diff --git a/inc/hgl/io/LoadDataArray.h b/inc/hgl/io/LoadDataArray.h new file mode 100644 index 0000000..12009c6 --- /dev/null +++ b/inc/hgl/io/LoadDataArray.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +namespace hgl +{ + /** + * 加载一个文件到数据阵列中 + */ + template static DataArray *LoadFileToDataArray(const OSString &filename) + { + io::FileInputStream fis; + + if(!fis.Open(filename))return(nullptr); + + const size_t file_size =fis.GetSize(); + const size_t size =(file_size+sizeof(T)-1)/sizeof(T); + + DataArray *mb=new DataArray(size); + + fis.Read(mb->data(),file_size); + + return(mb); + } +}//namespace hgl diff --git a/inc/hgl/type/LoadString.h b/inc/hgl/io/LoadString.h similarity index 100% rename from inc/hgl/type/LoadString.h rename to inc/hgl/io/LoadString.h diff --git a/inc/hgl/type/LoadStringList.h b/inc/hgl/io/LoadStringList.h similarity index 100% rename from inc/hgl/type/LoadStringList.h rename to inc/hgl/io/LoadStringList.h diff --git a/inc/hgl/io/SaveDataArray.h b/inc/hgl/io/SaveDataArray.h new file mode 100644 index 0000000..0cd1a88 --- /dev/null +++ b/inc/hgl/io/SaveDataArray.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include +namespace hgl +{ + /** + * 保存一个数据阵列到文件 + */ + template static bool SaveDataArrayToFile(const OSString &filename,const DataArray &mb) + { + const size_t size=mb.bytes(); + + if(size<=0)return(true); + + return(hgl::filesystem::SaveMemoryToFile(filename,mb.data(),mb.bytes())==size); + } +}//namespace hgl diff --git a/inc/hgl/type/SaveStringList.h b/inc/hgl/io/SaveStringList.h similarity index 100% rename from inc/hgl/type/SaveStringList.h rename to inc/hgl/io/SaveStringList.h diff --git a/inc/hgl/plugin/PlugInManage.h b/inc/hgl/plugin/PlugInManage.h index ab0bf53..3a60c5e 100644 --- a/inc/hgl/plugin/PlugInManage.h +++ b/inc/hgl/plugin/PlugInManage.h @@ -2,14 +2,14 @@ #define HGL_PLUG_IN_MANAGE_INCLUDE #include -#include +#include #include namespace hgl { /** * 插件管理 */ - class PlugInManage:public ResManage + class PlugInManage:public ObjectManage { OSString name; ///<插件类目名称(必须符合代码名称规则) @@ -28,7 +28,7 @@ namespace hgl PlugIn *LoadPlugin (const OSString &,const OSString &); ///<加载一个外部插件,明确指定全路径文件名 PlugIn *LoadPlugin (const OSString &); ///<加载一个外部插件,自行查找 bool UnloadPlugin(const OSString &); ///<释放一个外部插件 - };//class PlugInManage:public ResManage + };//class PlugInManage:public ObjectManage /** * 插件注册模板 diff --git a/inc/hgl/thread/Loader.h b/inc/hgl/thread/Loader.h index 188c545..8dfbaff 100644 --- a/inc/hgl/thread/Loader.h +++ b/inc/hgl/thread/Loader.h @@ -2,7 +2,7 @@ #define HGL_LOADER_INCLUDE #include -#include +#include #include #include namespace hgl diff --git a/inc/hgl/type/DataArray.h b/inc/hgl/type/DataArray.h new file mode 100644 index 0000000..4e1b05c --- /dev/null +++ b/inc/hgl/type/DataArray.h @@ -0,0 +1,246 @@ +#pragma once + +#include +namespace hgl +{ + /** + * 数据阵列 + */ + template class DataArray + { + protected: + + T *items; + size_t count; + size_t alloc_count; + + public: + + size_t GetCount ()const{return count;} ///<取得数据数量(注:非字节数) + const size_t GetAllocCount()const{return alloc_count;} ///<取得已分配的阵列大小(注:非字节数) + const size_t GetBytes ()const{return count*sizeof(T);} ///<取得阵列已使用的字节数 + const size_t GetAllocBytes()const{return alloc_count*sizeof(T);} ///<取得阵列已分配空间字节数 + + const T * GetData()const{return items;} + T * data() {return items;} + + public: + + T * begin (){return items;} ///<取得阵列起始地址指针 + T * end (){return items+count;} ///<取得阵列结束地址指针 + + const T * begin ()const{return items;} ///<取得阵列起始地址指针 + const T * end ()const{return items+count;} ///<取得阵列结束地址指针 + + public: + + /** + * 分配指定空间出来,供未来使用 + */ + void Alloc(size_t size) + { + if(size<=alloc_count) + return; + + alloc_count=power_to_2(size); + + if(!items) + items=(T *)hgl_malloc(alloc_count*sizeof(T)); + else + items=(T *)hgl_realloc(items,alloc_count*sizeof(T)); + } + + /** + * 设置阵列长度 + */ + void SetCount(size_t size) ///<设置阵列长度(注:非字节数) + { + Alloc(size); + + count=size; + } + + /** + * 增加阵列长度 + */ + void AddCount(size_t size) + { + SetCount(count+size); + } + + public: + + DataArray() + { + items=0; + count=0; + alloc_count=0; + } + + DataArray(size_t size) + { + if(size<=0) + items=0; + else + items=(T *)hgl_malloc(size*sizeof(T)); + + if(items) + { + count=size; + alloc_count=size; + } + else + { + count=0; + alloc_count=0; + } + } + + virtual ~DataArray() + { + Clear(); + } + + void Clear() + { + if(items) + hgl_free(items); + + count=0; + alloc_count=0; + } + + void ClearData() + { + count=0; + } + + void Zero() + { + if(items) + memset(items,0,alloc_count); + } + + /** + * 设置数据,请保证数据使用hgl_malloc分配,否则会因为释放函数不配对出现错误 + */ + void SetData(T *d,int s) + { + Clear(); + + items=d; + alloc_count=s; + count=s; + } + + /** + * 解除数据关联 + */ + void Unlink() + { + items=nullptr; + count=0; + alloc_count=0; + } + + /** + * 复制内存块中的数据 + * @param d 复制出来的数据指针 + * @param s 要复制出来的数据个数 + */ + void CopyData(const T *d,int s) + { + SetCount(s); + memcpy(items,d,s*sizeof(T)); + } + + /** + * 删除列表中的指定项,删除后将最后一个数据移到被删除的位置 + * @param index 要删除的数据项的索引值 + * @return 是否成功 + */ + bool Delete(int index) + { + if(count>0&&index>=0&&index0&&index>=0&&index=count)return(false); + + if(start<0) + { + number+=start; + start=0; + } + + if(start+number>count) + number=count-start; + + if(number<=0)return(false); + + count-=number; + + if(start()const + { + return items; + } + + T &operator[](int n) + { + return items[n]; + } + + const T &operator[](int n)const + { + return items[n]; + } + };//template class DataArray +}//namespace hgl diff --git a/inc/hgl/type/EnumClass.h b/inc/hgl/type/EnumClass.h deleted file mode 100644 index a5384d1..0000000 --- a/inc/hgl/type/EnumClass.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef HGL_ENUM_CLASS_INCLUDE -#define HGL_ENUM_CLASS_INCLUDE - -namespace hgl -{ - template class EnumAsUInteger - { - public: - - - };//template class EnumAsUInteger -}//namespace hgl -#endif//HGL_ENUM_CLASS_INCLUDE diff --git a/inc/hgl/type/MemBlock.h b/inc/hgl/type/MemBlock.h deleted file mode 100644 index 5dea4b6..0000000 --- a/inc/hgl/type/MemBlock.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef HGL_MEM_BLOCK_INCLUDE -#define HGL_MEM_BLOCK_INCLUDE - -#include -#include -#include -#include -namespace hgl -{ - /** - * 内存块模版 - */ - template class MemBlock - { - protected: - - T *buf; - size_t cur_size; - size_t buf_size; - - public: - - size_t GetLength ()const{return cur_size;} ///<取得内存块长度(注:非字节数) - const size_t GetMaxLength ()const{return buf_size;} ///<取得内存块最大长度(注:非字节数) - const size_t GetBytes ()const{return cur_size*sizeof(T);} ///<取得内存块字节数 - const size_t GetMaxBytes ()const{return buf_size*sizeof(T);} ///<取得内存块最大字节数 - - /** - * 分配指定空间出来,供未来使用 - */ - void Malloc(size_t size) - { - if(size<=buf_size) - return; - - buf_size=power_to_2(size); - - if(!buf) - buf=(T *)hgl_malloc(buf_size*sizeof(T)); - else - buf=(T *)hgl_realloc(buf,buf_size*sizeof(T)); - } - - /** - * 设置当前数据长度 - */ - void SetLength(size_t size) ///<设置内存块长度(注:非字节数) - { - Malloc(size); - - cur_size=size; - } - - void AddLength(size_t size) - { - SetLength(cur_size+size); - } - - public: - - MemBlock() - { - buf=0; - cur_size=0; - buf_size=0; - } - - MemBlock(size_t size) - { - if(size<=0) - buf=0; - else - buf=(T *)hgl_malloc(size*sizeof(T)); - - if(buf) - { - cur_size=size; - buf_size=size; - } - else - { - cur_size=0; - buf_size=0; - } - } - - virtual ~MemBlock() - { - Clear(); - } - - void Clear() - { - if(buf) - hgl_free(buf); - - cur_size=0; - buf_size=0; - } - - void ClearData() - { - cur_size=0; - } - - void Zero() - { - if(buf) - memset(buf,0,buf_size); - } - - /** - * 设置数据,请保证数据使用hgl_malloc分配,否则会因为释放函数不配对出现错误 - */ - void SetData(T *d,int s) - { - Clear(); - - buf=d; - buf_size=s; - cur_size=s; - } - - /** - * 解除数据关联 - */ - void Unlink() - { - buf=nullptr; - cur_size=0; - buf_size=0; - } - - /** - * 复制内存块中的数据 - * @param d 复制出来的缓冲区指针 - * @param s 要复制出来的数据个数 - */ - void CopyData(T *d,int s) - { - SetLength(s); - memcpy(buf,d,s*sizeof(T)); - } - - T *data()const{return buf;} - T *GetData()const{return buf;} - - size_t length()const{return cur_size;} - size_t GetCount()const{return cur_size;} - - size_t bytes()const - { - return cur_size*sizeof(T); - } - - operator T *()const - { - return buf; - } - - T *operator ->()const - { - return buf; - } - - T &operator[](int n) - { - return buf[n]; - } - - const T &operator[](int n)const - { - return buf[n]; - } - };//template class MemBlock - - /** - * 加载一个文件到内存块类中 - */ - template MemBlock *LoadFileToMemBlock(const OSString &filename) - { - io::FileInputStream fis; - - if(!fis.Open(filename))return(nullptr); - - const size_t file_size =fis.GetSize(); - const size_t size =(file_size+sizeof(T)-1)/sizeof(T); - - MemBlock *mb=new MemBlock(size); - - fis.Read(mb->data(),file_size); - - return(mb); - } - - /** - * 保存一个内存块到文件 - */ - template bool SaveMemBlockToFile(const OSString &filename,const MemBlock &mb) - { - const size_t size=mb.bytes(); - - if(size<=0)return(true); - - return(hgl::filesystem::SaveMemoryToFile(filename,mb.data(),mb.bytes())==size); - } -}//namespace hgl -#endif//HGL_MEM_BLOCK_INCLUDE diff --git a/inc/hgl/type/ObjectManage.h b/inc/hgl/type/ObjectManage.h new file mode 100644 index 0000000..63d570d --- /dev/null +++ b/inc/hgl/type/ObjectManage.h @@ -0,0 +1,234 @@ +#pragma once + +#include +namespace hgl +{ + template struct RefKeyValue:public KeyValue ///<带引用计数的Key/value对象结构 + { + int ref_count; ///<引用计数 + + public: + + RefKeyValue():KeyValue() + { + ref_count=1; + } + }; + + /** + * 对象管理器,它没有缓冲管理,仅仅是统一管理对象,并保证不会被重复加载 + */ + template class ObjectManage + { + public: + + using KVObject=RefKeyValue; + + protected: + + + _Map items; + + protected: + + virtual void Clear(V *obj){delete obj;} ///<对象释放虚拟函数(缺省为直接delete对象) + + public: + + virtual ~ObjectManage() + { + Clear(); + } + + virtual void Clear() ///<清除所有对象 + { + int n=items.GetCount(); + + while(n--) + { + KVObject *obj=items.GetItem(n); + + Clear(obj->value); + } + + items.Clear(); + } + + virtual void ClearFree() ///<清除所有引用计数为0的对象 + { + int n=items.GetCount(); + + while(n--) + { + KVObject *obj=items.GetItem(n); + + if(obj->ref_count<=0) + { + Clear(obj->value); + items.DeleteBySerial(n); + } + } + } + + const int GetCount()const{return items.GetCount();} ///<取得对象数量 + + virtual bool Add(const K &key,V *obj) ///<添加一个对象 + { + if(!obj)return(false); + + if(items.KeyExist(key)) + return(false); + + items.Add(key,obj); + return(true); + } + + virtual V * Find(const K &key) ///<查找一个对象(不增加引用计数) + { + int index=items.Find(key); + + if(index==-1) + return(nullptr); + + KVObject *obj=items.GetItem(index); + + return obj->value; + } + + virtual V * Get(const K &key) ///<取得一个对象(增加引用计数) + { + int index=items.Find(key); + + if(index!=-1) + { + KVObject *obj=items.GetItem(index); + + ++obj->ref_count; + + return obj->value; + } + + return(nullptr); + } + + virtual bool ValueExist(V *value) ///<确认这个对象是否存在 + { + return(items.FindByValue(value)!=-1); + } + + /** + * 获取指定对象的Key和引用计数 + * @param value 对象 + * @param key Key存放地址 + * @param ref_count 引用计数存放地址 + * @param 是否增加引用计数 + */ + virtual bool GetKeyByValue(V *value,K *key,uint *ref_count,bool inc_ref_count) + { + int index=items.FindByValue(value); + + if(index==-1)return(false); + + KVObject *obj=items.GetItem(index); + + if(inc_ref_count) + ++obj->ref_count; + + if(key) + *key=obj->key; + + if(ref_count) + *ref_count=obj->ref_count; + + return(true); + } + + /** + * 根据序列号释放一个对象(减少引用计数). + * + * \param index + * \param zero_clear 引用为0后是否清除对象 + * \return + */ + virtual int ReleaseBySerial(int index,bool zero_clear=false) + { + if(index==-1) + { + // ErrorHint(u"所释放的资源不存在"); + return(-1); + } + + KVObject *obj=items.GetItem(index); + + --obj->ref_count; + + if(obj->ref_count>0) + return obj->ref_count; + + if(zero_clear) + { + Clear(obj->value); + + items.DeleteBySerial(index); + } + + return 0; + } + + /** + * 根据key释放一个对象(减少引用计数). + * + * \param key + * \param zero_clear 引用为0后是否清除对象 + * \return + */ + virtual int Release(const K &key,bool zero_clear=false) + { + return ReleaseBySerial(items.Find(key),zero_clear); + } + + /** + * 根据对象本身减少一次引用计数 + * @param td 对象指针 + * @param zero_clear 引用为0后是否清除对象 + */ + int Release(V *td,bool zero_clear=false) + { + return ReleaseBySerial(items.FindByValue(td),zero_clear); + } + };//template class ObjectManage + + /** + * 使用整型对象类做数标识的对象管理器 + */ + template class IDObjectManage:public ObjectManage + { + K id_count=0; + + public: + + using ObjectManage::ObjectManage; + virtual ~IDObjectManage()=default; + + virtual K Add(V *value) + { + if(!value)return(-1); + + { + K key; + uint count; + + if(ObjectManage::GetKeyByValue(value,&key,&count,true)) + return key; + } + + if(!ObjectManage::Add(id_count,value)) + return(-1); + + return id_count++; + } + };//template class IDObjectManage:public ObjectManage + + template using U32ObjectManage=IDObjectManage; + template using U64ObjectManage=IDObjectManage; +}//namespace hgl diff --git a/inc/hgl/type/ResManage.cpp b/inc/hgl/type/ResManage.cpp deleted file mode 100644 index 351c3ab..0000000 --- a/inc/hgl/type/ResManage.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef HGL_RES_MANAGE_CPP -#define HGL_RES_MANAGE_CPP - -#include -namespace hgl -{ - template - ResManage::~ResManage() - { - Clear(); - } - - template - void ResManage::Clear() - { - int n=items.GetCount(); - - while(n--) - { - ResItem *obj=items.GetItem(n); - - Clear(obj->value); - } - - items.Clear(); - } - - template - void ResManage::ClearFree() - { - int n=items.GetCount(); - - while(n--) - { - ResItem *obj=items.GetItem(n); - - if(obj->ref_count<=0) - { - Clear(obj->value); - items.DeleteBySerial(n); - } - } - } - - template - bool ResManage::Add(const K &flag,V *obj) - { - if(!obj)return(false); - - if(items.KeyExist(flag)) - return(false); - - items.Add(flag,obj); - return(true); - } - - template - V *ResManage::Find(const K &flag) - { - int index=items.Find(flag); - - if(index==-1) - return(nullptr); - - ResItem *obj=items.GetItem(index); - - return obj->value; - } - - template - V *ResManage::Get(const K &flag) - { - int index=items.Find(flag); - - if(index!=-1) - { - ResItem *obj=items.GetItem(index); - - ++obj->ref_count; - - return obj->value; - } - - return(nullptr); - } - - /** - * 确认指定数据是否存在 - */ - template - bool ResManage::ValueExist(V *value) - { - return(items.FindByValue(value)!=-1); - } - - /** - * 获取指定数据的Key和引用计数 - * @param value 数据 - * @param key Key存放地址 - * @param ref_count 引用计数存放地址 - * @param 是否增加引用计数 - */ - template - bool ResManage::GetKeyByValue(V *value,K *key,uint *ref_count,bool inc_ref_count) - { - int index=items.FindByValue(value); - - if(index==-1)return(false); - - ResItem *obj=items.GetItem(index); - - if(inc_ref_count) - ++obj->ref_count; - - if(key) - *key=obj->key; - - if(ref_count) - *ref_count=obj->ref_count; - - return(true); - } - - template - int ResManage::ReleaseBySerial(int index,bool zero_clear) - { - if(index==-1) - { -// ErrorHint(u"所释放的资源不存在"); - return(-1); - } - - ResItem *obj=items.GetItem(index); - - --obj->ref_count; - - if(obj->ref_count>0) - return obj->ref_count; - - if(zero_clear) - { - Clear(obj->value); - - items.DeleteBySerial(index); - } - - return 0; - } - - template - int ResManage::Release(const K &flag,bool zero_clear) - { - return ReleaseBySerial(items.Find(flag),zero_clear); - } - - template - int ResManage::Release(V *td,bool zero_clear) - { - return ReleaseBySerial(items.FindByValue(td),zero_clear); - } -}//namespace hgl -#endif//HGL_RES_MANAGE_CPP diff --git a/inc/hgl/type/ResManage.h b/inc/hgl/type/ResManage.h deleted file mode 100644 index 2845fe1..0000000 --- a/inc/hgl/type/ResManage.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef HGL_RES_MANAGE_INCLUDE -#define HGL_RES_MANAGE_INCLUDE - -#include -namespace hgl -{ - template struct RefKeyValue:public KeyValue ///<带引用计数的Key/value数据结构 - { - int ref_count; ///<引用计数 - - public: - - RefKeyValue():KeyValue() - { - ref_count=1; - } - }; - - /** - * 资源管理器,它没有缓冲管理,仅仅是管理数据,并保证不会被重复加载 - */ - template class ResManage - { - protected: - - using ResItem=RefKeyValue; - - _Map items; - - int ReleaseBySerial(int,bool); - - protected: - - virtual void Clear(V *obj){delete obj;} ///<资源释放虚拟函数(缺省为直接delete对象) - - public: - - virtual ~ResManage(); - - virtual void Clear(); ///<清除所有数据 - virtual void ClearFree(); ///<清除所有引用计数为0的数据 - - const int GetCount()const{return items.GetCount();} ///<取得数据数量 - - virtual bool Add(const K &,V *); ///<添加一个数据 - virtual V * Find(const K &); ///<查找一个数据(不增加引用计数) - virtual V * Get(const K &); ///<取得一个数据(增加引用计数) - - virtual bool ValueExist(V *); ///<确认这个数据是否存在 - virtual bool GetKeyByValue(V *,K *,uint *,bool inc_ref=false); ///<取得一个数据的Key和引用次数 - - virtual int Release(const K &,bool zero_clear=false); ///<释放一个数据 - virtual int Release(V *,bool zero_clear=false); ///<释放一个数据 - };//template class ResManage - - /** - * 使用int类做数标致的资源管理器 - */ - template class IDResManage:public ResManage - { - K id_count=0; - - public: - - using ResManage::ResManage; - virtual ~IDResManage()=default; - - virtual K Add(V *value) - { - if(!value)return(-1); - - { - K key; - uint count; - - if(ResManage::GetKeyByValue(value,&key,&count,true)) - return key; - } - - if(!ResManage::Add(id_count,value)) - return(-1); - - return id_count++; - } - };//template class IDResManage:public ResManage - - template using ID32ResManage=IDResManage; - template using ID64ResManage=IDResManage; -}//namespace hgl -#include -#endif//HGL_RES_MANAGE_INCLUDE diff --git a/inc/hgl/type/ResPoolManage.h b/inc/hgl/type/ResPoolManage.h index 01f2dfd..c1079a9 100644 --- a/inc/hgl/type/ResPoolManage.h +++ b/inc/hgl/type/ResPoolManage.h @@ -2,11 +2,11 @@ #define HGL_RES_POOL_MANAGE_INCLUDE #include -#include +#include namespace hgl { - template class _ResPoolManage:public ResManage + template class _ResPoolManage:public ObjectManage { protected: @@ -21,7 +21,7 @@ namespace hgl _ResPoolManage(OP *op):data_pool(op){} virtual ~_ResPoolManage()=default; - };//template class _ResPoolManage:public ResManage + };//template class _ResPoolManage:public ObjectManage /** * 资源池是Pool/ResManage两个模板的组合应用 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e1e7d0..2a22fa1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,9 +59,6 @@ SET(STRING_HEADER_FILES ${TYPE_INCLUDE_PATH}/String.h ${TYPE_INCLUDE_PATH}/StringList.h ${TYPE_INCLUDE_PATH}/SplitString.h ${TYPE_INCLUDE_PATH}/MergeString.h - ${TYPE_INCLUDE_PATH}/LoadString.h - ${TYPE_INCLUDE_PATH}/LoadStringList.h - ${TYPE_INCLUDE_PATH}/SaveStringList.h ${TYPE_INCLUDE_PATH}/StdString.h) SET(TEXT_HEADER_FILES ${CMCORE_ROOT_INCLUDE_PATH}/hgl/Endian.h @@ -72,9 +69,7 @@ SET(TEXT_HEADER_FILES ${CMCORE_ROOT_INCLUDE_PATH}/hgl/Endian.h SET(TEXT_SOURCE_FILES Text/Endian.cpp Text/CodePage.cpp - Text/UnicodeBlocks.cpp - Text/LoadString.cpp - Text/LoadStringList.cpp) + Text/UnicodeBlocks.cpp) SOURCE_GROUP("Text\\String" FILES ${STRING_HEADER_FILES} Text/StringList.cpp) @@ -93,13 +88,13 @@ SOURCE_GROUP("DataType\\Template\\Memory" FILES ${BASE_OTHER_SOURCE}) ##I/O------------------------------------------------------------ SET(IO_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/io) -SET(IO_BASE_FILES ${IO_INCLUDE_PATH}/InputStream.h +SET(IO_BASE_FILES ${IO_INCLUDE_PATH}/InputStream.h ${IO_INCLUDE_PATH}/IOType.h ${IO_INCLUDE_PATH}/OutputStream.h ${IO_INCLUDE_PATH}/SeekAccess.h IO/IOType.cpp) -SET(IO_DATA_FILES ${IO_INCLUDE_PATH}/DataInputStream.h +SET(IO_DATA_FILES ${IO_INCLUDE_PATH}/DataInputStream.h ${IO_INCLUDE_PATH}/DataOutputStream.h ${IO_INCLUDE_PATH}/EndianDataInputStream.h ${IO_INCLUDE_PATH}/EndianDataOutputStream.h @@ -107,10 +102,13 @@ SET(IO_DATA_FILES ${IO_INCLUDE_PATH}/DataInputStream.h IO/DataInputStream.cpp IO/DataOutputStream.cpp) -SET(IO_MEMORY_FILES ${IO_INCLUDE_PATH}/MemoryInputStream.h - ${IO_INCLUDE_PATH}/MemoryOutputStream.h) +SET(IO_MEMORY_STREAM_FILES ${IO_INCLUDE_PATH}/MemoryInputStream.h + ${IO_INCLUDE_PATH}/MemoryOutputStream.h) -SET(IO_FILE_FILES ${IO_INCLUDE_PATH}/FileAccess.h +SET(IO_DATA_ARRAY_FILES ${IO_INCLUDE_PATH}/LoadDataArray.h + ${IO_INCLUDE_PATH}/SaveDataArray.h) + +SET(IO_FILE_FILES ${IO_INCLUDE_PATH}/FileAccess.h ${IO_INCLUDE_PATH}/FileInputStream.h ${IO_INCLUDE_PATH}/FileOutputStream.h ${IO_INCLUDE_PATH}/RandomAccessFile.h @@ -122,11 +120,15 @@ SET(IO_FILE_FILES ${IO_INCLUDE_PATH}/FileAccess.h IO/FileOutputStream.cpp IO/RandomAccessFile.cpp) - SET(IO_JAVA_FILES ${IO_INCLUDE_PATH}/JavaInputStream.h - ${IO_INCLUDE_PATH}/JavaOutputStream.h) + ${IO_INCLUDE_PATH}/JavaOutputStream.h) -SET(IO_TEXT_FILES IO/TextOutputStream.cpp) +SET(IO_TEXT_FILES IO/TextOutputStream.cpp + Text/LoadString.cpp + Text/LoadStringList.cpp) + +SET(IO_STRING_LIST_FILES ${IO_INCLUDE_PATH}/LoadStringList.h + ${IO_INCLUDE_PATH}/SaveStringList.h) SET(INPUT_EVENT_FILES ${IO_INCLUDE_PATH}/event/KeyboardEvent.h ${IO_INCLUDE_PATH}/event/MouseEvent.h @@ -135,20 +137,24 @@ SET(INPUT_EVENT_FILES ${IO_INCLUDE_PATH}/event/KeyboardEvent.h SOURCE_GROUP("IO\\Event" FILES ${INPUT_EVENT_FILES}) -SOURCE_GROUP("IO\\Base" FILES ${IO_BASE_FILES}) -SOURCE_GROUP("IO\\Data" FILES ${IO_DATA_FILES}) -SOURCE_GROUP("IO\\Memory" FILES ${IO_MEMORY_FILES}) -SOURCE_GROUP("IO\\File" FILES ${IO_FILE_FILES}) -SOURCE_GROUP("IO\\Jave" FILES ${IO_JAVA_FILES}) -SOURCE_GROUP("IO\\Text" FILES ${IO_TEXT_FILES}) +SOURCE_GROUP("IO\\Base" FILES ${IO_BASE_FILES}) +SOURCE_GROUP("IO\\DataIOStream" FILES ${IO_DATA_FILES}) +SOURCE_GROUP("IO\\DataArray" FILES ${IO_DATA_ARRAY_FILES}) +SOURCE_GROUP("IO\\MemoryStream" FILES ${IO_MEMORY_STREAM_FILES}) +SOURCE_GROUP("IO\\File" FILES ${IO_FILE_FILES}) +SOURCE_GROUP("IO\\Jave" FILES ${IO_JAVA_FILES}) +SOURCE_GROUP("IO\\Text" FILES ${IO_TEXT_FILES}) +SOURCE_GROUP("ID\\StringList" FILES ${IO_STRING_LIST_FILES}) -SET(IO_SOURCE_FILES ${IO_BASE_FILES} - ${IO_DATA_FILES} - ${IO_MEMORY_FILES} - ${IO_FILE_FILES} - ${IO_JAVA_FILES} - ${IO_TEXT_FILES} - ${INPUT_EVENT_FILES}) +SET(IO_SOURCE_FILES ${IO_BASE_FILES} + ${IO_DATA_FILES} + ${IO_DATA_ARRAY_FILES} + ${IO_MEMORY_STREAM_FILES} + ${IO_FILE_FILES} + ${IO_JAVA_FILES} + ${IO_TEXT_FILES} + ${IO_STRING_LIST_FILES} + ${INPUT_EVENT_FILES}) SET(FILESYSTEM_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/filesystem) diff --git a/src/IO/TextInputStream.cpp b/src/IO/TextInputStream.cpp index 1f3c2bf..081e82a 100644 --- a/src/IO/TextInputStream.cpp +++ b/src/IO/TextInputStream.cpp @@ -1,4 +1,4 @@ -#include +#include namespace hgl { @@ -77,7 +77,7 @@ namespace hgl { uint8 *p=buffer; - if(stream_pos==0) //ʼǼһBOMͷ + if(stream_pos==0) //最开始,那检测一下BOM头 { if(cur_buf_size>=2) { diff --git a/src/Text/LoadString.cpp b/src/Text/LoadString.cpp index f4d7194..0b0b26a 100644 --- a/src/Text/LoadString.cpp +++ b/src/Text/LoadString.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace hgl { diff --git a/src/Text/LoadStringList.cpp b/src/Text/LoadStringList.cpp index 9a5bfac..b90fdcf 100644 --- a/src/Text/LoadStringList.cpp +++ b/src/Text/LoadStringList.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include