summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/io/file_data.h
blob: 9aa0e3ba09b934866202693fa66eaeb9f89e582d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef __ASURA_ENGINE_FILE_DATA_H__
#define __ASURA_ENGINE_FILE_DATA_H__

#include <string>

#include <asura-lib-utils/scripting/portable.hpp>

#include "data_buffer.h"

namespace AsuraEngine
{
	namespace IO
	{

		class Filesystem;

		///
		/// filesystemֱӶȡļʱFileDataļݺϢFilesystem
		///
		class FileData ASURA_FINAL
			: public AEScripting::Portable<FileData>
		{
		public:

			LUAX_DECL_FACTORY(FileData);

			~FileData();

			///
			/// ļݣͨDatabufferݺʹСڲӿڶData bufferΪҲdata buffer
			///
			DataBuffer* GetDataBuffer();

			const std::string& GetFileName(); 
			const std::string& GetExtension();
			const std::string& GetName();

		private:

			friend class Filesystem;

			FileData(const std::string& name);

			///
			/// data buffer
			///
			void BindData(ASURA_MOVE DataBuffer* buffer);

			///
			/// Data bufferfiledataʱ٣luaüΪ0ʱluaGC١mDataʱһԱá
			///
			ASURA_REF DataBuffer* mData;
			Luax::LuaxMemberRef   mDataRef;

			std::string mFileName;  ///< չļ
			std::string mExtension; ///< չ
			std::string mName;      ///< ͺ׺ļ

			LUAX_DECL_METHOD(_GetDataBuffer);
			LUAX_DECL_METHOD(_GetFileName);
			LUAX_DECL_METHOD(_GetExtension);
			LUAX_DECL_METHOD(_GetName);

		};

	}
}

#endif