From b87af86b4c5eab0f3c57e28fdd6e985de99f3aa7 Mon Sep 17 00:00:00 2001
From: HuYingzhuo
Date: Sun, 5 May 2019 14:22:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E7=89=88=EF=BC=8C=E5=88=A0=E9=99=A4?=
=?UTF-8?q?=E8=A1=8C=E5=B0=BE=E7=A9=BA=E6=A0=BC=E4=BB=A5=E5=8F=8A=E6=89=80?=
=?UTF-8?q?=E6=9C=89TAB=E8=BD=AC=E7=A9=BA=E6=A0=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
example/Vulkan/main.cpp | 12 +-
inc/hgl/CodePage.h | 312 +++----
inc/hgl/CompOperator.h | 16 +-
inc/hgl/LogInfo.h | 32 +-
inc/hgl/Logger.h | 18 +-
inc/hgl/Macro.h | 206 ++---
inc/hgl/Str.h | 120 +--
inc/hgl/Time.h | 18 +-
inc/hgl/TypeFunc.h | 738 ++++++++---------
inc/hgl/endian/Endian.h | 396 ++++-----
inc/hgl/filesystem/EnumVolume.h | 40 +-
inc/hgl/filesystem/FileSystem.h | 64 +-
inc/hgl/graph/Light.h | 48 +-
inc/hgl/graph/vulkan/VK.h | 2 +-
inc/hgl/graph/vulkan/VKBufferData.h | 8 +-
inc/hgl/graph/vulkan/VKDevice.h | 8 +-
inc/hgl/graph/vulkan/VKDeviceAttribute.h | 2 +-
inc/hgl/graph/vulkan/VKFormat.h | 8 +-
inc/hgl/graph/vulkan/VKPhysicalDevice.h | 2 +-
inc/hgl/graph/vulkan/VKPrimivate.h | 8 +-
inc/hgl/graph/vulkan/VKShaderModule.h | 6 +-
inc/hgl/graph/vulkan/VKShaderParse.h | 2 +-
inc/hgl/io/EndianDataInputStream.h | 148 ++--
inc/hgl/io/EndianDataOutputStream.h | 150 ++--
inc/hgl/io/FileAccess.h | 112 +--
inc/hgl/io/FileInputStream.h | 98 +--
inc/hgl/io/FileOutputStream.h | 114 +--
inc/hgl/io/IOType.h | 40 +-
inc/hgl/io/InputStream.h | 50 +-
inc/hgl/io/JavaInputStream.h | 94 +--
inc/hgl/io/JavaOutputStream.h | 86 +-
inc/hgl/io/MemoryInputStream.h | 246 +++---
inc/hgl/io/MemoryOutputStream.h | 334 ++++----
inc/hgl/io/OutputStream.h | 44 +-
inc/hgl/io/RandomAccessFile.h | 58 +-
inc/hgl/io/SeekAccess.h | 48 +-
inc/hgl/io/TextOutputStream.h | 228 ++---
inc/hgl/platform/ExternalModule.h | 40 +-
inc/hgl/platform/FuncLoad.h | 40 +-
inc/hgl/platform/InputDevice.h | 308 +++----
inc/hgl/platform/Platform.h | 380 ++++-----
inc/hgl/platform/SystemInfo.h | 4 +-
inc/hgl/platform/Window.h | 6 +-
inc/hgl/platform/compiler/DataTypeGNU.h | 18 +-
inc/hgl/platform/compiler/DataTypeTiny.h | 4 +-
inc/hgl/platform/compiler/DataTypeWin.h | 16 +-
inc/hgl/platform/compiler/EventFunc.h | 346 ++++----
inc/hgl/platform/compiler/GNU.h | 114 +--
inc/hgl/platform/compiler/Intel.h | 30 +-
inc/hgl/platform/compiler/LLVM.h | 12 +-
inc/hgl/platform/compiler/Microsoft.h | 4 +-
inc/hgl/platform/compiler/Property.h | 118 +--
inc/hgl/platform/os/Android.h | 84 +-
inc/hgl/platform/os/BSD.h | 84 +-
inc/hgl/platform/os/Linux.h | 82 +-
inc/hgl/platform/os/MSWindows.h | 56 +-
inc/hgl/platform/os/MacOS.h | 82 +-
inc/hgl/proc/Fifo.h | 32 +-
inc/hgl/proc/FifoInputStream.h | 42 +-
inc/hgl/proc/Pipe.h | 6 +-
inc/hgl/proc/Proc.h | 52 +-
inc/hgl/proc/ProcMutex.h | 30 +-
inc/hgl/thread/Atomic.h | 62 +-
inc/hgl/thread/CondVar.h | 32 +-
inc/hgl/thread/DataPost.h | 228 ++---
inc/hgl/thread/Loader.h | 88 +-
inc/hgl/thread/RWLock.h | 282 +++----
inc/hgl/thread/RingBuffer.h | 498 +++++------
inc/hgl/thread/SemLock.h | 366 ++++----
inc/hgl/thread/Semaphore.h | 26 +-
inc/hgl/thread/SwapColl.h | 228 ++---
inc/hgl/thread/SwapData.h | 130 +--
inc/hgl/thread/Thread.h | 72 +-
inc/hgl/thread/ThreadMutex.h | 244 +++---
inc/hgl/thread/Workflow.h | 468 +++++------
inc/hgl/thread/atomic/AtomicGNU.h | 60 +-
inc/hgl/thread/atomic/AtomicOSX.h | 62 +-
inc/hgl/thread/atomic/AtomicWin.h | 126 +--
inc/hgl/type/BaseString.h | 132 +--
inc/hgl/type/Color.h | 362 ++++----
inc/hgl/type/Color3f.h | 124 +--
inc/hgl/type/Color4f.h | 140 ++--
inc/hgl/type/DateTime.h | 256 +++---
inc/hgl/type/List.cpp | 782 +++++++++---------
inc/hgl/type/List.h | 214 ++---
inc/hgl/type/Map.cpp | 712 ++++++++--------
inc/hgl/type/Map.h | 470 +++++------
inc/hgl/type/ObjectList.cpp | 364 ++++----
inc/hgl/type/Pair.h | 76 +-
inc/hgl/type/Pool.cpp | 192 ++---
inc/hgl/type/Pool.h | 352 ++++----
inc/hgl/type/Queue.cpp | 374 ++++-----
inc/hgl/type/Queue.h | 94 +--
inc/hgl/type/RectScope.cpp | 130 +--
inc/hgl/type/RectScope.h | 192 ++---
inc/hgl/type/ResManage.cpp | 178 ++--
inc/hgl/type/ResManage.h | 62 +-
inc/hgl/type/ResPoolManage.h | 36 +-
inc/hgl/type/Set.cpp | 456 +++++-----
inc/hgl/type/Set.h | 66 +-
inc/hgl/type/Smart.h | 752 ++++++++---------
inc/hgl/type/Stack.cpp | 374 ++++-----
inc/hgl/type/Stack.h | 68 +-
inc/hgl/type/StringInstance.h | 38 +-
inc/hgl/type/StringList.h | 56 +-
inc/hgl/type/Vertex2.cpp | 214 ++---
inc/hgl/type/Vertex2.h | 156 ++--
inc/hgl/type/_Object.h | 48 +-
src/Base/DataType/Color.cpp | 12 +-
src/Base/FileSystem/FileSystem.cpp | 36 +-
src/Base/IO/DataInputStream.cpp | 16 +-
src/Base/IO/FileInputStream.cpp | 6 +-
src/Base/IO/FileOutputStream.cpp | 4 +-
src/Base/Other/ThreadFunc.cpp | 2 +-
src/Base/Other/TimeVal.cpp | 10 +-
src/Platform/Android/AndroidMain.cpp | 290 +++----
src/Platform/Android/JNISupport.cpp | 4 +-
src/Platform/Android/LogConsole.cpp | 152 ++--
.../Android/NativeActivitySupport.cpp | 4 +-
src/Platform/Apple/Semaphore.cpp | 92 +--
src/Platform/UNIX/CodePage.cpp | 154 ++--
src/Platform/UNIX/CondVar.cpp | 64 +-
src/Platform/UNIX/DateTime.cpp | 166 ++--
src/Platform/UNIX/EnumFile.cpp | 2 +-
src/Platform/UNIX/ExternalModule.cpp | 46 +-
src/Platform/UNIX/Fifo.cpp | 28 +-
src/Platform/UNIX/File.cpp | 4 +-
src/Platform/UNIX/FileAccess.cpp | 60 +-
src/Platform/UNIX/Process.cpp | 114 +--
src/Platform/UNIX/RWLock.cpp | 56 +-
src/Platform/UNIX/Semaphore.cpp | 116 +--
src/Platform/UNIX/SystemInfo.cpp | 104 +--
src/Platform/UNIX/Thread.cpp | 90 +-
src/Platform/UNIX/ThreadMutex.cpp | 92 +--
src/Platform/UNIX/Time.cpp | 108 +--
src/Platform/Win/Clipboard.cpp | 56 +-
src/Platform/Win/EnumFile.cpp | 2 +-
src/Platform/Win/FileAccess.cpp | 14 +-
src/Platform/Win/Pipe.cpp | 10 +-
src/Platform/Win/ProgramPath.cpp | 8 +-
src/Platform/Win/WinMessage.cpp | 326 ++++----
src/Platform/Win/WinWindow.cpp | 178 ++--
src/RenderDevice/Vulkan/VKCommandBuffer.cpp | 6 +-
src/RenderDevice/Vulkan/VKDescriptorSets.cpp | 4 +-
src/RenderDevice/Vulkan/VKDevice.cpp | 6 +-
src/RenderDevice/Vulkan/VKDeviceCreater.cpp | 8 +-
src/RenderDevice/Vulkan/VKFormat.cpp | 4 +-
src/RenderDevice/Vulkan/VKMaterial.cpp | 4 +-
src/RenderDevice/Vulkan/VKPipeline.cpp | 2 +-
src/RenderDevice/Vulkan/VKRenderable.cpp | 6 +-
.../Vulkan/VKShaderModuleManage.cpp | 6 +-
151 files changed, 9410 insertions(+), 9410 deletions(-)
diff --git a/example/Vulkan/main.cpp b/example/Vulkan/main.cpp
index b35e4695..99ee7d69 100644
--- a/example/Vulkan/main.cpp
+++ b/example/Vulkan/main.cpp
@@ -9,7 +9,7 @@ constexpr uint32_t SCREEN_HEIGHT=720;
struct WorldConfig
{
- Matrix4f mvp;
+ Matrix4f mvp;
}world;
constexpr uint32_t VERTEX_COUNT=3;
@@ -29,12 +29,12 @@ constexpr float color_data[VERTEX_COUNT][3]=
class TestApp:public VulkanApplicationFramework
{
-private:
+private:
uint swap_chain_count=0;
vulkan::Material * material =nullptr;
- vulkan::Renderable * render_obj =nullptr;
+ vulkan::Renderable * render_obj =nullptr;
vulkan::Buffer * ubo_mvp =nullptr;
vulkan::Pipeline * pipeline =nullptr;
@@ -84,7 +84,7 @@ private:
}
void InitVBO()
- {
+ {
vertex_buffer =device->CreateVBO(FMT_RG32F, VERTEX_COUNT,vertex_data);
color_buffer =device->CreateVBO(FMT_RGB32F, VERTEX_COUNT,color_data);
@@ -135,7 +135,7 @@ private:
public:
- bool Init()
+ bool Init()
{
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
return(false);
@@ -182,6 +182,6 @@ int main(int,char **)
return(-1);
while(app.Run());
-
+
return 0;
}
diff --git a/inc/hgl/CodePage.h b/inc/hgl/CodePage.h
index ef366f78..c4deb9fb 100644
--- a/inc/hgl/CodePage.h
+++ b/inc/hgl/CodePage.h
@@ -6,222 +6,222 @@
#include
namespace hgl
{
- struct CodePageAndCharSet
- {
- CharCodePage codepage;
- CharSetName charset;
- };
+ struct CodePageAndCharSet
+ {
+ CharCodePage codepage;
+ CharSetName charset;
+ };
- constexpr struct CodePageAndCharSet CodePage2CharSet[]=
- {
- {ccpNone, "us-ascii" },
+ constexpr struct CodePageAndCharSet CodePage2CharSet[]=
+ {
+ {ccpNone, "us-ascii" },
- {ccpGBK, "gbk" },
- {ccpBig5, "big5" },
- {ccpGB2312, "gb2312" },
- {ccpGB18030, "gb18030" },
+ {ccpGBK, "gbk" },
+ {ccpBig5, "big5" },
+ {ccpGB2312, "gb2312" },
+ {ccpGB18030, "gb18030" },
- {ccpShiftJIS, "shift-jis" },
- {ccpJISX, "iso-2022-jp" },
+ {ccpShiftJIS, "shift-jis" },
+ {ccpJISX, "iso-2022-jp" },
- {ccpKorean, "ks_c_5601-1987"},
+ {ccpKorean, "ks_c_5601-1987"},
- {ccpMacJanpan, "x-mac-japanese" },
- {ccpMacTraditionalChinese, "x-mac-chinesetrad" },
- {ccpMacSimplifiedChinese, "x-mac-chinesesimp" },
+ {ccpMacJanpan, "x-mac-japanese" },
+ {ccpMacTraditionalChinese, "x-mac-chinesetrad" },
+ {ccpMacSimplifiedChinese, "x-mac-chinesesimp" },
- {ccpUTF7, "utf-7" },
- {ccpUTF8, "utf-8" },
+ {ccpUTF7, "utf-7" },
+ {ccpUTF8, "utf-8" },
- {ccpUTF16LE, "utf-16le" },
- {ccpUTF16BE, "utf-16be" },
- {ccpUTF32LE, "utf-32le" },
- {ccpUTF32BE, "utf-32be" },
- };//const struct
+ {ccpUTF16LE, "utf-16le" },
+ {ccpUTF16BE, "utf-16be" },
+ {ccpUTF32LE, "utf-32le" },
+ {ccpUTF32BE, "utf-32be" },
+ };//const struct
- constexpr int CharSetCount=sizeof(CodePage2CharSet)/sizeof(CodePageAndCharSet);
+ constexpr int CharSetCount=sizeof(CodePage2CharSet)/sizeof(CodePageAndCharSet);
- inline const char *FindCharSet(CharCodePage ccp)
- {
- for(int i=0;i(str)+1,len);
- }
+ inline char * u16_to_u8(const u16char *str)
+ {
+ int len;
+ return u16_to_u8(str,hgl::strlen(str)+1,len);
+ }
- inline u16char *u8_to_u16(const char *str)
- {
- int len;
- return u8_to_u16(str,hgl::strlen(str)+1,len);
- }
+ inline u16char *u8_to_u16(const char *str)
+ {
+ int len;
+ return u8_to_u16(str,hgl::strlen(str)+1,len);
+ }
- inline UTF16String to_u16(const char *u8_str,int length)
- {
- int wlen;
- u16char *ws=u8_to_u16(u8_str,length,wlen);
+ inline UTF16String to_u16(const char *u8_str,int length)
+ {
+ int wlen;
+ u16char *ws=u8_to_u16(u8_str,length,wlen);
- return UTF16String(ws,wlen,true);
- }
+ return UTF16String(ws,wlen,true);
+ }
- inline UTF16String to_u16(const UTF8String &u8str)
- {
- return to_u16(u8str.c_str(),u8str.Length());
- }
+ inline UTF16String to_u16(const UTF8String &u8str)
+ {
+ return to_u16(u8str.c_str(),u8str.Length());
+ }
- inline UTF16String to_u16(const char *str)
- {
- int wlen;
+ inline UTF16String to_u16(const char *str)
+ {
+ int wlen;
- u16char *ws=u8_to_u16(str,strlen(str),wlen);
+ u16char *ws=u8_to_u16(str,strlen(str),wlen);
- return UTF16String(ws,wlen,true);
- }
+ return UTF16String(ws,wlen,true);
+ }
- inline UTF8String to_u8(const u16char *wide_str,int length)
- {
- int ulen;
+ inline UTF8String to_u8(const u16char *wide_str,int length)
+ {
+ int ulen;
- char *us=u16_to_u8(wide_str,length,ulen);
+ char *us=u16_to_u8(wide_str,length,ulen);
- return UTF8String(us,ulen,true);
- }
+ return UTF8String(us,ulen,true);
+ }
- inline UTF8String to_u8(const UTF16String &ws)
- {
- return to_u8(ws.c_str(),ws.Length());
- }
+ inline UTF8String to_u8(const UTF16String &ws)
+ {
+ return to_u8(ws.c_str(),ws.Length());
+ }
#if HGL_OS == HGL_OS_Windows
inline OSString ToOSString(const char *str){return to_u16(str);}
diff --git a/inc/hgl/CompOperator.h b/inc/hgl/CompOperator.h
index 78ebf6a5..5d4dd831 100644
--- a/inc/hgl/CompOperator.h
+++ b/inc/hgl/CompOperator.h
@@ -3,14 +3,14 @@
namespace hgl
{
- #define CompOperator(name,compfunc) const bool operator > (name i)const {return compfunc(i)>0;} \
- const bool operator < (name i)const {return compfunc(i)<0;} \
- const bool operator >=(name i)const {return compfunc(i)>=0;}\
- const bool operator <=(name i)const {return compfunc(i)<=0;}\
- const bool operator ==(name i)const {return compfunc(i)==0;}\
- const bool operator !=(name i)const {return compfunc(i)!=0;}
+ #define CompOperator(name,compfunc) const bool operator > (name i)const {return compfunc(i)>0;} \
+ const bool operator < (name i)const {return compfunc(i)<0;} \
+ const bool operator >=(name i)const {return compfunc(i)>=0;}\
+ const bool operator <=(name i)const {return compfunc(i)<=0;}\
+ const bool operator ==(name i)const {return compfunc(i)==0;}\
+ const bool operator !=(name i)const {return compfunc(i)!=0;}
- #define CompOperatorMemcmp(name) int _Comp(name data)const{return memcmp(this,&data,sizeof(name));} \
- CompOperator(name,_Comp)
+ #define CompOperatorMemcmp(name) int _Comp(name data)const{return memcmp(this,&data,sizeof(name));} \
+ CompOperator(name,_Comp)
}//namespace hgl
#endif//HGL_COMP_OPERATOR_INCLUDE
diff --git a/inc/hgl/LogInfo.h b/inc/hgl/LogInfo.h
index 3099136e..71ac103a 100644
--- a/inc/hgl/LogInfo.h
+++ b/inc/hgl/LogInfo.h
@@ -18,42 +18,42 @@ namespace hgl
{
enum LogLevel
{
- llError=0, //错误,肯定出对话框
- llProblem, //问题,默认出对话框
- llHint, //提示,不重要,debug状态默认出对话框
- llLog //记录一下
+ llError=0, //错误,肯定出对话框
+ llProblem, //问题,默认出对话框
+ llHint, //提示,不重要,debug状态默认出对话框
+ llLog //记录一下
};//enum LogLevel
- inline void Log(LogLevel ll,const UTF16String &str)
+ inline void Log(LogLevel ll,const UTF16String &str)
{
std::wcout<>LogFrom(\"")+to_u16(filename)+U16_TEXT("\", ")+UTF16String(line)+U16_TEXT(" line,func:\"")+to_u16(funcname)+U16_TEXT("\")"));
}
- inline void DebugLog(LogLevel ll,const UTF8String &str,const char *filename,int line,const char *funcname)
+ inline void DebugLog(LogLevel ll,const UTF8String &str,const char *filename,int line,const char *funcname)
{
Log(ll,str+U8_TEXT(">>LogFrom(\"")+UTF8String(filename)+U8_TEXT("\", ")+UTF8String(line)+U8_TEXT(" line,func:\"")+UTF8String(funcname)+U8_TEXT("\")"));
}
- #define LOG_INFO(str) {Log(llLog, str);}
- #define LOG_HINT(str) {Log(llHint, str);}
- #define LOG_PROBLEM(str) {Log(llProblem, str);}
- #define LOG_ERROR(str) {Log(llError, str);}
+ #define LOG_INFO(str) {Log(llLog, str);}
+ #define LOG_HINT(str) {Log(llHint, str);}
+ #define LOG_PROBLEM(str) {Log(llProblem, str);}
+ #define LOG_ERROR(str) {Log(llError, str);}
- #define RETURN_FALSE {DebugLog(llLog,OS_TEXT("return(false)" ),__FILE__,__LINE__,__HGL_FUNC__);return(false);}
- #define RETURN_ERROR(v) {DebugLog(llLog,OS_TEXT("return error(")+OSString(v)+OS_TEXT(")"),__FILE__,__LINE__,__HGL_FUNC__);return(v);}
- #define RETURN_ERROR_NULL {DebugLog(llLog,OS_TEXT("return error(nullptr)" ),__FILE__,__LINE__,__HGL_FUNC__);return(nullptr);}
+ #define RETURN_FALSE {DebugLog(llLog,OS_TEXT("return(false)" ),__FILE__,__LINE__,__HGL_FUNC__);return(false);}
+ #define RETURN_ERROR(v) {DebugLog(llLog,OS_TEXT("return error(")+OSString(v)+OS_TEXT(")"),__FILE__,__LINE__,__HGL_FUNC__);return(v);}
+ #define RETURN_ERROR_NULL {DebugLog(llLog,OS_TEXT("return error(nullptr)" ),__FILE__,__LINE__,__HGL_FUNC__);return(nullptr);}
- #define RETURN_BOOL(proc) {if(proc)return(true);RETURN_FALSE}
+ #define RETURN_BOOL(proc) {if(proc)return(true);RETURN_FALSE}
#define IF_FALSE_RETURN(str) if(!str)RETURN_FALSE;
}//namespace logger
diff --git a/inc/hgl/Logger.h b/inc/hgl/Logger.h
index 4897b7e2..aa1283d7 100644
--- a/inc/hgl/Logger.h
+++ b/inc/hgl/Logger.h
@@ -8,10 +8,10 @@ namespace hgl
{
enum LogLevel
{
- llError=0, //错误,肯定出对话框
- llProblem, //问题,默认出对话框
- llHint, //提示,不重要,debug状态默认出对话框
- llLog //记录一下
+ llError=0, //错误,肯定出对话框
+ llProblem, //问题,默认出对话框
+ llHint, //提示,不重要,debug状态默认出对话框
+ llLog //记录一下
};//enum LogLevel
/**
@@ -21,7 +21,7 @@ namespace hgl
{
protected:
- LogLevel min_level; ///<最小输出级别
+ LogLevel min_level; ///<最小输出级别
UTF16String project_code;
public:
@@ -29,12 +29,12 @@ namespace hgl
Logger(LogLevel l){min_level=l;}
virtual ~Logger()=default;
- const LogLevel GetLevel()const{return min_level;} ///<取得最小输出级别
+ const LogLevel GetLevel()const{return min_level;} ///<取得最小输出级别
- virtual void Close()=0; ///<关闭日志
+ virtual void Close()=0; ///<关闭日志
- virtual void Write(const u16char *,int)=0; ///<输出一行u16char日志
- virtual void Write(const char *,int)=0; ///<输出一行char(utf8)日志
+ virtual void Write(const u16char *,int)=0; ///<输出一行u16char日志
+ virtual void Write(const char *,int)=0; ///<输出一行char(utf8)日志
};//class Logger
}//namespace logger
diff --git a/inc/hgl/Macro.h b/inc/hgl/Macro.h
index 5c8eb327..4e954ff9 100644
--- a/inc/hgl/Macro.h
+++ b/inc/hgl/Macro.h
@@ -3,118 +3,118 @@
namespace hgl
{
- #define RETURN_OBJECT_OF_ARRAY(array,index,max_count) return (index<0||index>=max_count)?nullptr:array[index];
+ #define RETURN_OBJECT_OF_ARRAY(array,index,max_count) return (index<0||index>=max_count)?nullptr:array[index];
- #define NEW_NULL_ARRAY(name,type,count) { \
- name=new type[count]; \
- \
- memset(name,0,sizeof(type)*count); \
- }
+ #define NEW_NULL_ARRAY(name,type,count) { \
+ name=new type[count]; \
+ \
+ memset(name,0,sizeof(type)*count); \
+ }
- #define SAFE_CLEAR(name) { \
- if(name) \
- { \
- delete name; \
- name=nullptr; \
- } \
- }
+ #define SAFE_CLEAR(name) { \
+ if(name) \
+ { \
+ delete name; \
+ name=nullptr; \
+ } \
+ }
- #define SAFE_CLEAR_ARRAY(name) { \
- if(name) \
- { \
- delete[] name; \
- name=nullptr; \
- } \
- }
+ #define SAFE_CLEAR_ARRAY(name) { \
+ if(name) \
+ { \
+ delete[] name; \
+ name=nullptr; \
+ } \
+ }
- #define SAFE_CLEAR_OBJECT_ARRAY(name,num) { \
- if(name&&num>=0) \
- { \
- int safe_clear_object_array_number=num; \
- \
- while(safe_clear_object_array_number--) \
- if(name[safe_clear_object_array_number]) \
- delete name[safe_clear_object_array_number]; \
- \
- delete[] name; \
- name=nullptr; \
- } \
- }
+ #define SAFE_CLEAR_OBJECT_ARRAY(name,num) { \
+ if(name&&num>=0) \
+ { \
+ int safe_clear_object_array_number=num; \
+ \
+ while(safe_clear_object_array_number--) \
+ if(name[safe_clear_object_array_number]) \
+ delete name[safe_clear_object_array_number]; \
+ \
+ delete[] name; \
+ name=nullptr; \
+ } \
+ }
- #define FREE_OBJECT_ARRAY(name,num) { \
- if(name&&num>=0) \
- { \
- int free_object_array_number=num; \
- \
- while(free_object_array_number--) \
- if(name[free_object_array_number]) \
- delete name[free_object_array_number]; \
- \
- hgl_free(name); \
- name=nullptr; \
- } \
- }
-
- #define SAFE_FREE_OBJECT_ARRAY(name,num) { \
- if(name) \
- FREE_OBJECT_ARRAY(name,num); \
- }
-
- #define SAFE_FREE(name) { \
- if(name) \
- hgl_free(name); \
+ #define FREE_OBJECT_ARRAY(name,num) { \
+ if(name&&num>=0) \
+ { \
+ int free_object_array_number=num; \
+ \
+ while(free_object_array_number--) \
+ if(name[free_object_array_number]) \
+ delete name[free_object_array_number]; \
+ \
+ hgl_free(name); \
+ name=nullptr; \
+ } \
}
- #define SAFE_RECREATE(name,code) { \
- if(name) \
- delete name; \
- \
- name=code; \
- }
+ #define SAFE_FREE_OBJECT_ARRAY(name,num) { \
+ if(name) \
+ FREE_OBJECT_ARRAY(name,num); \
+ }
- #define ARRAY_CALL(name,num,code) { \
- int array_call_number=num; \
- \
- while(array_call_number--) \
- name[array_call_number]->code; \
- }
+ #define SAFE_FREE(name) { \
+ if(name) \
+ hgl_free(name); \
+ }
- #define LOAD_FUNC(type,func) type func(void *buf,int buf_size) \
- { \
- if(!buf||buf_size<=0)return 0; \
- \
- MemoryInputStream ms(buf,buf_size); \
- \
- return(func(&ms)); \
- } \
- \
- type func(const UTF16String &filename) \
- { \
- FileInputStream fs; \
- \
- if(fs.Open(filename)) \
- return(func(&fs)); \
- else \
- return 0; \
- }
+ #define SAFE_RECREATE(name,code) { \
+ if(name) \
+ delete name; \
+ \
+ name=code; \
+ }
- #define SAVE_FUNC(type,func) bool func(type data,void *buf,int buf_size) \
- { \
- if(!buf||buf_size<=0)return(false); \
- \
- MemoryOutputStream ms(buf,buf_size); \
- \
- return(func(data,&ms)); \
- } \
- \
- bool func(type data,const UTF16String &filename) \
- { \
- FileOutputStream fs; \
- \
- if(fs.CreateTrunc(filename)) \
- return(func(data,&fs)); \
- else \
- return(false); \
- }
+ #define ARRAY_CALL(name,num,code) { \
+ int array_call_number=num; \
+ \
+ while(array_call_number--) \
+ name[array_call_number]->code; \
+ }
+
+ #define LOAD_FUNC(type,func) type func(void *buf,int buf_size) \
+ { \
+ if(!buf||buf_size<=0)return 0; \
+ \
+ MemoryInputStream ms(buf,buf_size); \
+ \
+ return(func(&ms)); \
+ } \
+ \
+ type func(const UTF16String &filename) \
+ { \
+ FileInputStream fs; \
+ \
+ if(fs.Open(filename)) \
+ return(func(&fs)); \
+ else \
+ return 0; \
+ }
+
+ #define SAVE_FUNC(type,func) bool func(type data,void *buf,int buf_size) \
+ { \
+ if(!buf||buf_size<=0)return(false); \
+ \
+ MemoryOutputStream ms(buf,buf_size); \
+ \
+ return(func(data,&ms)); \
+ } \
+ \
+ bool func(type data,const UTF16String &filename) \
+ { \
+ FileOutputStream fs; \
+ \
+ if(fs.CreateTrunc(filename)) \
+ return(func(data,&fs)); \
+ else \
+ return(false); \
+ }
}//namespace hgl
#endif//HGL_MACRO_INCLUDE
diff --git a/inc/hgl/Str.h b/inc/hgl/Str.h
index d5fea49c..952e8325 100644
--- a/inc/hgl/Str.h
+++ b/inc/hgl/Str.h
@@ -4,42 +4,42 @@
#include
namespace hgl
{
- // 32 空格
- // 33 !
- // 34 "
- // 35 #
- // 36 $
- // 37 %
- // 38 &
- // 39 '
- // 40 (
- // 41 )
- // 42 *
- // 43 +
- // 44 ,
- // 45 -
- // 46 .
- // 47 /
- // 48 0123456789
- // 58 :
- // 59 ;
- // 60 <
- // 61 =
- // 62 >
- // 63 ?
- // 64 @
- // 65 ABCDEFGHIJKLMNOPQRSTUVWXYZ
- // 91 [
- // 92 \
- // 93 ]
- // 94 ^
- // 95 _
- // 96 `
- // 97 abcdefghijklmnopqrstuvwxyz
- // 123 {
- // 124 |
- // 125 }
- // 126 ~
+ // 32 空格
+ // 33 !
+ // 34 "
+ // 35 #
+ // 36 $
+ // 37 %
+ // 38 &
+ // 39 '
+ // 40 (
+ // 41 )
+ // 42 *
+ // 43 +
+ // 44 ,
+ // 45 -
+ // 46 .
+ // 47 /
+ // 48 0123456789
+ // 58 :
+ // 59 ;
+ // 60 <
+ // 61 =
+ // 62 >
+ // 63 ?
+ // 64 @
+ // 65 ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ // 91 [
+ // 92 \
+ // 93 ]
+ // 94 ^
+ // 95 _
+ // 96 `
+ // 97 abcdefghijklmnopqrstuvwxyz
+ // 123 {
+ // 124 |
+ // 125 }
+ // 126 ~
/**
* 测试字符是否是emoji表情
@@ -497,7 +497,7 @@ namespace hgl
while(*dst&&max_count)
{
- ++dst; //找到结束
+ ++dst; //找到结束
--max_count;
}
@@ -1532,7 +1532,7 @@ namespace hgl
return(true);
}
- ++str; //跳过小数点
+ ++str; //跳过小数点
R pos=0.1f;
@@ -1594,7 +1594,7 @@ namespace hgl
return(true);
}
- ++str; //跳过小数点
+ ++str; //跳过小数点
--size;
R pos=0.1f;
@@ -1667,10 +1667,10 @@ namespace hgl
return(false);
}
- if(*str=='T'||*str=='t' //true/false
- ||*str=='Y'||*str=='y' //yes/no
- ||*str=='M'||*str=='m' //male/women
- ||*str=='1') //1/0
+ if(*str=='T'||*str=='t' //true/false
+ ||*str=='Y'||*str=='y' //yes/no
+ ||*str=='M'||*str=='m' //male/women
+ ||*str=='1') //1/0
{
value=true;
return(true);
@@ -1870,11 +1870,11 @@ namespace hgl
template
T *ftos(T *str,int size,int fsize,F value)
{
- const long integer=(long)value; //整数部分
+ const long integer=(long)value; //整数部分
T *p=str;
- if(integer==0&&value<0) //如果为-0.xx这种,integer会为0所以不增加-号
+ if(integer==0&&value<0) //如果为-0.xx这种,integer会为0所以不增加-号
*p++='-';
itos(p,size,integer);
@@ -1886,7 +1886,7 @@ namespace hgl
p=str+len;
- value-=integer; //保留小数部分
+ value-=integer; //保留小数部分
if(value<0)
value=-value;
@@ -1899,15 +1899,15 @@ namespace hgl
return(str);
}
- *p++='.'; //加小数点
+ *p++='.'; //加小数点
++len;
while(value>min_value&&len inline int parse_float_array(const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
- template inline int parse_int_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
- template inline int parse_uint_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
- template inline int parse_xint_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
+ template inline int parse_float_array(const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
+ template inline int parse_int_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
+ template inline int parse_uint_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
+ template inline int parse_xint_array (const T *str,I *result,int max_count,const T end_char=0,const T **end_pointer=0){return parse_number_array(str,result,max_count,end_char,end_pointer);}
/**
* 解析数值阵列字符串到数组,如"1,2,3"或"1 2 3"
@@ -2099,10 +2099,10 @@ namespace hgl
return(count);
}
- template inline int parse_float_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
- template inline int parse_int_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
- template inline int parse_uint_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
- template inline int parse_xint_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
+ template inline int parse_float_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
+ template inline int parse_int_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
+ template inline int parse_uint_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
+ template inline int parse_xint_array (const T *str,const int len,SET &result_list){return parse_number_array(str,len,result_list);}
/**
* 按指定分隔符拆分字符串为多个字符串
@@ -2183,12 +2183,12 @@ namespace hgl
{
if(!str)return(false);
- if((!isalpha(*str))&&(*str!='_')) //不是字母或下划线
+ if((!isalpha(*str))&&(*str!='_')) //不是字母或下划线
return(false);
++str;
- if(!(*str)) //不能仅一个字符
+ if(!(*str)) //不能仅一个字符
return(false);
while(*str)
diff --git a/inc/hgl/Time.h b/inc/hgl/Time.h
index a7983646..7b7655bf 100644
--- a/inc/hgl/Time.h
+++ b/inc/hgl/Time.h
@@ -5,19 +5,19 @@
namespace hgl //ʱ
{
- int GetTimeZone(); ///<ʱʱ(λ)
+ int GetTimeZone(); ///<ʱʱ(λ)
- uint64 GetMilliStartTime(); ///<ȡúʱ(λ1/1000)
- uint64 GetMicroStartTime(); ///<ȡʱ(λ1/1000000)
- double GetDoubleStartTime(); ///<ȡʱ(λ)
+ uint64 GetMilliStartTime(); ///<ȡúʱ(λ1/1000)
+ uint64 GetMicroStartTime(); ///<ȡʱ(λ1/1000000)
+ double GetDoubleStartTime(); ///<ȡʱ(λ)
- uint64 GetTime(); ///<ȡõǰʱ(λ1/1000)
- uint64 GetMicroTime(); ///<ȡõǰʱ(λ1/1000000)
- double GetDoubleTime(); ///<ȡõǰʱ(λ)
+ uint64 GetTime(); ///<ȡõǰʱ(λ1/1000)
+ uint64 GetMicroTime(); ///<ȡõǰʱ(λ1/1000000)
+ double GetDoubleTime(); ///<ȡõǰʱ(λ)
- double GetLocalDoubleTime(); ///<ȡñصǰʱ(λ)
+ double GetLocalDoubleTime(); ///<ȡñصǰʱ(λ)
- void WaitTime(double); ///<ȴһʱ(λ)
+ void WaitTime(double); ///<ȴһʱ(λ)
}//namespace hgl
#endif//HGL_TIME_INCLUDE
diff --git a/inc/hgl/TypeFunc.h b/inc/hgl/TypeFunc.h
index 27f61aa9..d925004b 100644
--- a/inc/hgl/TypeFunc.h
+++ b/inc/hgl/TypeFunc.h
@@ -5,11 +5,11 @@
#include
namespace hgl
{
- #define HGL_CONVER_TO_MEM_ALIGN(x) ((((x)+HGL_MEM_ALIGN-1)/HGL_MEM_ALIGN)*HGL_MEM_ALIGN) //内存对齐转换宏
+ #define HGL_CONVER_TO_MEM_ALIGN(x) ((((x)+HGL_MEM_ALIGN-1)/HGL_MEM_ALIGN)*HGL_MEM_ALIGN) //内存对齐转换宏
- #ifndef NULL
- #define NULL 0
- #endif//
+ #ifndef NULL
+ #define NULL 0
+ #endif//
template
inline T *zero_new(const int count)
@@ -41,144 +41,144 @@ namespace hgl
new (static_cast(obj)) T();
}
- #define HGL_BIT(n) (1<<(n))
- #define HGL_64BIT(n) (1L<<(n))
+ #define HGL_BIT(n) (1<<(n))
+ #define HGL_64BIT(n) (1L<<(n))
- template
- inline bool hgl_is_one(const T value,int off)
- {
- return value&(1<
+ inline bool hgl_is_one(const T value,int off)
+ {
+ return value&(1<
- inline bool hgl_is_zero(const T value,int off)
- {
- return !(value&(1<
+ inline bool hgl_is_zero(const T value,int off)
+ {
+ return !(value&(1<
- inline void hgl_set_one(T &value,int off)
- {
- value|=(1<
+ inline void hgl_set_one(T &value,int off)
+ {
+ value|=(1<
- inline void hgl_set_zero(T &value,int off)
- {
- value&=~T(1<
+ inline void hgl_set_zero(T &value,int off)
+ {
+ value&=~T(1<
- inline void hgl_set_bit(T &value,int off,bool b)
- {
- if(b)
- hgl_set_one(value,off);
- else
- hgl_set_zero(value,off);
- }
+ template
+ inline void hgl_set_bit(T &value,int off,bool b)
+ {
+ if(b)
+ hgl_set_one(value,off);
+ else
+ hgl_set_zero(value,off);
+ }
- template
- inline int hgl_bit_count(const T value)
- {
- int count=0;
- T bit=1;
+ template
+ inline int hgl_bit_count(const T value)
+ {
+ int count=0;
+ T bit=1;
- for(int i=0;i
- inline int hgl_bit_count(const T value,int size)
- {
- int count=0;
- T bit=1;
+ template
+ inline int hgl_bit_count(const T value,int size)
+ {
+ int count=0;
+ T bit=1;
- for(int i=0;i T HGL_INTEGER_MAX();
- template T HGL_INTEGER_MIN();
+ template T HGL_INTEGER_MAX();
+ template T HGL_INTEGER_MIN();
- template<> inline uint8 HGL_INTEGER_MAX() { return HGL_U8_MAX; }
- template<> inline uint16 HGL_INTEGER_MAX() { return HGL_U16_MAX; }
- template<> inline uint32 HGL_INTEGER_MAX() { return HGL_U32_MAX; }
- template<> inline uint64 HGL_INTEGER_MAX() { return HGL_U64_MAX; }
+ template<> inline uint8 HGL_INTEGER_MAX() { return HGL_U8_MAX; }
+ template<> inline uint16 HGL_INTEGER_MAX() { return HGL_U16_MAX; }
+ template<> inline uint32 HGL_INTEGER_MAX() { return HGL_U32_MAX; }
+ template<> inline uint64 HGL_INTEGER_MAX() { return HGL_U64_MAX; }
- template<> inline int8 HGL_INTEGER_MAX() { return HGL_S8_MAX; }
- template<> inline int16 HGL_INTEGER_MAX() { return HGL_S16_MAX; }
- template<> inline int32 HGL_INTEGER_MAX() { return HGL_S32_MAX; }
- template<> inline int64 HGL_INTEGER_MAX() { return HGL_S64_MAX; }
+ template<> inline int8 HGL_INTEGER_MAX() { return HGL_S8_MAX; }
+ template<> inline int16 HGL_INTEGER_MAX() { return HGL_S16_MAX; }
+ template<> inline int32 HGL_INTEGER_MAX() { return HGL_S32_MAX; }
+ template<> inline int64 HGL_INTEGER_MAX() { return HGL_S64_MAX; }
- template<> inline int8 HGL_INTEGER_MIN() { return HGL_S8_MIN; }
- template<> inline int16 HGL_INTEGER_MIN() { return HGL_S16_MIN; }
- template<> inline int32 HGL_INTEGER_MIN() { return HGL_S32_MIN; }
- template<> inline int64 HGL_INTEGER_MIN() { return HGL_S64_MIN; }
+ template<> inline int8 HGL_INTEGER_MIN() { return HGL_S8_MIN; }
+ template<> inline int16 HGL_INTEGER_MIN() { return HGL_S16_MIN; }
+ template<> inline int32 HGL_INTEGER_MIN() { return HGL_S32_MIN; }
+ template<> inline int64 HGL_INTEGER_MIN() { return HGL_S64_MIN; }
- /**
- * 星期每天枚举
- */
- enum WeekDay
- {
- weekNone=-1,
+ /**
+ * 星期每天枚举
+ */
+ enum WeekDay
+ {
+ weekNone=-1,
- weekSunday, ///<星期天
- weekMonday, ///<星期一
- weekTuesday, ///<星期二
- weekWednesday, ///<星期三
- weekThursday, ///<星期四
- weekFriday, ///<星期五
- weekSaturday, ///<星期六
+ weekSunday, ///<星期天
+ weekMonday, ///<星期一
+ weekTuesday, ///<星期二
+ weekWednesday, ///<星期三
+ weekThursday, ///<星期四
+ weekFriday, ///<星期五
+ weekSaturday, ///<星期六
- weekEnd
- };
+ weekEnd
+ };
/**
* 月份枚举
@@ -203,77 +203,77 @@ namespace hgl
monthEnd
};
- constexpr uint HGL_TIME_ONE_SECOND =1;
- constexpr uint HGL_TIME_HALF_MINUTE =30;
- constexpr uint HGL_TIME_ONE_MINUTE =60;
- constexpr uint HGL_TIME_HALF_HOUR =30*HGL_TIME_ONE_MINUTE;
- constexpr uint HGL_TIME_ONE_HOUR =60*HGL_TIME_ONE_MINUTE;
- constexpr uint HGL_TIME_HALF_DAY =12*HGL_TIME_ONE_HOUR;
- constexpr uint HGL_TIME_ONE_DAY =24*HGL_TIME_ONE_HOUR;
- constexpr uint HGL_TIME_ONE_WEEK =7*HGL_TIME_ONE_DAY;
- constexpr uint HGL_TIME_ONE_YEAR =365*HGL_TIME_ONE_DAY;
+ constexpr uint HGL_TIME_ONE_SECOND =1;
+ constexpr uint HGL_TIME_HALF_MINUTE =30;
+ constexpr uint HGL_TIME_ONE_MINUTE =60;
+ constexpr uint HGL_TIME_HALF_HOUR =30*HGL_TIME_ONE_MINUTE;
+ constexpr uint HGL_TIME_ONE_HOUR =60*HGL_TIME_ONE_MINUTE;
+ constexpr uint HGL_TIME_HALF_DAY =12*HGL_TIME_ONE_HOUR;
+ constexpr uint HGL_TIME_ONE_DAY =24*HGL_TIME_ONE_HOUR;
+ constexpr uint HGL_TIME_ONE_WEEK =7*HGL_TIME_ONE_DAY;
+ constexpr uint HGL_TIME_ONE_YEAR =365*HGL_TIME_ONE_DAY;
- constexpr uint HGL_HOUR_HALF_DAY =12;
- constexpr uint HGL_HOUR_ONE_DAY =24;
+ constexpr uint HGL_HOUR_HALF_DAY =12;
+ constexpr uint HGL_HOUR_ONE_DAY =24;
- constexpr uint HGL_DAY_ONE_WEEK =7;
- constexpr uint HGL_DAY_ONE_YEAR =365;
+ constexpr uint HGL_DAY_ONE_WEEK =7;
+ constexpr uint HGL_DAY_ONE_YEAR =365;
- constexpr uint HGL_MONTH_ONE_YEAR =12;
+ constexpr uint HGL_MONTH_ONE_YEAR =12;
- constexpr uint HGL_MILLI_SEC_PRE_SEC =1000; //毫秒
- constexpr uint HGL_MICRO_SEC_PER_SEC =1000*1000; //微秒
- constexpr uint HGL_NANO_SEC_PER_SEC =1000*1000*1000; //纳秒
+ constexpr uint HGL_MILLI_SEC_PRE_SEC =1000; //毫秒
+ constexpr uint HGL_MICRO_SEC_PER_SEC =1000*1000; //微秒
+ constexpr uint HGL_NANO_SEC_PER_SEC =1000*1000*1000; //纳秒
- constexpr char LowerHexChar[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; ///<小写16进制字符
- constexpr char UpperHexChar[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; ///<大写16进制字符
+ constexpr char LowerHexChar[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; ///<小写16进制字符
+ constexpr char UpperHexChar[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; ///<大写16进制字符
- constexpr double HGL_E =2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274; //欧拉数(自然对数的底数)
- constexpr double HGL_LOG2E =1.44269504088896340736;
- constexpr double HGL_LOG10E =0.434294481903251827651;
- constexpr double HGL_LN2 =0.693147180559945309417;
- constexpr double HGL_LN10 =2.30258509299404568402;
- constexpr double HGL_PI =3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
- constexpr double HGL_PI_2 =1.57079632679489661923;
- constexpr double HGL_PI_4 =0.785398163397448309616;
- constexpr double HGL_PI_3_4 =2.356194490192344928938;
- constexpr double HGL_1_PI =0.318309886183790671538;
- constexpr double HGL_2_PI =0.636619772367581343076;
- constexpr double HGL_2_SQRTPI =1.12837916709551257390;
- constexpr double HGL_SQRT2 =1.41421356237309504880168872420969807;
- constexpr double HGL_SQRT1_2 =0.707106781186547524401;
+ constexpr double HGL_E =2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274; //欧拉数(自然对数的底数)
+ constexpr double HGL_LOG2E =1.44269504088896340736;
+ constexpr double HGL_LOG10E =0.434294481903251827651;
+ constexpr double HGL_LN2 =0.693147180559945309417;
+ constexpr double HGL_LN10 =2.30258509299404568402;
+ constexpr double HGL_PI =3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
+ constexpr double HGL_PI_2 =1.57079632679489661923;
+ constexpr double HGL_PI_4 =0.785398163397448309616;
+ constexpr double HGL_PI_3_4 =2.356194490192344928938;
+ constexpr double HGL_1_PI =0.318309886183790671538;
+ constexpr double HGL_2_PI =0.636619772367581343076;
+ constexpr double HGL_2_SQRTPI =1.12837916709551257390;
+ constexpr double HGL_SQRT2 =1.41421356237309504880168872420969807;
+ constexpr double HGL_SQRT1_2 =0.707106781186547524401;
- constexpr double HGL_COS_ANG_0 =1;
- constexpr double HGL_COS_ANG_45 =0.707106781187;
- constexpr double HGL_COS_ANG_90 =0;
- constexpr double HGL_COS_ANG_135=-0.707106781187;
- constexpr double HGL_COS_ANG_180=-1;
- constexpr double HGL_COS_ANG_225=-0.707106781187;
- constexpr double HGL_COS_ANG_270=0;
- constexpr double HGL_COS_ANG_315=0.707106781187;
+ constexpr double HGL_COS_ANG_0 =1;
+ constexpr double HGL_COS_ANG_45 =0.707106781187;
+ constexpr double HGL_COS_ANG_90 =0;
+ constexpr double HGL_COS_ANG_135=-0.707106781187;
+ constexpr double HGL_COS_ANG_180=-1;
+ constexpr double HGL_COS_ANG_225=-0.707106781187;
+ constexpr double HGL_COS_ANG_270=0;
+ constexpr double HGL_COS_ANG_315=0.707106781187;
- constexpr double HGL_GOLDEN_RATIO =0.61803398874989484820458683436563811772030917980576;//黄金比例
- constexpr double HGL_SILVER_RATIO =2.4142135623730950488; //白银比例
+ constexpr double HGL_GOLDEN_RATIO =0.61803398874989484820458683436563811772030917980576;//黄金比例
+ constexpr double HGL_SILVER_RATIO =2.4142135623730950488; //白银比例
constexpr double HGL_SPEED_OF_SOUND =331.3f; //音速(米/秒)
- constexpr double HGL_SPEED_OF_LIGHT =299792458; //光速(米/秒)
+ constexpr double HGL_SPEED_OF_LIGHT =299792458; //光速(米/秒)
constexpr double HGL_ABSOLUTE_ZERO =-273.15f; //绝对零度
- constexpr double HGL_UNIVERSAL_GRAVITATION =6.67384e-11; //万有引力常数
+ constexpr double HGL_UNIVERSAL_GRAVITATION =6.67384e-11; //万有引力常数
- constexpr double HGL_EARTH_GRAVITATIONAL_ACCELERATION =9.80665; //地球上的重力加速度(牛顿)
- constexpr double HGL_EARTH_MASS =5.9722e+24; //地球质量
- constexpr double HGL_EARTH_RADIUS =6371000; //地球半径(米)
+ constexpr double HGL_EARTH_GRAVITATIONAL_ACCELERATION =9.80665; //地球上的重力加速度(牛顿)
+ constexpr double HGL_EARTH_MASS =5.9722e+24; //地球质量
+ constexpr double HGL_EARTH_RADIUS =6371000; //地球半径(米)
- /**
+ /**
* 物体万有引力计算
* @param m1 星球质量
* @param m2 物体质量
* @param length 到星球中心的距离
*/
- template
- inline T UniversalGravitation(const T m1,const T m2,const T length)
+ template
+ inline T UniversalGravitation(const T m1,const T m2,const T length)
{
return HGL_UNIVERSAL_GRAVITATION*((m1*m2)/(length*length));
}
@@ -325,211 +325,211 @@ namespace hgl
return m0/sqrt(1-(v*v)/(HGL_SPEED_OF_LIGHT*HGL_SPEED_OF_LIGHT));
}
- inline float half_to_float(const uint16 &h)
- {
- return ((h&0x8000)<<16) | (((h&0x7c00)+0x1C000)<<13) | ((h&0x03FF)<<13);
- }
+ inline float half_to_float(const uint16 &h)
+ {
+ return ((h&0x8000)<<16) | (((h&0x7c00)+0x1C000)<<13) | ((h&0x03FF)<<13);
+ }
- inline uint16 float_to_half(const float &f)
- {
- const uint32 x = *((uint32 *)&f);
+ inline uint16 float_to_half(const float &f)
+ {
+ const uint32 x = *((uint32 *)&f);
- return ((x>>16)&0x8000)|((((x&0x7f800000)-0x38000000)>>13)&0x7c00)|((x>>13)&0x03ff);
- }
+ return ((x>>16)&0x8000)|((((x&0x7f800000)-0x38000000)>>13)&0x7c00)|((x>>13)&0x03ff);
+ }
- /**
- * 正圆面积计算
- * @param radius 半径
- */
- inline double CircleArea(const double radius)
- {
- return(radius*radius*HGL_PI);
- }
+ /**
+ * 正圆面积计算
+ * @param radius 半径
+ */
+ inline double CircleArea(const double radius)
+ {
+ return(radius*radius*HGL_PI);
+ }
- /**
- * 椭圆面积计算
- * @param l_radius 长半径
- * @param s_radius 短半径
- */
- inline double ElipseArea(const double l_radius,const double s_radius)
- {
- return(l_radius*s_radius*HGL_PI);
- }
+ /**
+ * 椭圆面积计算
+ * @param l_radius 长半径
+ * @param s_radius 短半径
+ */
+ inline double ElipseArea(const double l_radius,const double s_radius)
+ {
+ return(l_radius*s_radius*HGL_PI);
+ }
- /**
- * 球体积计算
- * @param radius 球半径
- */
- inline double SphereVolume(const double radius)
- {
- return(radius*radius*radius*(HGL_PI*4.0f))/3.0f;
- }
+ /**
+ * 球体积计算
+ * @param radius 球半径
+ */
+ inline double SphereVolume(const double radius)
+ {
+ return(radius*radius*radius*(HGL_PI*4.0f))/3.0f;
+ }
- /**
- * 椭球体积计算
- * @param x_radius x半径
- * @param y_radius y半径
- * @param z_radius z半径
- */
- inline double EllipsoidVolume(const double x_radius,const double y_radius,const double z_radius)
- {
- return(x_radius*y_radius*z_radius*(HGL_PI*4.0f))/3.0f;
- }
+ /**
+ * 椭球体积计算
+ * @param x_radius x半径
+ * @param y_radius y半径
+ * @param z_radius z半径
+ */
+ inline double EllipsoidVolume(const double x_radius,const double y_radius,const double z_radius)
+ {
+ return(x_radius*y_radius*z_radius*(HGL_PI*4.0f))/3.0f;
+ }
- /**
- * 取适合正巧大于当前数的2次幂值
- */
- template
- inline T power_to_2(T value)
- {
- T result=1;
+ /**
+ * 取适合正巧大于当前数的2次幂值
+ */
+ template
+ inline T power_to_2(T value)
+ {
+ T result=1;
- while(result inline void hgl_swap(T &x,T &y)
- {
- T t;
+ template inline void hgl_swap(T &x,T &y)
+ {
+ T t;
- memcpy(&t,&x,sizeof(T));
- memcpy(&x,&y,sizeof(T));
- memcpy(&y,&t,sizeof(T));
- }
+ memcpy(&t,&x,sizeof(T));
+ memcpy(&x,&y,sizeof(T));
+ memcpy(&y,&t,sizeof(T));
+ }
- template inline T hgl_abs(const T &v){return (v>=0?v:-v);}
+ template inline T hgl_abs(const T &v){return (v>=0?v:-v);}
- template inline T hgl_min(const T &a,const T &b){return (a>b?b:a);}
- template inline T hgl_max(const T &a,const T &b){return (a>b?a:b);}
+ template inline T hgl_min(const T &a,const T &b){return (a>b?b:a);}
+ template inline T hgl_max(const T &a,const T &b){return (a>b?a:b);}
- template inline T hgl_min(const T *data,int count,T min_value)
- {
- T value=min_value;
+ template inline T hgl_min(const T *data,int count,T min_value)
+ {
+ T value=min_value;
- for(int i=0;i inline T hgl_max(const T *data,int count,T max_value)
- {
- T value=max_value;
+ template inline T hgl_max(const T *data,int count,T max_value)
+ {
+ T value=max_value;
- for(int i=0;ivalue)
- value=*data;
+ for(int i=0;ivalue)
+ value=*data;
- ++data;
- }
+ ++data;
+ }
- return(value);
- }
+ return(value);
+ }
- /**
- * 角度转弧度
- */
- inline double hgl_ang2rad(const double ang)
- {
- return ang*(HGL_PI/180.0f);
- }
+ /**
+ * 角度转弧度
+ */
+ inline double hgl_ang2rad(const double ang)
+ {
+ return ang*(HGL_PI/180.0f);
+ }
- /**
- * 弧度转角度
- */
- inline double hgl_rad2ang(const double rad)
- {
- return rad*(180.0f/HGL_PI);
- }
+ /**
+ * 弧度转角度
+ */
+ inline double hgl_rad2ang(const double rad)
+ {
+ return rad*(180.0f/HGL_PI);
+ }
- /**
+ /**
* 浮点数截取小数点后指定位度
* @param value 要截取的浮点数
* @param num 要截取的位数
*/
- template
- inline T hgl_clip_float(const T value,const int num)
- {
- if(num<=0)
- return int64(value);
+ template
+ inline T hgl_clip_float(const T value,const int num)
+ {
+ if(num<=0)
+ return int64(value);
- if(value==0)return(0);
+ if(value==0)return(0);
- double per=pow(10,num);
+ double per=pow(10,num);
- return double(floor(value*per))/per;
- }
+ return double(floor(value*per))/per;
+ }
- /**
+ /**
* 等值类型复制
*/
- template
- inline void hgl_cpy(T &dst,const T &src)
- {
- memcpy(&dst,&src,sizeof(T));
- }
+ template
+ inline void hgl_cpy(T &dst,const T &src)
+ {
+ memcpy(&dst,&src,sizeof(T));
+ }
- /**
+ /**
* 不同类型数据块复制
*/
- template
- inline void hgl_cpy(D *dst,const S *src,const size_t count)
- {
- for(size_t i=0;i
+ inline void hgl_cpy(D *dst,const S *src,const size_t count)
+ {
+ for(size_t i=0;i
- inline void hgl_typecpy(T *dst,const T *src,const size_t count)
- {
- memcpy(dst,src,count*sizeof(T));
- }
+ template
+ inline void hgl_typecpy(T *dst,const T *src,const size_t count)
+ {
+ memcpy(dst,src,count*sizeof(T));
+ }
- /**
+ /**
* 同类型数据块移动
*/
- template
- inline void hgl_typemove(T *dst,const T *src,const size_t count)
- {
- memmove(dst,src,count*sizeof(T));
- }
+ template
+ inline void hgl_typemove(T *dst,const T *src,const size_t count)
+ {
+ memmove(dst,src,count*sizeof(T));
+ }
- /**
+ /**
* 指定类型数据块赋值
*/
- template
- inline void hgl_set(T *data,const T value,const size_t count)
- {
- for(size_t i=0;i
+ inline void hgl_set(T *data,const T value,const size_t count)
+ {
+ for(size_t i=0;i
- inline void hgl_zero(T *data,const size_t count)
- {
- memset(data,0,count*sizeof(T));
- }
+ template
+ inline void hgl_zero(T *data,const size_t count)
+ {
+ memset(data,0,count*sizeof(T));
+ }
/**
* 分配指定类型数据块并清0
@@ -554,81 +554,81 @@ namespace hgl
return data;
}
- /**
+ /**
* 指定类型数据清0
*/
- template
- inline void hgl_zero(T &data)
- {
- memset(&data,0,sizeof(T));
- }
+ template
+ inline void hgl_zero(T &data)
+ {
+ memset(&data,0,sizeof(T));
+ }
}//namespace hgl
/**
* 比较处理模板基类
*/
-template class Comparator ///比较处理模板基类
+template class Comparator ///比较处理模板基类
{
public:
- /**
- * 比较函数,需被特例化或派生实现
- */
- virtual int compare(const T &a,const T &b)const
- {
- return 0; // 如 return(a-b); ,但这个函数正确情况下不应该会被调用
- }
+ /**
+ * 比较函数,需被特例化或派生实现
+ */
+ virtual int compare(const T &a,const T &b)const
+ {
+ return 0; // 如 return(a-b); ,但这个函数正确情况下不应该会被调用
+ }
- /**
- * 交换函数
- */
- virtual void exchange(T &a,T &b)
- {
- T t;
+ /**
+ * 交换函数
+ */
+ virtual void exchange(T &a,T &b)
+ {
+ T t;
- memcpy(&t,&a,sizeof(T));
- memcpy(&a,&b,sizeof(T));
- memcpy(&b,&t,sizeof(T));
- }
+ memcpy(&t,&a,sizeof(T));
+ memcpy(&a,&b,sizeof(T));
+ memcpy(&b,&t,sizeof(T));
+ }
- /**
- * 复制数据
- */
- virtual void cpy(T *t,T *s)
- {
- memcpy(t,s,sizeof(T));
- }
+ /**
+ * 复制数据
+ */
+ virtual void cpy(T *t,T *s)
+ {
+ memcpy(t,s,sizeof(T));
+ }
};//class Comparator
//针对原生类型的特例化版本,做适当加速
-#define COMPARATOR_ORIGIN_TYPE(type) template<> class Comparator \
- { \
- public: \
- int compare(const type &a,const type &b)const{return a-b;} \
- void exchange(type &a,type &b){type t;t=a;a=b;b=t;} \
- void cpy(type *t,type *s){*t=*s;} \
- };
+#define COMPARATOR_ORIGIN_TYPE(type) template<> class Comparator \
+ { \
+ public: \
+ int compare(const type &a,const type &b)const{return a-b;} \
+ void exchange(type &a,type &b){type t;t=a;a=b;b=t;} \
+ void cpy(type *t,type *s){*t=*s;} \
+ };
- COMPARATOR_ORIGIN_TYPE(hgl::int8)
- COMPARATOR_ORIGIN_TYPE(hgl::int16)
- COMPARATOR_ORIGIN_TYPE(hgl::int32)
- COMPARATOR_ORIGIN_TYPE(hgl::int64)
+ COMPARATOR_ORIGIN_TYPE(hgl::int8)
+ COMPARATOR_ORIGIN_TYPE(hgl::int16)
+ COMPARATOR_ORIGIN_TYPE(hgl::int32)
+ COMPARATOR_ORIGIN_TYPE(hgl::int64)
- COMPARATOR_ORIGIN_TYPE(hgl::uint8)
- COMPARATOR_ORIGIN_TYPE(hgl::uint16)
- COMPARATOR_ORIGIN_TYPE(hgl::uint32)
- COMPARATOR_ORIGIN_TYPE(hgl::uint64)
+ COMPARATOR_ORIGIN_TYPE(hgl::uint8)
+ COMPARATOR_ORIGIN_TYPE(hgl::uint16)
+ COMPARATOR_ORIGIN_TYPE(hgl::uint32)
+ COMPARATOR_ORIGIN_TYPE(hgl::uint64)
- COMPARATOR_ORIGIN_TYPE(float)
- COMPARATOR_ORIGIN_TYPE(double)
+ COMPARATOR_ORIGIN_TYPE(float)
+ COMPARATOR_ORIGIN_TYPE(double)
- COMPARATOR_ORIGIN_TYPE(char)
- COMPARATOR_ORIGIN_TYPE(wchar_t)
+ COMPARATOR_ORIGIN_TYPE(char)
+ COMPARATOR_ORIGIN_TYPE(wchar_t)
#if HGL_OS != HGL_OS_Windows
- COMPARATOR_ORIGIN_TYPE(u16char)
+ COMPARATOR_ORIGIN_TYPE(u16char)
#endif//HGL_OS != HGL_OS_Windows
- COMPARATOR_ORIGIN_TYPE(char32_t)
+ COMPARATOR_ORIGIN_TYPE(char32_t)
#undef COMPARATOR_ORIGIN_TYPE
#endif//HGL_TYPE_FUNC_INCLUDE
diff --git a/inc/hgl/endian/Endian.h b/inc/hgl/endian/Endian.h
index b65e9ae4..77574fef 100644
--- a/inc/hgl/endian/Endian.h
+++ b/inc/hgl/endian/Endian.h
@@ -1,67 +1,67 @@
#ifndef HGL_ENDIAN_INCLUDE
#define HGL_ENDIAN_INCLUDE
-#include // 平台定义
+#include // 平台定义
namespace hgl
{
- namespace endian
- {
- /**
- * Windows代码页枚举
- * 全部Windows所支持代码页请参见 http://msdn.microsoft.com/en-us/library/dd317756
- */
- enum CharCodePage ///代码页枚举
- {
- ccpNone=0, ///<起始定义,无意义
+ namespace endian
+ {
+ /**
+ * Windows代码页枚举
+ * 全部Windows所支持代码页请参见 http://msdn.microsoft.com/en-us/library/dd317756
+ */
+ enum CharCodePage ///代码页枚举
+ {
+ ccpNone=0, ///<起始定义,无意义
- //中文
- ccpGBK =936, ///<中国GBK标准中文
- ccpBig5 =950, ///<中国台湾Big5标准繁体中文
- ccpGB2312 =20936, ///<中国GB2312标准简体中文
- ccpGB18030 =54936, ///<中国GB18030-2000标准中文
+ //中文
+ ccpGBK =936, ///<中国GBK标准中文
+ ccpBig5 =950, ///<中国台湾Big5标准繁体中文
+ ccpGB2312 =20936, ///<中国GB2312标准简体中文
+ ccpGB18030 =54936, ///<中国GB18030-2000标准中文
- //日文
- ccpShiftJIS =932, ///<日文ShiftJIS
- ccpJISX =50222, ///<日文JIS X/ISO 2022
+ //日文
+ ccpShiftJIS =932, ///<日文ShiftJIS
+ ccpJISX =50222, ///<日文JIS X/ISO 2022
- //韩文
- ccpKorean =949, ///<韩文
+ //韩文
+ ccpKorean =949, ///<韩文
- //苹果编码
- ccpMacJanpan =10001, ///<日文
- ccpMacTraditionalChinese =10002, ///<繁体中文
- ccpMacSimplifiedChinese =10008, ///<简体中文
+ //苹果编码
+ ccpMacJanpan =10001, ///<日文
+ ccpMacTraditionalChinese =10002, ///<繁体中文
+ ccpMacSimplifiedChinese =10008, ///<简体中文
- //unicode
- ccpUTF7 =65000, /// const CharSetName &GetCurCharSet(); ///<取得当前程序编码字符集
+ template const CharSetName &GetCurCharSet(); ///<取得当前程序编码字符集
constexpr CharSetName utf8_charset="utf8";
constexpr CharSetName utf16le_charset="utf-16le";
@@ -69,61 +69,61 @@ namespace hgl
constexpr CharSetName utf32le_charset="utf-32le";
constexpr CharSetName utf32be_charset="utf-32be";
- template<> inline const CharSetName &GetCurCharSet<2,HGL_LITTLE_ENDIAN >(){return utf16le_charset;}
- template<> inline const CharSetName &GetCurCharSet<2,HGL_BIG_ENDIAN >(){return utf16be_charset;}
- template<> inline const CharSetName &GetCurCharSet<4,HGL_LITTLE_ENDIAN >(){return utf32le_charset;}
- template<> inline const CharSetName &GetCurCharSet<4,HGL_BIG_ENDIAN >(){return utf32be_charset;}
+ template<> inline const CharSetName &GetCurCharSet<2,HGL_LITTLE_ENDIAN >(){return utf16le_charset;}
+ template<> inline const CharSetName &GetCurCharSet<2,HGL_BIG_ENDIAN >(){return utf16be_charset;}
+ template<> inline const CharSetName &GetCurCharSet<4,HGL_LITTLE_ENDIAN >(){return utf32le_charset;}
+ template<> inline const CharSetName &GetCurCharSet<4,HGL_BIG_ENDIAN >(){return utf32be_charset;}
- template inline const CharSetName &GetCharSet()
- {
- return GetCurCharSet();
- }
+ template inline const CharSetName &GetCharSet()
+ {
+ return GetCurCharSet();
+ }
- /**
- * 字节序文件头数据结构
- */
- struct BOMFileHeader
- {
- int size; ///<字节序文件头长度
- unsigned char data[4]; ///<字节序数据
+ /**
+ * 字节序文件头数据结构
+ */
+ struct BOMFileHeader
+ {
+ int size; ///<字节序文件头长度
+ unsigned char data[4]; ///<字节序数据
ByteOrderMask bom; ///<字节序枚举
const CharSetName *char_set;///<字符集名称
CharCodePage code_page; ///<代码页
- };
+ };
- /**
- * 字节序文件头定义
- */
- constexpr BOMFileHeader BOMData[bomEnd]=
- {
- {0,{} ,bomNone, nullptr ,ccpNone },
- {3,{0xEF,0xBB,0xBF} ,bomUTF8, &utf8_charset ,ccpUTF8 },
- {2,{0xFF,0xFE} ,bomUTF16LE,&utf16le_charset ,ccpUTF16LE },
- {2,{0xFE,0xFF} ,bomUTF16BE,&utf16be_charset ,ccpUTF16BE },
- {4,{0xFF,0xFE,0x00,0x00},bomUTF32LE,&utf32le_charset ,ccpUTF32LE },
- {4,{0x00,0x00,0xFE,0xFF},bomUTF32BE,&utf32be_charset ,ccpUTF32BE }
- };
+ /**
+ * 字节序文件头定义
+ */
+ constexpr BOMFileHeader BOMData[bomEnd]=
+ {
+ {0,{} ,bomNone, nullptr ,ccpNone },
+ {3,{0xEF,0xBB,0xBF} ,bomUTF8, &utf8_charset ,ccpUTF8 },
+ {2,{0xFF,0xFE} ,bomUTF16LE,&utf16le_charset ,ccpUTF16LE },
+ {2,{0xFE,0xFF} ,bomUTF16BE,&utf16be_charset ,ccpUTF16BE },
+ {4,{0xFF,0xFE,0x00,0x00},bomUTF32LE,&utf32le_charset ,ccpUTF32LE },
+ {4,{0x00,0x00,0xFE,0xFF},bomUTF32BE,&utf32be_charset ,ccpUTF32BE }
+ };
- template
- inline T EndianSwap(const T value)
- {
- union
- {
- T v;
- uint8 bytes[sizeof(T)];
- }a,b;
+ template
+ inline T EndianSwap(const T value)
+ {
+ union
+ {
+ T v;
+ uint8 bytes[sizeof(T)];
+ }a,b;
- a.v=value;
+ a.v=value;
- for(uint i=0;i inline int8 EndianSwap< int8>(const int8 value){return value;}
- template<> inline uint8 EndianSwap(const uint8 value){return value;}
+ template<> inline int8 EndianSwap< int8>(const int8 value){return value;}
+ template<> inline uint8 EndianSwap(const uint8 value){return value;}
template<> inline uint16 EndianSwap(const uint16 value)
{
@@ -153,123 +153,123 @@ namespace hgl
template<> inline u16char EndianSwap(const u16char value){return EndianSwap(uint16(value));}
- template
- inline void EndianSwap(T *value,const int64 count)
- {
- for(int64 i=0;i
+ inline void EndianSwap(T *value,const int64 count)
+ {
+ for(int64 i=0;i
- inline void EndianSwap(T *dst,const T *src,const int64 count)
- {
- for(uint i=0;i
+ inline void EndianSwap(T *dst,const T *src,const int64 count)
+ {
+ for(uint i=0;i
- inline void EndianSwap(D *dst,const S *src,const int64 count)
- {
- for(uint i=0;i
+ inline void EndianSwap(D *dst,const S *src,const int64 count)
+ {
+ for(uint i=0;i T ToBigEndian(T value){return value;}
-
- template inline void ToBigEndian(T *value,const int64 count){}
- template inline void ToBigEndian(D *dst,const S *src,const int64 count){hgl_cpy(dst,src,count);}
-
- template T ToLittleEndian(T value){return EndianSwap(value);}
-
- template inline void ToLittleEndian(T *value,const int64 count){EndianSwap(value,count);}
- template inline void ToLittleEndian(D *dst,const S *src,const int64 count){EndianSwap(dst,src,count);}
-
- #else
-
- constexpr uint HGL_BOM_UTF16LE =0xfeff;
- constexpr uint HGL_BOM_UTF16BE =0xfffe;
- constexpr uint HGL_BOM_UTF32LE =0x0000feff;
- constexpr uint HGL_BOM_UTF32BE =0xfffe0000;
-
- #define LittleToCurrentEndian ToLittleEndian
- #define BigToCurrentEndian EndianSwap
-
- template T ToBigEndian(T value){return EndianSwap(value);}
-
- template inline void ToBigEndian(T *value,const int64 count){EndianSwap(value,count);}
- template inline void ToBigEndian(D *dst,const S *src,const int64 count){EndianSwap(dst,src,count);}
-
- template T ToLittleEndian(T value){return value;}
-
- template inline void ToLittleEndian(T *,const int64){}
- template inline void ToLittleEndian(D *dst,const S *src,const int64 count){hgl_cpy(dst,src,count);}
-
- #endif//HGL_BIG_ENDIAN
-
- template struct UTF16CharConvert;
-
- template<> struct UTF16CharConvert
- {
#if HGL_ENDIAN == HGL_BIG_ENDIAN
- static void convert(u16char *str,const int length)
- {
- EndianSwap(str,length);
- }
+
+ constexpr uint HGL_BOM_UTF16LE =0xfffe;
+ constexpr uint HGL_BOM_UTF16BE =0xfeff;
+ constexpr uint HGL_BOM_UTF32LE =0xfffe0000;
+ constexpr uint HGL_BOM_UTF32BE =0x0000feff;
+
+ #define LittleToCurrentEndian EndianSwap
+ #define BigToCurrentEndian ToBigEndian
+
+ template T ToBigEndian(T value){return value;}
+
+ template inline void ToBigEndian(T *value,const int64 count){}
+ template inline void ToBigEndian(D *dst,const S *src,const int64 count){hgl_cpy(dst,src,count);}
+
+ template T ToLittleEndian(T value){return EndianSwap(value);}
+
+ template inline void ToLittleEndian(T *value,const int64 count){EndianSwap(value,count);}
+ template inline void ToLittleEndian(D *dst,const S *src,const int64 count){EndianSwap(dst,src,count);}
+
+ #else
+
+ constexpr uint HGL_BOM_UTF16LE =0xfeff;
+ constexpr uint HGL_BOM_UTF16BE =0xfffe;
+ constexpr uint HGL_BOM_UTF32LE =0x0000feff;
+ constexpr uint HGL_BOM_UTF32BE =0xfffe0000;
+
+ #define LittleToCurrentEndian ToLittleEndian
+ #define BigToCurrentEndian EndianSwap
+
+ template T ToBigEndian(T value){return EndianSwap(value);}
+
+ template inline void ToBigEndian(T *value,const int64 count){EndianSwap(value,count);}
+ template inline void ToBigEndian(D *dst,const S *src,const int64 count){EndianSwap(dst,src,count);}
+
+ template T ToLittleEndian(T value){return value;}
+
+ template inline void ToLittleEndian(T *,const int64){}
+ template inline void ToLittleEndian(D *dst,const S *src,const int64 count){hgl_cpy(dst,src,count);}
+
+ #endif//HGL_BIG_ENDIAN
+
+ template struct UTF16CharConvert;
+
+ template<> struct UTF16CharConvert
+ {
+ #if HGL_ENDIAN == HGL_BIG_ENDIAN
+ static void convert(u16char *str,const int length)
+ {
+ EndianSwap(str,length);
+ }
#else
static void convert(const u16char *,const int){}
- #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- static void convert(u16char *out_str,const u16char *in_str,const int length)
- {
- #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
- memcpy(out_str,in_str,length*sizeof(u16char));
- #else
- EndianSwap(in_str,length);
- #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- }
- };//template<> struct UTF16CharConvert
+ static void convert(u16char *out_str,const u16char *in_str,const int length)
+ {
+ #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ memcpy(out_str,in_str,length*sizeof(u16char));
+ #else
+ EndianSwap(in_str,length);
+ #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ }
+ };//template<> struct UTF16CharConvert
- template<> struct UTF16CharConvert
- {
- static void convert(u16char *str,const int length)
- {
- #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
- EndianSwap(str,length);
- #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- }
+ template<> struct UTF16CharConvert
+ {
+ static void convert(u16char *str,const int length)
+ {
+ #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ EndianSwap(str,length);
+ #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ }
- static void convert(u16char *out_str,const u16char *in_str,const int length)
- {
- #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
- memcpy(out_str,in_str,length*sizeof(u16char));
- #else
- EndianSwap(in_str,length);
- #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- }
- };//template<> struct UTF16ToWideChar
- }//namespace endian
+ static void convert(u16char *out_str,const u16char *in_str,const int length)
+ {
+ #if HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ memcpy(out_str,in_str,length*sizeof(u16char));
+ #else
+ EndianSwap(in_str,length);
+ #endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
+ }
+ };//template<> struct UTF16ToWideChar
+ }//namespace endian
- using namespace endian;
+ using namespace endian;
}//namespace hgl
#endif//HGL_ENDIAN_INCLUDE
diff --git a/inc/hgl/filesystem/EnumVolume.h b/inc/hgl/filesystem/EnumVolume.h
index 5cfd4c3b..47e7a105 100644
--- a/inc/hgl/filesystem/EnumVolume.h
+++ b/inc/hgl/filesystem/EnumVolume.h
@@ -13,36 +13,36 @@ namespace hgl
{
enum DriverType
{
- dtNone=0, ///<未知类型
+ dtNone=0, ///<未知类型
- dtRemovable, ///<可移动设备
- dtFixed, ///<固定设备
- dtRemote, ///<远程设备
- dtCDROM, ///<光盘驱动器
- dtRamDisk, ///<内存虚拟设备
+ dtRemovable, ///<可移动设备
+ dtFixed, ///<固定设备
+ dtRemote, ///<远程设备
+ dtCDROM, ///<光盘驱动器
+ dtRamDisk, ///<内存虚拟设备
- dtEnd ///<结束定义
+ dtEnd ///<结束定义
};
- u16char name[HGL_MAX_PATH]; ///<卷名称
+ u16char name[HGL_MAX_PATH]; ///<卷名称
- u16char path[HGL_MAX_PATH]; ///<卷所对应的路径名(注意:不是所有卷都有对应路径)
+ u16char path[HGL_MAX_PATH]; ///<卷所对应的路径名(注意:不是所有卷都有对应路径)
- DriverType driver_type; ///<驱动器类型(注意:不是所有的卷都对应驱动器)
+ DriverType driver_type; ///<驱动器类型(注意:不是所有的卷都对应驱动器)
- uint32 serial; ///<卷序列号
+ uint32 serial; ///<卷序列号
- u16char volume_label[HGL_MAX_PATH]; ///<卷标名称
+ u16char volume_label[HGL_MAX_PATH]; ///<卷标名称
- u16char file_system[HGL_MAX_PATH]; ///<文件系统名称
+ u16char file_system[HGL_MAX_PATH]; ///<文件系统名称
- uint32 filename_max_length; ///<文件名最大长度
+ uint32 filename_max_length; ///<文件名最大长度
- bool unicode; ///<文件名支持UNICODE
+ bool unicode; ///<文件名支持UNICODE
- uint64 available_space; ///<有效容量
- uint64 total_space; ///<总空量
- uint64 free_space; ///<自由容量
+ uint64 available_space; ///<有效容量
+ uint64 total_space; ///<总空量
+ uint64 free_space; ///<自由容量
};//struct VolumeInfo
#if HGL_OS == HGL_OS_Windows
@@ -52,7 +52,7 @@ namespace hgl
*/
struct VolumeCheckConfig
{
- bool removable =false;
+ bool removable =false;
bool fixed =false;
bool remote =false;
bool cdrom =false;
@@ -64,7 +64,7 @@ namespace hgl
/**
* 设置为全部检测
*/
- void SetFullCheck()
+ void SetFullCheck()
{
memset(this,0xff,sizeof(VolumeCheckConfig));
}
diff --git a/inc/hgl/filesystem/FileSystem.h b/inc/hgl/filesystem/FileSystem.h
index b41190ef..6cd772c1 100644
--- a/inc/hgl/filesystem/FileSystem.h
+++ b/inc/hgl/filesystem/FileSystem.h
@@ -53,7 +53,7 @@ namespace hgl
if(fullname.Length()<=1)
return(BaseString());
- const T spear_char[] = { '/','\\' };
+ const T spear_char[] = { '/','\\' };
const int pos=fullname.FindRightChar(spear_char);
@@ -131,60 +131,60 @@ namespace hgl
inline WideString MergeFilename(const WideString &pathname,const WideString &filename) ///<组合路径名与文件名
{return MergeFilename(pathname,filename,L'\\',L"\\");}
- bool FileCopy(const OSString &,const OSString &); ///<文件复制
- bool FileDelete(const OSString &); ///<文件删除
- bool FileMove(const OSString &,const OSString &); ///<文件移动
- bool FileRename(const OSString &,const OSString &); ///<文件改名
- bool FileExist(const OSString &); ///<文件确认是否存在
- bool FileComp(const OSString &,const OSString &); ///<文件比较
+ bool FileCopy(const OSString &,const OSString &); ///<文件复制
+ bool FileDelete(const OSString &); ///<文件删除
+ bool FileMove(const OSString &,const OSString &); ///<文件移动
+ bool FileRename(const OSString &,const OSString &); ///<文件改名
+ bool FileExist(const OSString &); ///<文件确认是否存在
+ bool FileComp(const OSString &,const OSString &); ///<文件比较
- bool FileCanRead(const OSString &); ///<检测文件是否可读
- bool FileCanWrite(const OSString &); ///<检测文件是否可写
- bool FileCanExec(const OSString &); ///<检测文件是否可执行
+ bool FileCanRead(const OSString &); ///<检测文件是否可读
+ bool FileCanWrite(const OSString &); ///<检测文件是否可写
+ bool FileCanExec(const OSString &); ///<检测文件是否可执行
- int64 LoadFileToMemory(const OSString &,void **); ///<加载一个文件到内存
+ int64 LoadFileToMemory(const OSString &,void **); ///<加载一个文件到内存
int64 SaveMemoryToFile(const OSString &,const void *,const int64 &); ///<保存一块内存成文件
- int64 SaveMemoryToFile(const OSString &,void **,const int64 *,const int &); ///<保存多块内存成一个文件
+ int64 SaveMemoryToFile(const OSString &,void **,const int64 *,const int &); ///<保存多块内存成一个文件
- void *LoadFileToMemory(const OSString &,int64,void *buf,int64); ///<加载一个文件的一部分到内存
- bool SaveMemoryToFile(const OSString &,int64,const void *,int64); ///<保存一块内存到一个文件
+ void *LoadFileToMemory(const OSString &,int64,void *buf,int64); ///<加载一个文件的一部分到内存
+ bool SaveMemoryToFile(const OSString &,int64,const void *,int64); ///<保存一块内存到一个文件
bool IsDirectory(const os_char *);
- inline bool IsDirectory(const OSString &str){return IsDirectory(str.c_str());} ///<判断这个名称是否是目录
+ inline bool IsDirectory(const OSString &str){return IsDirectory(str.c_str());} ///<判断这个名称是否是目录
#if HGL_OS != HGL_OS_Windows
bool IsLink(const os_char *); ///<判断这个名称是否是链接
#endif//
- bool MakePath(const OSString &); ///<创建一个路径
- bool DeletePath(const OSString &); ///<删除一个路径
- void DeleteTree(const OSString &); ///<删除一个路径(包含所有文件)
+ bool MakePath(const OSString &); ///<创建一个路径
+ bool DeletePath(const OSString &); ///<删除一个路径
+ void DeleteTree(const OSString &); ///<删除一个路径(包含所有文件)
- bool GetCurrentPath(OSString &); ///<取得当前路径
- bool GetCurrentProgram(OSString &); ///<取得当前程序全路径名称
- bool GetCurrentProgramPath(OSString &); ///<取得当前程序所在路径
- void GetLocalAppdataPath(os_char fn[HGL_MAX_PATH]); ///<取得当前用户应用程序数据存放路径
+ bool GetCurrentPath(OSString &); ///<取得当前路径
+ bool GetCurrentProgram(OSString &); ///<取得当前程序全路径名称
+ bool GetCurrentProgramPath(OSString &); ///<取得当前程序所在路径
+ void GetLocalAppdataPath(os_char fn[HGL_MAX_PATH]); ///<取得当前用户应用程序数据存放路径
//使用int64而不是__int64是因为不是所有编译器都支持__int64的写法,必须使用DataType.H中引入的定义
/**
* 文件信息数据结构
*/
- struct FileInfo ///文件信息
+ struct FileInfo ///文件信息
{
- os_char name[HGL_MAX_PATH]; ///<文件名(不包含路径)
- os_char fullname[HGL_MAX_PATH]; ///<完整名称(包含路径)
+ os_char name[HGL_MAX_PATH]; ///<文件名(不包含路径)
+ os_char fullname[HGL_MAX_PATH]; ///<完整名称(包含路径)
- uint64 size; ///<文件长度
+ uint64 size; ///<文件长度
union
{
- uint32 attrib; ///<文件属性
+ uint32 attrib; ///<文件属性
struct
{
- bool is_file:1; ///<是文件
- bool is_directory:1; ///<是目录
+ bool is_file:1; ///<是文件
+ bool is_directory:1; ///<是目录
bool is_hiddle:1; ///<是否隐藏文件
@@ -192,15 +192,15 @@ namespace hgl
bool is_link:1; ///<是否是链接
#endif//HGL_OS != HGL_OS_Windows
- bool can_read:1; ///<可以读
- bool can_write:1; ///<可以写
+ bool can_read:1; ///<可以读
+ bool can_write:1; ///<可以写
};
};
uint64 mtime; ///<最后修改日期(这个值在win/unix下不通用)
};//struct FileInfo
- bool GetFileInfo(const os_char *filename,struct FileInfo &); ///<取得文件信息
+ bool GetFileInfo(const os_char *filename,struct FileInfo &); ///<取得文件信息
int GetFileInfoList(List &, const OSString &folder_name, bool proc_folder, bool proc_file, bool sub_folder);
}//namespace filesystem
diff --git a/inc/hgl/graph/Light.h b/inc/hgl/graph/Light.h
index bad3b7c7..3b853ffa 100644
--- a/inc/hgl/graph/Light.h
+++ b/inc/hgl/graph/Light.h
@@ -21,18 +21,18 @@ namespace hgl
*/
enum LightType
{
- ltNone=0, ///<起始定义,无意义
+ ltNone=0, ///<起始定义,无意义
ltSunLight, ///<太阳光
- ltPoint, ///<点光源
- ltDirection, ///<方向光
- ltSpot, ///<聚光灯
+ ltPoint, ///<点光源
+ ltDirection, ///<方向光
+ ltSpot, ///<聚光灯
ltInfiniteSpotLight,///<无尽聚光灯
- ltAreaQuad, ///<四边形面光源
+ ltAreaQuad, ///<四边形面光源
- ltEnd ///<结束定义,无意义
+ ltEnd ///<结束定义,无意义
};//enum LightType
/**
@@ -40,13 +40,13 @@ namespace hgl
*/
struct Light
{
- LightType type; ///<光源类型
+ LightType type; ///<光源类型
- bool enabled; ///<是否开启
+ bool enabled; ///<是否开启
- Color4f ambient; ///<环境光
- Color4f specular; ///<镜面光
- Color4f diffuse; ///<漫反射
+ Color4f ambient; ///<环境光
+ Color4f specular; ///<镜面光
+ Color4f diffuse; ///<漫反射
};//struct Light
/**
@@ -62,10 +62,10 @@ namespace hgl
*/
struct DirectionLight:public Light
{
- Vector3f direction; ///<方向
+ Vector3f direction; ///<方向
- float nDotVP; ///;
diff --git a/inc/hgl/graph/vulkan/VKBufferData.h b/inc/hgl/graph/vulkan/VKBufferData.h
index 56be1311..901ec28d 100644
--- a/inc/hgl/graph/vulkan/VKBufferData.h
+++ b/inc/hgl/graph/vulkan/VKBufferData.h
@@ -23,7 +23,7 @@ VK_NAMESPACE_BEGIN
friend BufferData *CreateBufferData(void *data,const VkFormat f,const uint32_t count,const uint32_t stride);
BufferData(uint8_t *data,const VkFormat f,const uint32_t c,const uint32_t s)
- {
+ {
buffer_data =data;
format=f;
@@ -74,7 +74,7 @@ VK_NAMESPACE_BEGIN
{
VkFormat format; ///<ݸʽ
uint byte; ///<ֽ
-
+
uint compoment; ///<ݳɷ
public:
@@ -141,7 +141,7 @@ VK_NAMESPACE_BEGIN
#define VBDATA_CREATE_FUNC(short_name,type,comp_count,vk_type) \
inline VertexBufferData *VB##comp_count##short_name(const uint32_t &count){return CreateVertexBufferData(vk_type,sizeof(type),comp_count,count);} \
- inline VertexBufferData *VB##comp_count##short_name(const uint32_t &count,const type *data){return CreateVertexBufferData((void *)data,vk_type,sizeof(type),comp_count,count);}
+ inline VertexBufferData *VB##comp_count##short_name(const uint32_t &count,const type *data){return CreateVertexBufferData((void *)data,vk_type,sizeof(type),comp_count,count);}
// UNORM ָԶתΪ 0.0 to 1.0 ĸ
// SNORM ָзԶתΪ-1.0 to +1.0 ĸ
@@ -166,7 +166,7 @@ VK_NAMESPACE_BEGIN
VBDATA_UIF_1234(uint32,int32,float ,VK_FORMAT_R32_UINT)
VBDATA_UIF_1234(uint64,int64,double,VK_FORMAT_R64_UINT)
#undef VBDATA_CREATE_FUNC
-
+
//inline VertexBufferData *EB16(const uint16 &count){return CreateVertexBufferData(GL_UNSIGNED_SHORT, 2,1,count);}
//inline VertexBufferData *EB32(const uint32 &count){return CreateVertexBufferData(GL_UNSIGNED_INT, 4,1,count);}
VK_NAMESPACE_END
diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h
index be111f80..208fd189 100644
--- a/inc/hgl/graph/vulkan/VKDevice.h
+++ b/inc/hgl/graph/vulkan/VKDevice.h
@@ -34,11 +34,11 @@ class Device
RenderPass *main_rp;
ObjectList main_fb;
-
+
uint32_t current_frame;
VkPresentInfoKHR present;
-
+
private:
friend Device *CreateRenderDevice(VkInstance,const PhysicalDevice *,Window *);
@@ -74,7 +74,7 @@ public: //Buffer
Buffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize size,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
Buffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize size,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateBuffer(buf_usage,size,nullptr,sharing_mode);}
-
+
VertexBuffer * CreateVBO(VkFormat format,uint32_t count,const void *data,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE);
VertexBuffer * CreateVBO(VkFormat format,uint32_t count,VkSharingMode sharing_mode=VK_SHARING_MODE_EXCLUSIVE){return CreateVBO(format,count,nullptr,sharing_mode);}
@@ -96,7 +96,7 @@ public: //Buffer
#undef CREATE_BUFFER_OBJECT
public: //material
-
+
ShaderModuleManage *CreateShaderModuleManage();
public: //Command Buffer
diff --git a/inc/hgl/graph/vulkan/VKDeviceAttribute.h b/inc/hgl/graph/vulkan/VKDeviceAttribute.h
index 73c95655..48b2da8d 100644
--- a/inc/hgl/graph/vulkan/VKDeviceAttribute.h
+++ b/inc/hgl/graph/vulkan/VKDeviceAttribute.h
@@ -51,7 +51,7 @@ struct DeviceAttribute
}depth;
VkDescriptorPool desc_pool =nullptr;
-
+
VkPipelineCache pipeline_cache =nullptr;
public:
diff --git a/inc/hgl/graph/vulkan/VKFormat.h b/inc/hgl/graph/vulkan/VKFormat.h
index d59d55fa..6c409f07 100644
--- a/inc/hgl/graph/vulkan/VKFormat.h
+++ b/inc/hgl/graph/vulkan/VKFormat.h
@@ -45,14 +45,14 @@
#define FMT_ABGR8I VK_FORMAT_A8B8G8R8_SINT_PACK32
#define FMT_ABGR8s VK_FORMAT_A8B8G8R8_SRGB_PACK32
-#define FMT_A2RGB10UN VK_FORMAT_A2R10G10B10_UNORM_PACK32
+#define FMT_A2RGB10UN VK_FORMAT_A2R10G10B10_UNORM_PACK32
#define FMT_A2RGB10SN VK_FORMAT_A2R10G10B10_SNORM_PACK32
-#define FMT_A2RGB10U VK_FORMAT_A2R10G10B10_UINT_PACK32
+#define FMT_A2RGB10U VK_FORMAT_A2R10G10B10_UINT_PACK32
#define FMT_A2RGB10I VK_FORMAT_A2R10G10B10_SINT_PACK32
-#define FMT_A2BGR10UN VK_FORMAT_A2B10G10R10_UNORM_PACK32
+#define FMT_A2BGR10UN VK_FORMAT_A2B10G10R10_UNORM_PACK32
#define FMT_A2BGR10SN VK_FORMAT_A2B10G10R10_SNORM_PACK32
-#define FMT_A2BGR10U VK_FORMAT_A2B10G10R10_UINT_PACK32
+#define FMT_A2BGR10U VK_FORMAT_A2B10G10R10_UINT_PACK32
#define FMT_A2BGR10I VK_FORMAT_A2B10G10R10_SINT_PACK32
#define FMT_R16UN VK_FORMAT_R16_UNORM
diff --git a/inc/hgl/graph/vulkan/VKPhysicalDevice.h b/inc/hgl/graph/vulkan/VKPhysicalDevice.h
index aaac1102..bf66209c 100644
--- a/inc/hgl/graph/vulkan/VKPhysicalDevice.h
+++ b/inc/hgl/graph/vulkan/VKPhysicalDevice.h
@@ -35,7 +35,7 @@ public:
return(false);
}
-
+
const bool isDiscreteGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);} ///<ǷǶԿ
const bool isIntegratedGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);} ///<ǷǼԿ
const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<ǷԿ
diff --git a/inc/hgl/graph/vulkan/VKPrimivate.h b/inc/hgl/graph/vulkan/VKPrimivate.h
index c2bd0869..13b52c77 100644
--- a/inc/hgl/graph/vulkan/VKPrimivate.h
+++ b/inc/hgl/graph/vulkan/VKPrimivate.h
@@ -13,10 +13,10 @@
#define PRIM_LINE_STRIP_ADJ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY ///<与LINES_ADJACENCY类似,第一个点跟最后一个点提供信息,剩下的点则跟Line Strip一样形成线段.
#define PRIM_TRIANGLES_ADJ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY ///<代表一个有六个顶点的Primitive,其中第1,3,5个顶点代表一个Triangle,而地2,4,6个点提供邻近信息.(由1起算)
#define PRIM_TRIANGLE_STRIP_ADJ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY ///<4+2N个Vertices代表N个Primitive,其中1,3,5,7,9...代表原本的Triangle strip形成Triangle,而2,4,6,8,10...代表邻近提供信息的点.(由1起算)
-#define PRIM_PATCHS VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
+#define PRIM_PATCHS VK_PRIMITIVE_TOPOLOGY_PATCH_LIST
#define PRIM_RECTANGLE 0x100 ///<矩形(并非原生支持。以画点形式在每个点的Position中传递Left,Top,Width,Height。在Geometry Shader中转换为2个三角形。用于2D游戏或UI)
-#define PRIM_BEGIN VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE
-#define PRIM_END VK_PRIMITIVE_TOPOLOGY_END_RANGE
-#define PRIM_RANGE VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE
+#define PRIM_BEGIN VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE
+#define PRIM_END VK_PRIMITIVE_TOPOLOGY_END_RANGE
+#define PRIM_RANGE VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
diff --git a/inc/hgl/graph/vulkan/VKShaderModule.h b/inc/hgl/graph/vulkan/VKShaderModule.h
index f7c42359..9da1aaf6 100644
--- a/inc/hgl/graph/vulkan/VKShaderModule.h
+++ b/inc/hgl/graph/vulkan/VKShaderModule.h
@@ -33,7 +33,7 @@ protected:
void ParseUBO(const ShaderParse *);
public:
-
+
ShaderModule(int id,VkPipelineShaderStageCreateInfo *pssci,const ShaderParse *);
virtual ~ShaderModule();
@@ -50,10 +50,10 @@ public:
const int GetUBO (const UTF8String &name)const
{
int binding;
-
+
if(ubo_map.Get(name,binding))
return binding;
- else
+ else
return -1;
}
diff --git a/inc/hgl/graph/vulkan/VKShaderParse.h b/inc/hgl/graph/vulkan/VKShaderParse.h
index cfcee472..1ee04127 100644
--- a/inc/hgl/graph/vulkan/VKShaderParse.h
+++ b/inc/hgl/graph/vulkan/VKShaderParse.h
@@ -48,7 +48,7 @@ public:
const VkFormat GetFormat(const spirv_cross::Resource &res)const
{
const spirv_cross::SPIRType &type=compiler->get_type(res.type_id);
-
+
constexpr VkFormat format[][4]=
{
{FMT_R8I,FMT_RG8I,FMT_RGB8I,FMT_RGBA8I}, //sbyte
diff --git a/inc/hgl/io/EndianDataInputStream.h b/inc/hgl/io/EndianDataInputStream.h
index c313e066..54442b35 100644
--- a/inc/hgl/io/EndianDataInputStream.h
+++ b/inc/hgl/io/EndianDataInputStream.h
@@ -5,96 +5,96 @@
#include
namespace hgl
{
- namespace io
- {
- class DirectDataInputStream:public DataInputStream
- {
- public:
+ namespace io
+ {
+ class DirectDataInputStream:public DataInputStream
+ {
+ public:
- using DataInputStream::DataInputStream;
- virtual ~DirectDataInputStream()=default;
+ using DataInputStream::DataInputStream;
+ virtual ~DirectDataInputStream()=default;
- #define STREAM_DIRECT_READ(type,name) virtual bool Read##name(type &value) \
- { \
- return Read(value); \
- } \
- \
- virtual int64 Read##name(type *data,const int64 count) \
- { \
- if(count<=0)return(count); \
- if(!data)return(-1); \
- \
- return ReadArrays(data,count); \
- }
+ #define STREAM_DIRECT_READ(type,name) virtual bool Read##name(type &value) \
+ { \
+ return Read(value); \
+ } \
+ \
+ virtual int64 Read##name(type *data,const int64 count) \
+ { \
+ if(count<=0)return(count); \
+ if(!data)return(-1); \
+ \
+ return ReadArrays(data,count); \
+ }
- STREAM_DIRECT_READ(int16, Int16 );
- STREAM_DIRECT_READ(int32, Int32 );
- STREAM_DIRECT_READ(int64, Int64 );
+ STREAM_DIRECT_READ(int16, Int16 );
+ STREAM_DIRECT_READ(int32, Int32 );
+ STREAM_DIRECT_READ(int64, Int64 );
- STREAM_DIRECT_READ(uint16, Uint16 );
- STREAM_DIRECT_READ(uint32, Uint32 );
- STREAM_DIRECT_READ(uint64, Uint64 );
+ STREAM_DIRECT_READ(uint16, Uint16 );
+ STREAM_DIRECT_READ(uint32, Uint32 );
+ STREAM_DIRECT_READ(uint64, Uint64 );
- STREAM_DIRECT_READ(u16char,UTF16Char);
- STREAM_DIRECT_READ(float, Float );
- STREAM_DIRECT_READ(double, Double );
+ STREAM_DIRECT_READ(u16char,UTF16Char);
+ STREAM_DIRECT_READ(float, Float );
+ STREAM_DIRECT_READ(double, Double );
- #undef STREAM_DIRECT_READ
- };//class DirectDataInputStream
+ #undef STREAM_DIRECT_READ
+ };//class DirectDataInputStream
- class SwapDataInputStream:public DataInputStream
- {
- public:
+ class SwapDataInputStream:public DataInputStream
+ {
+ public:
- using DataInputStream::DataInputStream;
- virtual ~SwapDataInputStream()=default;
+ using DataInputStream::DataInputStream;
+ virtual ~SwapDataInputStream()=default;
- #define STREAM_SWAP_READ(type,name) virtual bool Read##name(type &value) \
- {\
- type swap_value; \
- \
- if(!Read(swap_value)) \
- return(false); \
- \
- value=EndianSwap(swap_value); \
- return(true); \
- } \
- \
- virtual int64 Read##name(type *data,const int64 count) \
- { \
- if(count<=0)return(count); \
- if(!data)return(-1); \
- \
- const int64 result=ReadArrays(data,count); \
- \
- if(result<=0)return(result); \
- \
- EndianSwap(data,result); \
- return(result); \
- }
+ #define STREAM_SWAP_READ(type,name) virtual bool Read##name(type &value) \
+ {\
+ type swap_value; \
+ \
+ if(!Read(swap_value)) \
+ return(false); \
+ \
+ value=EndianSwap(swap_value); \
+ return(true); \
+ } \
+ \
+ virtual int64 Read##name(type *data,const int64 count) \
+ { \
+ if(count<=0)return(count); \
+ if(!data)return(-1); \
+ \
+ const int64 result=ReadArrays(data,count); \
+ \
+ if(result<=0)return(result); \
+ \
+ EndianSwap(data,result); \
+ return(result); \
+ }
- STREAM_SWAP_READ(int16, Int16 );
- STREAM_SWAP_READ(int32, Int32 );
- STREAM_SWAP_READ(int64, Int64 );
+ STREAM_SWAP_READ(int16, Int16 );
+ STREAM_SWAP_READ(int32, Int32 );
+ STREAM_SWAP_READ(int64, Int64 );
- STREAM_SWAP_READ(uint16, Uint16 );
- STREAM_SWAP_READ(uint32, Uint32 );
- STREAM_SWAP_READ(uint64, Uint64 );
+ STREAM_SWAP_READ(uint16, Uint16 );
+ STREAM_SWAP_READ(uint32, Uint32 );
+ STREAM_SWAP_READ(uint64, Uint64 );
- STREAM_SWAP_READ(u16char, UTF16Char);
- STREAM_SWAP_READ(float, Float );
- STREAM_SWAP_READ(double, Double );
+ STREAM_SWAP_READ(u16char, UTF16Char);
+ STREAM_SWAP_READ(float, Float );
+ STREAM_SWAP_READ(double, Double );
- #undef STREAM_SWAP_READ
- };//class SwapDataInputStream
+ #undef STREAM_SWAP_READ
+ };//class SwapDataInputStream
#if HGL_ENDIAN == HGL_LITTLE_ENDIAN
- typedef DirectDataInputStream LEDataInputStream;
- typedef SwapDataInputStream BEDataInputStream;
+ typedef DirectDataInputStream LEDataInputStream;
+ typedef SwapDataInputStream BEDataInputStream;
#else
- typedef DirectDataInputStream BEDataInputStream;
- typedef SwapDataInputStream LEDataInputStream;
+ typedef DirectDataInputStream BEDataInputStream;
+ typedef SwapDataInputStream LEDataInputStream;
#endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- }//namespace io
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_ENDIAN_DATA_INPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/EndianDataOutputStream.h b/inc/hgl/io/EndianDataOutputStream.h
index 66fbfb8c..90190378 100644
--- a/inc/hgl/io/EndianDataOutputStream.h
+++ b/inc/hgl/io/EndianDataOutputStream.h
@@ -5,99 +5,99 @@
#include
namespace hgl
{
- namespace io
- {
- class DirectDataOutputStream:public DataOutputStream
- {
- public:
+ namespace io
+ {
+ class DirectDataOutputStream:public DataOutputStream
+ {
+ public:
- DirectDataOutputStream(OutputStream *os):DataOutputStream(os)
- {
- }
+ DirectDataOutputStream(OutputStream *os):DataOutputStream(os)
+ {
+ }
- virtual ~DirectDataOutputStream()
- {
- }
+ virtual ~DirectDataOutputStream()
+ {
+ }
- #define STREAM_DIRECT_WRITE(type,name) virtual bool Write##name(const type &value) \
- { \
- return Write(value); \
- } \
- \
- virtual int64 Write##name(const type *data,const int64 count) \
- { \
- if(count<=0)return(count); \
- if(!data)return(-1); \
- \
- return WriteArrays(data,count); \
- }
+ #define STREAM_DIRECT_WRITE(type,name) virtual bool Write##name(const type &value) \
+ { \
+ return Write(value); \
+ } \
+ \
+ virtual int64 Write##name(const type *data,const int64 count) \
+ { \
+ if(count<=0)return(count); \
+ if(!data)return(-1); \
+ \
+ return WriteArrays(data,count); \
+ }
- STREAM_DIRECT_WRITE(int16, Int16 );
- STREAM_DIRECT_WRITE(int32, Int32 );
- STREAM_DIRECT_WRITE(int64, Int64 );
+ STREAM_DIRECT_WRITE(int16, Int16 );
+ STREAM_DIRECT_WRITE(int32, Int32 );
+ STREAM_DIRECT_WRITE(int64, Int64 );
- STREAM_DIRECT_WRITE(uint16, Uint16 );
- STREAM_DIRECT_WRITE(uint32, Uint32 );
- STREAM_DIRECT_WRITE(uint64, Uint64 );
+ STREAM_DIRECT_WRITE(uint16, Uint16 );
+ STREAM_DIRECT_WRITE(uint32, Uint32 );
+ STREAM_DIRECT_WRITE(uint64, Uint64 );
- STREAM_DIRECT_WRITE(u16char,UTF16Char);
- STREAM_DIRECT_WRITE(float, Float );
- STREAM_DIRECT_WRITE(double, Double );
+ STREAM_DIRECT_WRITE(u16char,UTF16Char);
+ STREAM_DIRECT_WRITE(float, Float );
+ STREAM_DIRECT_WRITE(double, Double );
- #undef STREAM_DIRECT_WRITE
- };//class DirectDataOutputStream
+ #undef STREAM_DIRECT_WRITE
+ };//class DirectDataOutputStream
- class SwapDataOutputStream:public DataOutputStream
- {
- public:
+ class SwapDataOutputStream:public DataOutputStream
+ {
+ public:
- SwapDataOutputStream(OutputStream *os):DataOutputStream(os)
- {
- }
+ SwapDataOutputStream(OutputStream *os):DataOutputStream(os)
+ {
+ }
- virtual ~SwapDataOutputStream()
- {
- }
+ virtual ~SwapDataOutputStream()
+ {
+ }
- #define STREAM_SWAP_WRITE(type,name) virtual bool Write##name(const type &value) \
- {\
- return Write(EndianSwap(value)); \
- } \
- \
- virtual int64 Write##name(const type *data,const int64 count) \
- { \
- if(count<=0)return(count); \
- if(!data)return(-1); \
- \
- SharedArray swap_data=new type[count]; \
- \
- EndianSwap(swap_data,data,count); \
- \
- return WriteArrays(swap_data,count); \
- }
+ #define STREAM_SWAP_WRITE(type,name) virtual bool Write##name(const type &value) \
+ {\
+ return Write(EndianSwap(value)); \
+ } \
+ \
+ virtual int64 Write##name(const type *data,const int64 count) \
+ { \
+ if(count<=0)return(count); \
+ if(!data)return(-1); \
+ \
+ SharedArray swap_data=new type[count]; \
+ \
+ EndianSwap(swap_data,data,count); \
+ \
+ return WriteArrays(swap_data,count); \
+ }
- STREAM_SWAP_WRITE(int16, Int16 );
- STREAM_SWAP_WRITE(int32, Int32 );
- STREAM_SWAP_WRITE(int64, Int64 );
+ STREAM_SWAP_WRITE(int16, Int16 );
+ STREAM_SWAP_WRITE(int32, Int32 );
+ STREAM_SWAP_WRITE(int64, Int64 );
- STREAM_SWAP_WRITE(uint16, Uint16 );
- STREAM_SWAP_WRITE(uint32, Uint32 );
- STREAM_SWAP_WRITE(uint64, Uint64 );
+ STREAM_SWAP_WRITE(uint16, Uint16 );
+ STREAM_SWAP_WRITE(uint32, Uint32 );
+ STREAM_SWAP_WRITE(uint64, Uint64 );
- STREAM_SWAP_WRITE(u16char, UTF16Char);
- STREAM_SWAP_WRITE(float, Float );
- STREAM_SWAP_WRITE(double, Double );
+ STREAM_SWAP_WRITE(u16char, UTF16Char);
+ STREAM_SWAP_WRITE(float, Float );
+ STREAM_SWAP_WRITE(double, Double );
- #undef STREAM_SWAP_WRITE
- };//class SwapDataOutputStream
+ #undef STREAM_SWAP_WRITE
+ };//class SwapDataOutputStream
#if HGL_ENDIAN == HGL_LITTLE_ENDIAN
- typedef DirectDataOutputStream LEDataOutputStream;
- typedef SwapDataOutputStream BEDataOutputStream;
+ typedef DirectDataOutputStream LEDataOutputStream;
+ typedef SwapDataOutputStream BEDataOutputStream;
#else
- typedef DirectDataOutputStream BEDataOutputStream;
- typedef SwapDataOutputStream LEDataOutputStream;
+ typedef DirectDataOutputStream BEDataOutputStream;
+ typedef SwapDataOutputStream LEDataOutputStream;
#endif//HGL_ENDIAN == HGL_LITTLE_ENDIAN
- }//namespace io
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_ENDIAN_DATA_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/FileAccess.h b/inc/hgl/io/FileAccess.h
index 8d61fe2f..85669978 100644
--- a/inc/hgl/io/FileAccess.h
+++ b/inc/hgl/io/FileAccess.h
@@ -6,78 +6,78 @@
#include
namespace hgl
{
- namespace io
- {
- enum FileOpenMode ///文件访问模式枚举
- {
- fomNone=0,
+ namespace io
+ {
+ enum FileOpenMode ///文件访问模式枚举
+ {
+ fomNone=0,
- fomCreate, ///<创建文件,如存在则失败
- fomCreateTrunc, ///<强制创建,如存在则抹掉
- fomCreateTemp,
- fomOnlyRead, ///<只读方式
- fomOnlyWrite, ///<只写方式
- fomReadWrite, ///<可读可写
- fomAppend, ///<追加模式
+ fomCreate, ///<创建文件,如存在则失败
+ fomCreateTrunc, ///<强制创建,如存在则抹掉
+ fomCreateTemp,
+ fomOnlyRead, ///<只读方式
+ fomOnlyWrite, ///<只写方式
+ fomReadWrite, ///<可读可写
+ fomAppend, ///<追加模式
- fomEnd
- };//enum FileOpenMode
+ fomEnd
+ };//enum FileOpenMode
- /**
- * 文件访问实例管理类
- */
- class FileAccess ///文件访问实例管理类
- {
- protected:
+ /**
+ * 文件访问实例管理类
+ */
+ class FileAccess ///文件访问实例管理类
+ {
+ protected:
- OSString filename;
+ OSString filename;
- int fp;
+ int fp;
- struct_stat64 file_state;
+ struct_stat64 file_state;
- FileOpenMode mode;
+ FileOpenMode mode;
- public:
+ public:
- FileAccess();
- virtual ~FileAccess();
+ FileAccess();
+ virtual ~FileAccess();
- virtual bool Open(const OSString &,FileOpenMode fom); ///<以指定模式打开一个文件
- virtual bool Create(const OSString &fn){return Open(fn,fomCreate);} ///<创建一个新文件,如文件已存在则创建失败
- virtual bool CreateTrunc(const OSString &fn){return Open(fn,fomCreateTrunc);} ///<创建一个新文件,如文件已存在则抹消它
- virtual bool OpenRead(const OSString &fn){return Open(fn,fomOnlyRead);} ///<以只读模式打开一个文件
- virtual bool OpenWrite(const OSString &fn){return Open(fn,fomOnlyWrite);} ///<以只写模式打开一个文件
- virtual bool OpenReadWrite(const OSString &fn){return Open(fn,fomReadWrite);} ///<以读写模式打开一个文件
- virtual bool CreateTemp();
+ virtual bool Open(const OSString &,FileOpenMode fom); ///<以指定模式打开一个文件
+ virtual bool Create(const OSString &fn){return Open(fn,fomCreate);} ///<创建一个新文件,如文件已存在则创建失败
+ virtual bool CreateTrunc(const OSString &fn){return Open(fn,fomCreateTrunc);} ///<创建一个新文件,如文件已存在则抹消它
+ virtual bool OpenRead(const OSString &fn){return Open(fn,fomOnlyRead);} ///<以只读模式打开一个文件
+ virtual bool OpenWrite(const OSString &fn){return Open(fn,fomOnlyWrite);} ///<以只写模式打开一个文件
+ virtual bool OpenReadWrite(const OSString &fn){return Open(fn,fomReadWrite);} ///<以读写模式打开一个文件
+ virtual bool CreateTemp();
- virtual void Close(); ///<关闭文件
- virtual void CloseRead(); ///<仅关闭读取
- virtual void CloseWrite(); ///<仅关闭写入
+ virtual void Close(); ///<关闭文件
+ virtual void CloseRead(); ///<仅关闭读取
+ virtual void CloseWrite(); ///<仅关闭写入
- virtual int GetFileHandle()const{return fp;}
+ virtual int GetFileHandle()const{return fp;}
- virtual bool CanRead()const; ///<文件是否可读
- virtual bool CanPeek()const{return(CanRead()&&CanSeek());} ///<文件是否可预读
- virtual bool CanWrite()const; ///<文件是否可写
- virtual bool CanSeek()const; ///<文件是否可定位访问指针
- virtual bool CanRestart()const{return CanSeek();} ///<文件是否可复位访问
- virtual bool CanSize()const{return(true);} ///<文件是否可取得长度
+ virtual bool CanRead()const; ///<文件是否可读
+ virtual bool CanPeek()const{return(CanRead()&&CanSeek());} ///<文件是否可预读
+ virtual bool CanWrite()const; ///<文件是否可写
+ virtual bool CanSeek()const; ///<文件是否可定位访问指针
+ virtual bool CanRestart()const{return CanSeek();} ///<文件是否可复位访问
+ virtual bool CanSize()const{return(true);} ///<文件是否可取得长度
- virtual int64 Seek(int64,SeekOrigin=soBegin); ///<定位访问指针
- virtual int64 Tell()const; ///<取得访问指针位置
- virtual int64 GetSize(); ///<取得文件长度
- virtual bool Restart(); ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin); ///<定位访问指针
+ virtual int64 Tell()const; ///<取得访问指针位置
+ virtual int64 GetSize(); ///<取得文件长度
+ virtual bool Restart(); ///<复位访问指针
- virtual int64 Read(void *,int64); ///<读取指定长度数据
- virtual int64 Peek(void *,int64); ///<预读指定长度数据
- virtual int64 Write(const void *,int64); ///<写入指定长度数据
+ virtual int64 Read(void *,int64); ///<读取指定长度数据
+ virtual int64 Peek(void *,int64); ///<预读指定长度数据
+ virtual int64 Write(const void *,int64); ///<写入指定长度数据
- virtual int64 AvailableRead(); ///<剩下的可读数据
+ virtual int64 AvailableRead(); ///<剩下的可读数据
- virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
- virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
- };//class FileAccess
- }//namespace io
+ virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
+ virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
+ };//class FileAccess
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_FILE_ACCESS_INCLUDE
diff --git a/inc/hgl/io/FileInputStream.h b/inc/hgl/io/FileInputStream.h
index 5490bf2a..72fe582e 100644
--- a/inc/hgl/io/FileInputStream.h
+++ b/inc/hgl/io/FileInputStream.h
@@ -5,74 +5,74 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 文件输入流类
- */
- class FileInputStream:public InputStream ///文件输入流类
- {
- protected:
+ namespace io
+ {
+ /**
+ * 文件输入流类
+ */
+ class FileInputStream:public InputStream ///文件输入流类
+ {
+ protected:
- SharedPtr file; ///<文件访问指针
+ SharedPtr file; ///<文件访问指针
- public:
+ public:
- FileInputStream();
- FileInputStream(SharedPtr &);
- virtual ~FileInputStream();
+ FileInputStream();
+ FileInputStream(SharedPtr &);
+ virtual ~FileInputStream();
- virtual bool Open(const OSString &); ///<打开文件
- virtual void Close(); ///<关闭文件输入流
+ virtual bool Open(const OSString &); ///<打开文件
+ virtual void Close(); ///<关闭文件输入流
- virtual int GetFileHandle()const{return file->GetFileHandle();}
+ virtual int GetFileHandle()const{return file->GetFileHandle();}
- virtual int64 Read(void *,int64); ///<读取数据
- virtual int64 Peek(void *,int64); ///<预读数据
+ virtual int64 Read(void *,int64); ///<读取数据
+ virtual int64 Peek(void *,int64); ///<预读数据
- virtual bool CanSeek()const; ///<是否可移动访问指针
- virtual bool CanRestart()const; ///<是否可复位访问
- virtual bool CanSize()const; ///<是否可访问文件长度
- virtual bool CanPeek()const; ///<是否可预读数据
+ virtual bool CanSeek()const; ///<是否可移动访问指针
+ virtual bool CanRestart()const; ///<是否可复位访问
+ virtual bool CanSize()const; ///<是否可访问文件长度
+ virtual bool CanPeek()const; ///<是否可预读数据
- virtual int64 Skip(int64); ///<跳过指定字节
- virtual int64 Tell()const; ///<取当前位置
- virtual int64 GetSize()const; ///<取得文件长度
- virtual bool Restart(); ///<复位访问指针
- virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
+ virtual int64 Skip(int64); ///<跳过指定字节
+ virtual int64 Tell()const; ///<取当前位置
+ virtual int64 GetSize()const; ///<取得文件长度
+ virtual bool Restart(); ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
- virtual int64 Available()const; ///<剩下的可以不受阻塞访问的字节数
+ virtual int64 Available()const; ///<剩下的可以不受阻塞访问的字节数
- virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
- };//class FileInputStream
+ virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
+ };//class FileInputStream
- class OpenFileInputStream
- {
- FileInputStream *fis;
+ class OpenFileInputStream
+ {
+ FileInputStream *fis;
- public:
+ public:
- OpenFileInputStream(const OSString &filename)
- {
- fis=new FileInputStream();
+ OpenFileInputStream(const OSString &filename)
+ {
+ fis=new FileInputStream();
- if(!fis->Open(filename))
+ if(!fis->Open(filename))
{
delete fis;
fis=nullptr;
}
- }
+ }
- ~OpenFileInputStream()
- {
- SAFE_CLEAR(fis);
- }
+ ~OpenFileInputStream()
+ {
+ SAFE_CLEAR(fis);
+ }
- const bool operator !(){return !fis;}
- operator FileInputStream *(){return fis;}
- FileInputStream *operator &(){return fis;}
- FileInputStream *operator ->(){return fis;}
- };//class OpenFileInputStream
- }//namespace io
+ const bool operator !(){return !fis;}
+ operator FileInputStream *(){return fis;}
+ FileInputStream *operator &(){return fis;}
+ FileInputStream *operator ->(){return fis;}
+ };//class OpenFileInputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_FILE_INPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/FileOutputStream.h b/inc/hgl/io/FileOutputStream.h
index ca497a84..e55d798b 100644
--- a/inc/hgl/io/FileOutputStream.h
+++ b/inc/hgl/io/FileOutputStream.h
@@ -5,89 +5,89 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 文件输出流类
- */
- class FileOutputStream:public OutputStream ///文件输出流类
- {
- protected:
+ namespace io
+ {
+ /**
+ * 文件输出流类
+ */
+ class FileOutputStream:public OutputStream ///文件输出流类
+ {
+ protected:
- SharedPtr file; ///<文件访问指针
+ SharedPtr file; ///<文件访问指针
- virtual bool OpenFile(const OSString &,FileOpenMode);
+ virtual bool OpenFile(const OSString &,FileOpenMode);
- public:
+ public:
- FileOutputStream();
- FileOutputStream(SharedPtr &);
- virtual ~FileOutputStream();
+ FileOutputStream();
+ FileOutputStream(SharedPtr &);
+ virtual ~FileOutputStream();
- virtual bool Open(const OSString &fn,FileOpenMode mode){return OpenFile(fn,mode);} ///<打开文件,指定一个模式
- virtual bool Open(const OSString &fn){return OpenFile(fn,fomOnlyWrite);} ///<打开文件
- virtual bool Create(const OSString &fn){return OpenFile(fn,fomCreate);} ///<创建文件,如存在创建失败
- virtual bool CreateTrunc(const OSString &fn){return OpenFile(fn,fomCreateTrunc);} ///<创建文件,如存在则抹去
- virtual bool OpenAppend(const OSString &fn){return OpenFile(fn,fomAppend);} ///<打开文件,追加模式
+ virtual bool Open(const OSString &fn,FileOpenMode mode){return OpenFile(fn,mode);} ///<打开文件,指定一个模式
+ virtual bool Open(const OSString &fn){return OpenFile(fn,fomOnlyWrite);} ///<打开文件
+ virtual bool Create(const OSString &fn){return OpenFile(fn,fomCreate);} ///<创建文件,如存在创建失败
+ virtual bool CreateTrunc(const OSString &fn){return OpenFile(fn,fomCreateTrunc);} ///<创建文件,如存在则抹去
+ virtual bool OpenAppend(const OSString &fn){return OpenFile(fn,fomAppend);} ///<打开文件,追加模式
- virtual void Close(); ///<关闭文件
+ virtual void Close(); ///<关闭文件
- virtual int64 Write(const void *,int64); ///<写入数据
+ virtual int64 Write(const void *,int64); ///<写入数据
- virtual bool CanSeek()const; ///<是否可移动访问指针
- virtual bool CanRestart()const; ///<是否可复位访问
- virtual bool CanSize()const; ///<是否可访问文件长度
+ virtual bool CanSeek()const; ///<是否可移动访问指针
+ virtual bool CanRestart()const; ///<是否可复位访问
+ virtual bool CanSize()const; ///<是否可访问文件长度
- virtual int64 Tell()const; ///<取当前位置
- virtual int64 GetSize()const; ///<取得文件长度
- virtual bool Restart(); ///<复位访问指针
- virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
- virtual int64 Available()const{return -1;} ///<可不受影响写入的字节数
+ virtual int64 Tell()const; ///<取当前位置
+ virtual int64 GetSize()const; ///<取得文件长度
+ virtual bool Restart(); ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
+ virtual int64 Available()const{return -1;} ///<可不受影响写入的字节数
- virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
- };//class FileOutputStream
+ virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
+ };//class FileOutputStream
- /**
- * 打开一个文件输出流
- */
- class OpenFileOutputStream
- {
- FileOutputStream *fos;
+ /**
+ * 打开一个文件输出流
+ */
+ class OpenFileOutputStream
+ {
+ FileOutputStream *fos;
- public:
+ public:
OpenFileOutputStream()
{
fos=nullptr;
}
- /**
- * 打开一个文件输出流构造函数
- * @param filename 文件名
- * @param mode 打开模式,默认只写(必然可读)
- * @see FileOpenMode
- */
- OpenFileOutputStream(const OSString &filename,FileOpenMode mode=fomOnlyWrite)
- {
- fos=new FileOutputStream();
+ /**
+ * 打开一个文件输出流构造函数
+ * @param filename 文件名
+ * @param mode 打开模式,默认只写(必然可读)
+ * @see FileOpenMode
+ */
+ OpenFileOutputStream(const OSString &filename,FileOpenMode mode=fomOnlyWrite)
+ {
+ fos=new FileOutputStream();
- if(!fos->Open(filename))
+ if(!fos->Open(filename))
{
delete fos;
fos=nullptr;
}
- }
+ }
- ~OpenFileOutputStream()
- {
- SAFE_CLEAR(fos);
+ ~OpenFileOutputStream()
+ {
+ SAFE_CLEAR(fos);
}
const bool operator !(){return !fos;}
- operator FileOutputStream *(){return fos;}
- FileOutputStream *operator &(){return fos;}
- FileOutputStream *operator ->(){return fos;}
- };//class OpenFileInputStream
- }//namespace io
+ operator FileOutputStream *(){return fos;}
+ FileOutputStream *operator &(){return fos;}
+ FileOutputStream *operator ->(){return fos;}
+ };//class OpenFileInputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_FILE_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/IOType.h b/inc/hgl/io/IOType.h
index 5456d091..d09068a5 100644
--- a/inc/hgl/io/IOType.h
+++ b/inc/hgl/io/IOType.h
@@ -4,31 +4,31 @@
#include
namespace hgl
{
- namespace io
- {
- class DataInputStream;
- class DataOutputStream;
+ namespace io
+ {
+ class DataInputStream;
+ class DataOutputStream;
- template struct io_type
- {
- T value;
+ template struct io_type
+ {
+ T value;
- public:
+ public:
- io_type()=default;
- io_type(const T &v){value=v;}
+ io_type()=default;
+ io_type(const T &v){value=v;}
- bool Read(DataInputStream *);
- bool Write(DataOutputStream *)const;
+ bool Read(DataInputStream *);
+ bool Write(DataOutputStream *)const;
- void operator = (const T &v)
- {
- value=v;
- }
+ void operator = (const T &v)
+ {
+ value=v;
+ }
- operator T (){return value;}
- operator const T ()const{return value;}
- };//template struct io_type
- }//namespace io
+ operator T (){return value;}
+ operator const T ()const{return value;}
+ };//template struct io_type
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_TYPE_INCLUDE
diff --git a/inc/hgl/io/InputStream.h b/inc/hgl/io/InputStream.h
index 9f81e226..c2dd5963 100644
--- a/inc/hgl/io/InputStream.h
+++ b/inc/hgl/io/InputStream.h
@@ -5,35 +5,35 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 数据输入流基类
- */
- class InputStream:public SeekAccess ///数据输入流基类
- {
- public:
+ namespace io
+ {
+ /**
+ * 数据输入流基类
+ */
+ class InputStream:public SeekAccess ///数据输入流基类
+ {
+ public:
- virtual ~InputStream()=default;
+ virtual ~InputStream()=default;
- virtual void Close()=0; ///<关闭输入流
+ virtual void Close()=0; ///<关闭输入流
- virtual int64 Read(void *,int64)=0; ///<读取数据
- virtual int64 Peek(void *,int64)=0; ///<预览数据
- virtual int64 ReadFully(void *buf,int64 buf_size){return Read(buf,buf_size);} ///<充分读取,保证读取到指定长度的数据(不计算超时)
+ virtual int64 Read(void *,int64)=0; ///<读取数据
+ virtual int64 Peek(void *,int64)=0; ///<预览数据
+ virtual int64 ReadFully(void *buf,int64 buf_size){return Read(buf,buf_size);} ///<充分读取,保证读取到指定长度的数据(不计算超时)
- virtual bool CanRestart()const=0; ///<是否可以复位
- virtual bool CanSeek()const=0; ///<是否可以定位
- virtual bool CanSize()const=0; ///<是否可以取得尺寸
- virtual bool CanPeek()const=0; ///<是否可以预览数据
+ virtual bool CanRestart()const=0; ///<是否可以复位
+ virtual bool CanSeek()const=0; ///<是否可以定位
+ virtual bool CanSize()const=0; ///<是否可以取得尺寸
+ virtual bool CanPeek()const=0; ///<是否可以预览数据
- virtual bool Restart()=0; ///<复位访问指针
- virtual int64 Skip(int64)=0; ///<跳过指定字节不访问
- virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
- virtual int64 Tell()const=0; ///<返回当前访问位置
- virtual int64 GetSize()const=0; ///<取得流长度
- virtual int64 Available()const=0; ///<剩下的可以不受阻塞访问的字节数
- };//class InputStream
- }//namespace io
+ virtual bool Restart()=0; ///<复位访问指针
+ virtual int64 Skip(int64)=0; ///<跳过指定字节不访问
+ virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
+ virtual int64 Tell()const=0; ///<返回当前访问位置
+ virtual int64 GetSize()const=0; ///<取得流长度
+ virtual int64 Available()const=0; ///<剩下的可以不受阻塞访问的字节数
+ };//class InputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_INPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/JavaInputStream.h b/inc/hgl/io/JavaInputStream.h
index 7b17b5b3..3b07a1c4 100644
--- a/inc/hgl/io/JavaInputStream.h
+++ b/inc/hgl/io/JavaInputStream.h
@@ -4,68 +4,68 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * Java数据输入流
- * 接口类似于java.io.DataInputStream,用于和Java程序进行交互
- */
- class JavaInputStream
- {
- protected:
+ namespace io
+ {
+ /**
+ * Java数据输入流
+ * 接口类似于java.io.DataInputStream,用于和Java程序进行交互
+ */
+ class JavaInputStream
+ {
+ protected:
- BEDataInputStream *in;
+ BEDataInputStream *in;
- public:
+ public:
- JavaInputStream(InputStream *is)
- {
- in=new BEDataInputStream(is);
- }
+ JavaInputStream(InputStream *is)
+ {
+ in=new BEDataInputStream(is);
+ }
- virtual ~JavaInputStream()
- {
- delete in;
- }
+ virtual ~JavaInputStream()
+ {
+ delete in;
+ }
- int64 read (void *ptr,int size){return in?in->ReadFully(ptr,size):-1;}
- int skipBytes (int size) {return in?in->Seek(size,soCurrent):-1;}
+ int64 read (void *ptr,int size){return in?in->ReadFully(ptr,size):-1;}
+ int skipBytes (int size) {return in?in->Seek(size,soCurrent):-1;}
- bool readBoolean (bool &b) {return in?in->ReadBool (b):false;}
- bool readByte (int8 &i) {return in?in->ReadInt8 (i):false;}
- bool readUnsignedByte (uint8 &i) {return in?in->ReadUint8 (i):false;}
+ bool readBoolean (bool &b) {return in?in->ReadBool (b):false;}
+ bool readByte (int8 &i) {return in?in->ReadInt8 (i):false;}
+ bool readUnsignedByte (uint8 &i) {return in?in->ReadUint8 (i):false;}
- bool readShort (int16 &i) {return in?in->ReadInt16 (i):false;}
- bool readUnsignedShort (uint16 &i) {return in?in->ReadUint16 (i):false;}
- bool readInt (int32 &i) {return in?in->ReadInt32 (i):false;}
- bool readLong (int64 &i) {return in?in->ReadInt64 (i):false;}
- bool readFloat (float &f) {return in?in->ReadFloat (f):false;}
- bool readDouble (double &d) {return in?in->ReadDouble (d):false;}
+ bool readShort (int16 &i) {return in?in->ReadInt16 (i):false;}
+ bool readUnsignedShort (uint16 &i) {return in?in->ReadUint16 (i):false;}
+ bool readInt (int32 &i) {return in?in->ReadInt32 (i):false;}
+ bool readLong (int64 &i) {return in?in->ReadInt64 (i):false;}
+ bool readFloat (float &f) {return in?in->ReadFloat (f):false;}
+ bool readDouble (double &d) {return in?in->ReadDouble (d):false;}
- bool readChar (u16char &c)
- {
- if(!in)
- return(false);
+ bool readChar (u16char &c)
+ {
+ if(!in)
+ return(false);
- uint16 c16;
+ uint16 c16;
- if(!in->Read(c16))
- return(false);
+ if(!in->Read(c16))
+ return(false);
- c=BigToCurrentEndian(c16);
- return(true);
- }
+ c=BigToCurrentEndian(c16);
+ return(true);
+ }
- bool readChars (u16char *wstr,const int count)
- {
- return in?in->ReadUTF16BEChars(wstr,count):false;
- }
+ bool readChars (u16char *wstr,const int count)
+ {
+ return in?in->ReadUTF16BEChars(wstr,count):false;
+ }
- bool readUTF (UTF16String &str)
+ bool readUTF (UTF16String &str)
{
return in?in->ReadUTF8ShortString(str);
}
- };//class JavaInputStream
- }//namespace io
+ };//class JavaInputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_JAVA_INPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/JavaOutputStream.h b/inc/hgl/io/JavaOutputStream.h
index 3d53000d..bf2d91db 100644
--- a/inc/hgl/io/JavaOutputStream.h
+++ b/inc/hgl/io/JavaOutputStream.h
@@ -4,59 +4,59 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * Java数据输出流
- * 接口类似于java.io.DataOutputStream,用于和Java程序进行交互
- */
- class JavaOutputStream
- {
- protected:
+ namespace io
+ {
+ /**
+ * Java数据输出流
+ * 接口类似于java.io.DataOutputStream,用于和Java程序进行交互
+ */
+ class JavaOutputStream
+ {
+ protected:
- BEDataOutputStream *out;
+ BEDataOutputStream *out;
- public:
+ public:
- JavaOutputStream(OutputStream *os)
- {
- out=new BEDataOutputStream(os);
- }
+ JavaOutputStream(OutputStream *os)
+ {
+ out=new BEDataOutputStream(os);
+ }
- virtual ~JavaOutputStream()
- {
- delete out;
- }
+ virtual ~JavaOutputStream()
+ {
+ delete out;
+ }
- int64 write (const void *ptr,int size) {return out?out->WriteFully(ptr,size):-1;}
+ int64 write (const void *ptr,int size) {return out?out->WriteFully(ptr,size):-1;}
- bool writeBoolean (const bool &b) {return out?out->WriteBool (b):false;}
- bool writeByte (const int8 &i) {return out?out->WriteInt8 (i):false;}
- bool writeUnsignedByte (const uint8 &i) {return out?out->WriteUint8 (i):false;}
+ bool writeBoolean (const bool &b) {return out?out->WriteBool (b):false;}
+ bool writeByte (const int8 &i) {return out?out->WriteInt8 (i):false;}
+ bool writeUnsignedByte (const uint8 &i) {return out?out->WriteUint8 (i):false;}
- bool writeShort (const int16 &i) {return out?out->WriteInt16 (i):false;}
- bool writeUnsignedShort (const uint16 &i) {return out?out->WriteUint16(i):false;}
- bool writeInt (const int32 &i) {return out?out->WriteInt32 (i):false;}
- bool writeLong (const int64 &i) {return out?out->WriteInt64 (i):false;}
- bool writeFloat (const float &f) {return out?out->WriteFloat (f):false;}
- bool writeDouble (const double &d) {return out?out->WriteDouble(d):false;}
+ bool writeShort (const int16 &i) {return out?out->WriteInt16 (i):false;}
+ bool writeUnsignedShort (const uint16 &i) {return out?out->WriteUint16(i):false;}
+ bool writeInt (const int32 &i) {return out?out->WriteInt32 (i):false;}
+ bool writeLong (const int64 &i) {return out?out->WriteInt64 (i):false;}
+ bool writeFloat (const float &f) {return out?out->WriteFloat (f):false;}
+ bool writeDouble (const double &d) {return out?out->WriteDouble(d):false;}
- bool writeChar (const u16char &c)
- {
- if(!out)
- return(false);
+ bool writeChar (const u16char &c)
+ {
+ if(!out)
+ return(false);
- return out->Write(ToBigEndian(c));
- }
+ return out->Write(ToBigEndian(c));
+ }
- bool writeChars (const u16char *wstr,const int64 count)
- {
- return out?out->WriteUTF16BEChars(wstr,count):false;
- }
+ bool writeChars (const u16char *wstr,const int64 count)
+ {
+ return out?out->WriteUTF16BEChars(wstr,count):false;
+ }
- bool writeUTF (const UTF8String &str){return out?out->WriteUTF8ShortString(str);}
- bool writeUTF (const UTF16String &str){return out?out->WriteUTF8ShortString(str);}
- };//class JavaOutputStream
- }//namespace io
+ bool writeUTF (const UTF8String &str){return out?out->WriteUTF8ShortString(str);}
+ bool writeUTF (const UTF16String &str){return out?out->WriteUTF8ShortString(str);}
+ };//class JavaOutputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_JAVA_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/MemoryInputStream.h b/inc/hgl/io/MemoryInputStream.h
index 78129cde..78edbbe9 100644
--- a/inc/hgl/io/MemoryInputStream.h
+++ b/inc/hgl/io/MemoryInputStream.h
@@ -5,159 +5,159 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 内存数据输入流,从内存块中取得数据。
- */
- class MemoryInputStream:public InputStream ///内存数据输入流
- {
- protected:
+ namespace io
+ {
+ /**
+ * 内存数据输入流,从内存块中取得数据。
+ */
+ class MemoryInputStream:public InputStream ///内存数据输入流
+ {
+ protected:
- const uint8 *buf;
- size_t buf_size;
- size_t cur_pos;
+ const uint8 *buf;
+ size_t buf_size;
+ size_t cur_pos;
- public:
+ public:
- MemoryInputStream()
- {
- buf=0;
+ MemoryInputStream()
+ {
+ buf=0;
- buf_size=0;
- cur_pos=0;
- }
+ buf_size=0;
+ cur_pos=0;
+ }
- virtual ~MemoryInputStream()
- {
- }
+ virtual ~MemoryInputStream()
+ {
+ }
- /**
- * 关联一个数据区到当前输入流
- * @param data 数据指针
- * @param size 数据长度字节数
- * @return 是否成功
- */
- bool Link(const void *data,const size_t size)
- {
- if(!data)
- return(false);
+ /**
+ * 关联一个数据区到当前输入流
+ * @param data 数据指针
+ * @param size 数据长度字节数
+ * @return 是否成功
+ */
+ bool Link(const void *data,const size_t size)
+ {
+ if(!data)
+ return(false);
- buf=(uint8 *)data;
- buf_size=size;
- cur_pos=0;
+ buf=(uint8 *)data;
+ buf_size=size;
+ cur_pos=0;
- return(true);
- }
+ return(true);
+ }
- /**
- * 更新关联的数据区长度,不复位cur_pos
- * @param data 数据指针
- * @param size 数据长度字节数
- * @return 是否成功
- */
- bool Update(void *data,size_t size)
- {
- if(!data)
- return(false);
+ /**
+ * 更新关联的数据区长度,不复位cur_pos
+ * @param data 数据指针
+ * @param size 数据长度字节数
+ * @return 是否成功
+ */
+ bool Update(void *data,size_t size)
+ {
+ if(!data)
+ return(false);
- buf=(uint8 *)data;
- buf_size=size;
+ buf=(uint8 *)data;
+ buf_size=size;
- return(true);
- }
+ return(true);
+ }
- void Unlink()
- {
- buf=0;
- }
+ void Unlink()
+ {
+ buf=0;
+ }
- void Close()
- {
- Unlink();
- }
+ void Close()
+ {
+ Unlink();
+ }
- int64 Read(void *data,int64 size)
- {
- const int result=Peek(data,size);
+ int64 Read(void *data,int64 size)
+ {
+ const int result=Peek(data,size);
- if(result>0)
- cur_pos+=result;
+ if(result>0)
+ cur_pos+=result;
- return result;
- }
+ return result;
+ }
- int64 Peek(void *data,int64 size)
- {
- if(!buf||!data||size<0)
- return(-1);
+ int64 Peek(void *data,int64 size)
+ {
+ if(!buf||!data||size<0)
+ return(-1);
- if(cur_pos+size>buf_size)
- size=buf_size-cur_pos;
+ if(cur_pos+size>buf_size)
+ size=buf_size-cur_pos;
- if(size<=0)
- return(0);
+ if(size<=0)
+ return(0);
- memcpy(data,buf+cur_pos,size);
+ memcpy(data,buf+cur_pos,size);
- return size;
- }
+ return size;
+ }
- bool CanRestart()const{return true;}
- bool CanSeek()const{return true;}
- bool CanSize()const{return true;}
- bool CanPeek()const{return true;}
+ bool CanRestart()const{return true;}
+ bool CanSeek()const{return true;}
+ bool CanSize()const{return true;}
+ bool CanPeek()const{return true;}
- bool Restart()
- {
- cur_pos=0;
- return(true);
- }
+ bool Restart()
+ {
+ cur_pos=0;
+ return(true);
+ }
- int64 Skip(int64 bytes)
- {
- return Seek(bytes,soCurrent);
- }
+ int64 Skip(int64 bytes)
+ {
+ return Seek(bytes,soCurrent);
+ }
- int64 Seek(int64 off,SeekOrigin so)
- {
- if(!CanSeek())return(-1);
+ int64 Seek(int64 off,SeekOrigin so)
+ {
+ if(!CanSeek())return(-1);
- if(so==soCurrent)
- {
- off+=cur_pos;
- }
- else
- if(so==soEnd)
- {
- off+=buf_size;
- }
+ if(so==soCurrent)
+ {
+ off+=cur_pos;
+ }
+ else
+ if(so==soEnd)
+ {
+ off+=buf_size;
+ }
- if(off<0||off>=buf_size)
- return(-1);
+ if(off<0||off>=buf_size)
+ return(-1);
- cur_pos=off;
- return cur_pos;
- }
+ cur_pos=off;
+ return cur_pos;
+ }
- int64 Tell()const
- {
- if(!buf)return(-1);
- return cur_pos;
- }
+ int64 Tell()const
+ {
+ if(!buf)return(-1);
+ return cur_pos;
+ }
- int64 GetSize()const
- {
- if(!buf)return(-1);
- return buf_size;
- }
+ int64 GetSize()const
+ {
+ if(!buf)return(-1);
+ return buf_size;
+ }
- int64 Available()const
- {
- if(!buf)return(-1);
- return buf_size-cur_pos;
- }
- };//class MemoryInputStream
- }//namespace io
+ int64 Available()const
+ {
+ if(!buf)return(-1);
+ return buf_size-cur_pos;
+ }
+ };//class MemoryInputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_MEMORY_INPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/MemoryOutputStream.h b/inc/hgl/io/MemoryOutputStream.h
index 4b53205a..ef9c8822 100644
--- a/inc/hgl/io/MemoryOutputStream.h
+++ b/inc/hgl/io/MemoryOutputStream.h
@@ -5,48 +5,48 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 内存数据输出流,将数据输出到一个内存块中。
- */
- class MemoryOutputStream:public OutputStream ///内存数据输出流
- {
- protected:
+ namespace io
+ {
+ /**
+ * 内存数据输出流,将数据输出到一个内存块中。
+ */
+ class MemoryOutputStream:public OutputStream ///内存数据输出流
+ {
+ protected:
- uint8 *buf;
+ uint8 *buf;
- size_t max_size;
- size_t buf_size;
- size_t cur_pos;
+ size_t max_size;
+ size_t buf_size;
+ size_t cur_pos;
- bool one;
+ bool one;
- public:
+ public:
- MemoryOutputStream()
- {
- buf=0;
- max_size=0;
- buf_size=0;
- cur_pos=0;
- one=false;
- }
+ MemoryOutputStream()
+ {
+ buf=0;
+ max_size=0;
+ buf_size=0;
+ cur_pos=0;
+ one=false;
+ }
- virtual ~MemoryOutputStream()
- {
- Close();
- }
+ virtual ~MemoryOutputStream()
+ {
+ Close();
+ }
- void *GetData()const{return buf;}
+ void *GetData()const{return buf;}
- /**
+ /**
* 创建一个当前流数据的内存拷贝,此函数需用户自行delete[]
* @param len 存放数据长度的指针
* @return 创建好的内存拷贝
*/
- void *CreateCopyData(int *len)const
- {
+ void *CreateCopyData(int *len)const
+ {
if(buf_size<=0)
return(nullptr);
@@ -60,177 +60,177 @@ namespace hgl
return data;
}
- /**
- * 关联一个数据区到当前输出流
- * @param ptr 数据指针
- * @param size 数据长度字节数
- * @param one_instance 是否仅此一份实例(如果是,将由MemoryOutputStream类负责释放)
- * @return 是否成功
- */
- bool Link(void *ptr,size_t size,bool one_instance=false)
- {
- if(!ptr||!size)
- return(false);
+ /**
+ * 关联一个数据区到当前输出流
+ * @param ptr 数据指针
+ * @param size 数据长度字节数
+ * @param one_instance 是否仅此一份实例(如果是,将由MemoryOutputStream类负责释放)
+ * @return 是否成功
+ */
+ bool Link(void *ptr,size_t size,bool one_instance=false)
+ {
+ if(!ptr||!size)
+ return(false);
- buf=(uint8 *)ptr;
- buf_size=size;
- max_size=size;
- cur_pos=0;
+ buf=(uint8 *)ptr;
+ buf_size=size;
+ max_size=size;
+ cur_pos=0;
- one=one_instance;
+ one=one_instance;
- return(true);
- }
+ return(true);
+ }
- /**
- * 更新关联的数据区长度,不复位cur_pos
- * @param ptr 数据指针
- * @param size 数据长度字节数
- * @return 是否成功
- */
- bool Update(void *ptr,size_t size)
- {
- if(!ptr||!size)
- return(false);
+ /**
+ * 更新关联的数据区长度,不复位cur_pos
+ * @param ptr 数据指针
+ * @param size 数据长度字节数
+ * @return 是否成功
+ */
+ bool Update(void *ptr,size_t size)
+ {
+ if(!ptr||!size)
+ return(false);
- buf=(uint8 *)ptr;
- buf_size=size;
- max_size=0;
+ buf=(uint8 *)ptr;
+ buf_size=size;
+ max_size=0;
- return(true);
- }
+ return(true);
+ }
- void Unlink()
- {
- buf=0;
- buf_size=0;
- max_size=0;
- }
+ void Unlink()
+ {
+ buf=0;
+ buf_size=0;
+ max_size=0;
+ }
- bool Create(int64 size)
- {
- Close();
+ bool Create(int64 size)
+ {
+ Close();
- if(size<=0)
- return(false);
+ if(size<=0)
+ return(false);
- buf=(uint8 *)hgl_malloc(size);
+ buf=(uint8 *)hgl_malloc(size);
- if(!buf)
- return(false);
+ if(!buf)
+ return(false);
- one=true;
- cur_pos=0;
- buf_size=size;
- max_size=size;
+ one=true;
+ cur_pos=0;
+ buf_size=size;
+ max_size=size;
- return(true);
- }
+ return(true);
+ }
- void Close() override
- {
- if(buf)
- {
- if(one)
- hgl_free(buf);
+ void Close() override
+ {
+ if(buf)
+ {
+ if(one)
+ hgl_free(buf);
- buf=0;
- }
+ buf=0;
+ }
- buf_size=0;
- max_size=0;
- }
+ buf_size=0;
+ max_size=0;
+ }
- void ClearData()
- {
- cur_pos=0;
- buf_size=0;
- }
+ void ClearData()
+ {
+ cur_pos=0;
+ buf_size=0;
+ }
- int64 Write(const void *ptr,int64 size) override
- {
- if(!ptr||size<0)
- return(-1);
+ int64 Write(const void *ptr,int64 size) override
+ {
+ if(!ptr||size<0)
+ return(-1);
- if(!buf)
- {
- if(!Create(size))
- return(-1);
- }
+ if(!buf)
+ {
+ if(!Create(size))
+ return(-1);
+ }
- if(cur_pos+size>buf_size)
- {
- if(one)
- {
- buf_size=cur_pos+size;
+ if(cur_pos+size>buf_size)
+ {
+ if(one)
+ {
+ buf_size=cur_pos+size;
- if(buf_size>max_size)
- {
- max_size=power_to_2(buf_size);
+ if(buf_size>max_size)
+ {
+ max_size=power_to_2(buf_size);
- buf=(uint8 *)hgl_realloc(buf,max_size);
- }
- }
- else
- size=buf_size-cur_pos;
- }
+ buf=(uint8 *)hgl_realloc(buf,max_size);
+ }
+ }
+ else
+ size=buf_size-cur_pos;
+ }
- if(size<=0)
- return(0);
+ if(size<=0)
+ return(0);
- memcpy(buf+cur_pos,ptr,size);
+ memcpy(buf+cur_pos,ptr,size);
- cur_pos+=size;
+ cur_pos+=size;
- return size;
- }
+ return size;
+ }
- bool CanRestart()const override{return true;}
- bool CanSeek()const override{return true;}
- bool CanSize()const override{return true;}
+ bool CanRestart()const override{return true;}
+ bool CanSeek()const override{return true;}
+ bool CanSize()const override{return true;}
- bool Restart() override
- {
- cur_pos=0;
- return(true);
- }
+ bool Restart() override
+ {
+ cur_pos=0;
+ return(true);
+ }
- int64 Seek(int64 off,SeekOrigin so=soBegin) override
- {
- if(!CanSeek())return(-1);
+ int64 Seek(int64 off,SeekOrigin so=soBegin) override
+ {
+ if(!CanSeek())return(-1);
- if(so==soCurrent)
- {
- off+=cur_pos;
- }
- else
- if(so==soEnd)
- {
- off+=buf_size;
- }
+ if(so==soCurrent)
+ {
+ off+=cur_pos;
+ }
+ else
+ if(so==soEnd)
+ {
+ off+=buf_size;
+ }
- if(off<0||off>=buf_size)
- return(-1);
+ if(off<0||off>=buf_size)
+ return(-1);
- cur_pos=off;
- return cur_pos;
- }
+ cur_pos=off;
+ return cur_pos;
+ }
- int64 Tell()const override
- {
- return cur_pos;
- }
+ int64 Tell()const override
+ {
+ return cur_pos;
+ }
- int64 GetSize()const override
- {
- return buf_size;
- }
+ int64 GetSize()const override
+ {
+ return buf_size;
+ }
- int64 Available()const override
- {
- return buf_size-cur_pos;
- }
- };//class MemoryOutputStream
- }//namespace io
+ int64 Available()const override
+ {
+ return buf_size-cur_pos;
+ }
+ };//class MemoryOutputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_MEMORY_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/OutputStream.h b/inc/hgl/io/OutputStream.h
index b528851f..a0022836 100644
--- a/inc/hgl/io/OutputStream.h
+++ b/inc/hgl/io/OutputStream.h
@@ -5,32 +5,32 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 数据输出流基类
- */
- class OutputStream:public SeekAccess ///数据输出流基类
- {
- public:
+ namespace io
+ {
+ /**
+ * 数据输出流基类
+ */
+ class OutputStream:public SeekAccess ///数据输出流基类
+ {
+ public:
- virtual ~OutputStream()=default;
+ virtual ~OutputStream()=default;
- virtual void Close()=0; ///<关闭输出流
+ virtual void Close()=0; ///<关闭输出流
- virtual int64 Write(const void *,int64)=0; ///<写入数据
- virtual int64 WriteFully(const void *buf,int64 buf_size){return Write(buf,buf_size);} ///<充分写入,保证完整写入指定长度的数据
+ virtual int64 Write(const void *,int64)=0; ///<写入数据
+ virtual int64 WriteFully(const void *buf,int64 buf_size){return Write(buf,buf_size);} ///<充分写入,保证完整写入指定长度的数据
- virtual bool CanRestart()const=0; ///<是否可以复位
- virtual bool CanSeek()const=0; ///<是否可以定位
- virtual bool CanSize()const=0; ///<是否可以取得尺寸
+ virtual bool CanRestart()const=0; ///<是否可以复位
+ virtual bool CanSeek()const=0; ///<是否可以定位
+ virtual bool CanSize()const=0; ///<是否可以取得尺寸
- virtual bool Restart()=0; ///<复位访问指针
- virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
- virtual int64 Tell()const=0; ///<返回当前访问位置
- virtual int64 GetSize()const=0; ///<取得流长度
- virtual int64 Available()const=0; ///<剩下的可以不受阻塞写入的字节数
- };//class OutputStream
- }//namespace io
+ virtual bool Restart()=0; ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
+ virtual int64 Tell()const=0; ///<返回当前访问位置
+ virtual int64 GetSize()const=0; ///<取得流长度
+ virtual int64 Available()const=0; ///<剩下的可以不受阻塞写入的字节数
+ };//class OutputStream
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/io/RandomAccessFile.h b/inc/hgl/io/RandomAccessFile.h
index e395cd67..01f1e4ed 100644
--- a/inc/hgl/io/RandomAccessFile.h
+++ b/inc/hgl/io/RandomAccessFile.h
@@ -6,42 +6,42 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 随机文件访问
- * 可同时被DataInputStream/DataOutputStream包含引用,但需注意他们将共用一个访问指针
- */
- class RandomAccessFile:public InputStream,public OutputStream
- {
- protected:
+ namespace io
+ {
+ /**
+ * 随机文件访问
+ * 可同时被DataInputStream/DataOutputStream包含引用,但需注意他们将共用一个访问指针
+ */
+ class RandomAccessFile:public InputStream,public OutputStream
+ {
+ protected:
- SharedPtr file; ///<文件访问指针
+ SharedPtr file; ///<文件访问指针
- public:
+ public:
- RandomAccessFile();
- RandomAccessFile(SharedPtr &);
- ~RandomAccessFile();
+ RandomAccessFile();
+ RandomAccessFile(SharedPtr &);
+ ~RandomAccessFile();
- virtual bool Open(const OSString &); ///<打开文件
- virtual void Close(); ///<关闭文件
+ virtual bool Open(const OSString &); ///<打开文件
+ virtual void Close(); ///<关闭文件
- virtual int64 Read(void *,int64); ///<读取数据
- virtual int64 Write(const void *,int64); ///<写入数据
+ virtual int64 Read(void *,int64); ///<读取数据
+ virtual int64 Write(const void *,int64); ///<写入数据
- virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
- virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
+ virtual int64 Read(int64,void *,int64); ///<在指定位置读取指定长度的数据
+ virtual int64 Write(int64,const void *,int64); ///<在指定位置写入指定长度的数据
- virtual bool CanSeek()const; ///<是否可移动访问指针
- virtual bool CanRestart()const; ///<是否可复位访问
- virtual bool CanSize()const; ///<是否可访问文件长度
+ virtual bool CanSeek()const; ///<是否可移动访问指针
+ virtual bool CanRestart()const; ///<是否可复位访问
+ virtual bool CanSize()const; ///<是否可访问文件长度
- virtual int64 Tell()const; ///<取当前位置
- virtual int64 GetSize(); ///<取得文件长度
- virtual bool Restart(); ///<复位访问指针
- virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
- };//class RandomAccessFile
- }//namespace io
+ virtual int64 Tell()const; ///<取当前位置
+ virtual int64 GetSize(); ///<取得文件长度
+ virtual bool Restart(); ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin); ///<移动访问指针
+ };//class RandomAccessFile
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_RANDOM_ACCESS_FILE_INCLUDE
diff --git a/inc/hgl/io/SeekAccess.h b/inc/hgl/io/SeekAccess.h
index 0f33ca86..1db8198a 100644
--- a/inc/hgl/io/SeekAccess.h
+++ b/inc/hgl/io/SeekAccess.h
@@ -4,33 +4,33 @@
#include
namespace hgl
{
- namespace io
- {
- enum_int(SeekOrigin) /// 资源偏移方向枚举
- {
- soBegin=0, ///<从资源最开始处开始,offset必须大于0。移到资源的offset位置
- soCurrent, ///<从资源当前位置开始,移到资源的Position+offset位置
- soEnd ///<从资源的结束位置开始,offset必须小于0,表示结束前的字符数
- };//enum SeekOrigin
+ namespace io
+ {
+ enum_int(SeekOrigin) /// 资源偏移方向枚举
+ {
+ soBegin=0, ///<从资源最开始处开始,offset必须大于0。移到资源的offset位置
+ soCurrent, ///<从资源当前位置开始,移到资源的Position+offset位置
+ soEnd ///<从资源的结束位置开始,offset必须小于0,表示结束前的字符数
+ };//enum SeekOrigin
- /**
- * 定位访问功能基类
- */
- class SeekAccess
- {
- public:
+ /**
+ * 定位访问功能基类
+ */
+ class SeekAccess
+ {
+ public:
- virtual ~SeekAccess()=default;
+ virtual ~SeekAccess()=default;
- virtual bool CanRestart()const=0; ///<是否可以复位
- virtual bool CanSeek()const=0; ///<是否可以定位
- virtual bool CanSize()const=0; ///<是否可以取得尺寸
+ virtual bool CanRestart()const=0; ///<是否可以复位
+ virtual bool CanSeek()const=0; ///<是否可以定位
+ virtual bool CanSize()const=0; ///<是否可以取得尺寸
- virtual bool Restart()=0; ///<复位访问指针
- virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
- virtual int64 Tell()const=0; ///<返回当前访问位置
- virtual int64 GetSize()const=0; ///<取得文件长度
- };//class SeekAccess
- }//namespace io
+ virtual bool Restart()=0; ///<复位访问指针
+ virtual int64 Seek(int64,SeekOrigin=soBegin)=0; ///<移动访问指针
+ virtual int64 Tell()const=0; ///<返回当前访问位置
+ virtual int64 GetSize()const=0; ///<取得文件长度
+ };//class SeekAccess
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_SEEK_ACCESS_INCLUDE
diff --git a/inc/hgl/io/TextOutputStream.h b/inc/hgl/io/TextOutputStream.h
index 0d96beb7..0f01c5d9 100644
--- a/inc/hgl/io/TextOutputStream.h
+++ b/inc/hgl/io/TextOutputStream.h
@@ -5,172 +5,172 @@
#include
namespace hgl
{
- namespace io
- {
- /**
- * 文本输出流
- * 用于将数据输出成文件,用于日志、配置等文本信息处理。
- */
+ namespace io
+ {
+ /**
+ * 文本输出流
+ * 用于将数据输出成文件,用于日志、配置等文本信息处理。
+ */
class TextOutputStream
{
- protected:
+ protected:
- ByteOrderMask bom; ///<文本编码
- DataOutputStream *out; ///<数据输出流
+ ByteOrderMask bom; ///<文本编码
+ DataOutputStream *out; ///<数据输出流
- public:
+ public:
- TextOutputStream(ByteOrderMask _bom,DataOutputStream *_out)
+ TextOutputStream(ByteOrderMask _bom,DataOutputStream *_out)
{
bom=_bom;
out=_out;
}
- virtual ~TextOutputStream()
- {
- delete out;
- }
+ virtual ~TextOutputStream()
+ {
+ delete out;
+ }
- const ByteOrderMask GetBOM()const
- {
- return bom;
- }
+ const ByteOrderMask GetBOM()const
+ {
+ return bom;
+ }
- DataOutputStream *GetDataOutputStream()
- {
- return out;
- }
+ DataOutputStream *GetDataOutputStream()
+ {
+ return out;
+ }
- operator DataOutputStream *()
- {
- return out;
- }
+ operator DataOutputStream *()
+ {
+ return out;
+ }
- bool WriteBOM() ///<写入文本文件bom头
- {
- if(!out)return(false);
+ bool WriteBOM() ///<写入文本文件bom头
+ {
+ if(!out)return(false);
- const BOMFileHeader *bom_item=BOMData+bom;
+ const BOMFileHeader *bom_item=BOMData+bom;
- return(out->Write(bom_item->data,bom_item->size)==bom_item->size);
- }
+ return(out->Write(bom_item->data,bom_item->size)==bom_item->size);
+ }
- virtual bool WriteChars(const char *,int64)=0; ///<写入一个字符串
- virtual bool WriteChars(const u16char *,int64)=0; ///<写入一个字符串
+ virtual bool WriteChars(const char *,int64)=0; ///<写入一个字符串
+ virtual bool WriteChars(const u16char *,int64)=0; ///<写入一个字符串
- template
- bool WriteString(const BaseString &str) ///<写入一个字符串
- {
- return WriteChars(str.c_str(),str.Length());
- }
+ template
+ bool WriteString(const BaseString &str) ///<写入一个字符串
+ {
+ return WriteChars(str.c_str(),str.Length());
+ }
- bool WriteLineEnd() ///<写入一个换行符
- {
- return WriteChars(HGL_LINE_END,HGL_LINE_END_SIZE);
- }
+ bool WriteLineEnd() ///<写入一个换行符
+ {
+ return WriteChars(HGL_LINE_END,HGL_LINE_END_SIZE);
+ }
- template
- bool WriteLine(const N *str,int64 size)
- {
- if(!WriteChars(str,size))
- return(false);
+ template
+ bool WriteLine(const N *str,int64 size)
+ {
+ if(!WriteChars(str,size))
+ return(false);
- return WriteLineEnd();
- }
+ return WriteLineEnd();
+ }
- template
- bool WriteLine(const BaseString &str)
- {
- return WriteLine(str.c_str(),str.Length());
- }
+ template
+ bool WriteLine(const BaseString &str)
+ {
+ return WriteLine(str.c_str(),str.Length());
+ }
- /**
- * 向流中写入一个文本(注:整体按标准文本文件模式)
- */
- template
- bool WriteText(const StringList &sl)
- {
- const int count=sl.GetCount();
+ /**
+ * 向流中写入一个文本(注:整体按标准文本文件模式)
+ */
+ template
+ bool WriteText(const StringList &sl)
+ {
+ const int count=sl.GetCount();
- for(int i=0;i
- bool Write(const StringList &sl)
- {
- const int count=sl.GetCount();
+ /**
+ * 向流中写入一个字符串列表(注:整体为2进制流,不可用于文本文件)
+ * @return 是否成功
+ */
+ template
+ bool Write(const StringList &sl)
+ {
+ const int count=sl.GetCount();
- if(!out->WriteInt32(count)) //写入行数
- return(false);
+ if(!out->WriteInt32(count)) //写入行数
+ return(false);
- if(count<=0)
- return(true);
+ if(count<=0)
+ return(true);
- SharedArray line_length=new int32[count];
- SharedArray str_list=new T *[count];
- int32 *line_p=line_length;
- T **str_p=str_list;
+ SharedArray line_length=new int32[count];
+ SharedArray str_list=new T *[count];
+ int32 *line_p=line_length;
+ T **str_p=str_list;
- int32 total=0;
+ int32 total=0;
- for(int i=0;i &str=sl[i];
+ for(int i=0;i &str=sl[i];
- const int len=str.Length();
+ const int len=str.Length();
- total+=len;
+ total+=len;
- *line_p++=len;
+ *line_p++=len;
- *str_list++=str.c_str();
- }
+ *str_list++=str.c_str();
+ }
- if(out->WriteInt32(line_length,count)!=count) //写入每行长度
- return(false);
+ if(out->WriteInt32(line_length,count)!=count) //写入每行长度
+ return(false);
- line_p=line_length;
- str_p=str_list;
+ line_p=line_length;
+ str_p=str_list;
- SharedArray text=new T[total];
- T *text_p=text;
+ SharedArray text=new T[total];
+ T *text_p=text;
- for(int i=0;i class EndianTextOutputStream:public TextOutputStream ///文本输出流
- {
+ template class EndianTextOutputStream:public TextOutputStream ///文本输出流
+ {
public:
EndianTextOutputStream(OutputStream *);
- bool WriteChars(const char *,int64); ///<写入一个字符串
- bool WriteChars(const u16char *,int64); ///<写入一个字符串
- };//template class EndianTextOutputStream
+ bool WriteChars(const char *,int64); ///<写入一个字符串
+ bool WriteChars(const u16char *,int64); ///<写入一个字符串
+ };//template class EndianTextOutputStream
- typedef EndianTextOutputStream UTF8TextOutputStream;
+ typedef EndianTextOutputStream UTF8TextOutputStream;
typedef EndianTextOutputStream UTF16LETextOutputStream;
typedef EndianTextOutputStream UTF16BETextOutputStream;
template TextOutputStream *CreateTextOutputStream(OutputStream *os);
- }//namespace io
+ }//namespace io
}//namespace hgl
#endif//HGL_IO_TEXT_OUTPUT_STREAM_INCLUDE
diff --git a/inc/hgl/platform/ExternalModule.h b/inc/hgl/platform/ExternalModule.h
index bb3e85e0..97463bfb 100644
--- a/inc/hgl/platform/ExternalModule.h
+++ b/inc/hgl/platform/ExternalModule.h
@@ -6,31 +6,31 @@
#include OS_EXTERNAL_H
namespace hgl
{
- /**
- * 这个类用于对外部动态库的调用,支持Windows/Linux/BSD/MacOSX
- * Windows 下动态库扩展名为.DLL
- * FreeBSD/MacOSX 下动态库扩展名为.dylib
- * Linux 下动态库扩展名为.so
- */
- class ExternalModule ///外部模块调用类
- {
- ExternalModulePointer fp;
+ /**
+ * 这个类用于对外部动态库的调用,支持Windows/Linux/BSD/MacOSX
+ * Windows 下动态库扩展名为.DLL
+ * FreeBSD/MacOSX 下动态库扩展名为.dylib
+ * Linux 下动态库扩展名为.so
+ */
+ class ExternalModule ///外部模块调用类
+ {
+ ExternalModulePointer fp;
- public: //方法
+ public: //方法
- ExternalModule(); ///<本类构造函数
- ExternalModule(ExternalModulePointer); ///<本类构造函数
- virtual ~ExternalModule(); ///<本类析构函数
+ ExternalModule(); ///<本类构造函数
+ ExternalModule(ExternalModulePointer); ///<本类构造函数
+ virtual ~ExternalModule(); ///<本类析构函数
- bool Load(const os_char *); ///<加载一个外部模块
- void Clear(); ///<清除当前模块
+ bool Load(const os_char *); ///<加载一个外部模块
+ void Clear(); ///<清除当前模块
- void *FindFunc(const char *); ///<查找函数
- void *GetFunc(const char *); ///<取得函数
+ void *FindFunc(const char *); ///<查找函数
+ void *GetFunc(const char *); ///<取得函数
- int Get(FuncLoad *); ///<加载函数列表
- };//class ExternalModule
+ int Get(FuncLoad *); ///<加载函数列表
+ };//class ExternalModule
- ExternalModule *LoadExternalModule(const os_char *); ///<加载一个外部模块
+ ExternalModule *LoadExternalModule(const os_char *); ///<加载一个外部模块
}//namespace hgl
#endif//HGL_EXTERNAL_MODULE_INCLUDE
diff --git a/inc/hgl/platform/FuncLoad.h b/inc/hgl/platform/FuncLoad.h
index 19777517..8686ee8c 100644
--- a/inc/hgl/platform/FuncLoad.h
+++ b/inc/hgl/platform/FuncLoad.h
@@ -3,29 +3,29 @@
namespace hgl
{
- /**
- * 函数加载定义数据结构
- */
- struct FuncLoad
- {
- char func_name[64]; ///<函数名称
- void **func_pointer; ///<函数指针
- };//struct FuncLoad
+ /**
+ * 函数加载定义数据结构
+ */
+ struct FuncLoad
+ {
+ char func_name[64]; ///<函数名称
+ void **func_pointer; ///<函数指针
+ };//struct FuncLoad
- #define HGL_FUNC_LOAD_LIST_BEGIN(name) struct FuncLoad name[]={
- #define HGL_FUNC_LOAD(name) {#name,(void **)&name},
- #define HGL_FUNC_LOAD_LIST_END {"",(void **)0}};
+ #define HGL_FUNC_LOAD_LIST_BEGIN(name) struct FuncLoad name[]={
+ #define HGL_FUNC_LOAD(name) {#name,(void **)&name},
+ #define HGL_FUNC_LOAD_LIST_END {"",(void **)0}};
- inline void ClearFuncLoadPointer(struct FuncLoad *flp)
- {
- if(!flp)return;
+ inline void ClearFuncLoadPointer(struct FuncLoad *flp)
+ {
+ if(!flp)return;
- while(flp->func_pointer)
- {
- flp->func_pointer=(void **)0;
+ while(flp->func_pointer)
+ {
+ flp->func_pointer=(void **)0;
- ++flp;
- }
- }
+ ++flp;
+ }
+ }
}//namespace hgl
#endif//HGL_FUNC_LOAD_INCLUDE
diff --git a/inc/hgl/platform/InputDevice.h b/inc/hgl/platform/InputDevice.h
index c645d668..553f5842 100644
--- a/inc/hgl/platform/InputDevice.h
+++ b/inc/hgl/platform/InputDevice.h
@@ -8,197 +8,197 @@ namespace hgl
*/
enum MouseButton
{
- mbMove =0x00000001, ///<鼠标移动了
+ mbMove =0x00000001, ///<鼠标移动了
- mbLeft =0x00000010, ///<鼠标左键处于按下状态
- mbMid =0x00000100, ///<鼠标中键处于按下状态
- mbRight =0x00001000, ///<鼠标右键处于按下状态
+ mbLeft =0x00000010, ///<鼠标左键处于按下状态
+ mbMid =0x00000100, ///<鼠标中键处于按下状态
+ mbRight =0x00001000, ///<鼠标右键处于按下状态
- mbShift =0x10000000, ///
+ #include
- #if HGL_COMPILER == HGL_COMPILER_Microsoft
- #include
- #elif HGL_COMPILER == HGL_COMPILER_Intel
- #include
- #elif HGL_COMPILER == HGL_COMPILER_IBM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_MINGW32
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif
+ #if HGL_COMPILER == HGL_COMPILER_Microsoft
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_Intel
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_IBM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_MINGW32
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif
#elif HGL_OS == HGL_OS_Cygwin
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_LLVM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif//GNU
+ #if HGL_COMPILER == HGL_COMPILER_LLVM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif//GNU
#elif (HGL_OS == HGL_OS_FreeBSD)||(HGL_OS == HGL_OS_NetBSD)||(HGL_OS == HGL_OS_OpenBSD)
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_LLVM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif//GNU
+ #if HGL_COMPILER == HGL_COMPILER_LLVM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif//GNU
#elif HGL_OS == HGL_OS_Linux
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_CBuilder
- #include
- #elif HGL_COMPILER == HGL_COMPILER_Intel
- #include
- #elif HGL_COMPILER == HGL_COMPILER_IBM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_Watcom
- #include
- #elif HGL_COMPILER == HGL_COMPILER_LLVM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif
+ #if HGL_COMPILER == HGL_COMPILER_CBuilder
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_Intel
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_IBM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_Watcom
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_LLVM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif
#elif HGL_OS == HGL_OS_macOS
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_Intel
- #include
- #elif HGL_COMPILER == HGL_COMPILER_LLVM
- #include
- #else
- #error Unrecognized compiler
- #endif
+ #if HGL_COMPILER == HGL_COMPILER_Intel
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_LLVM
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif
#elif HGL_OS == HGL_OS_iOS
- #include
- #include
+ #include
+ #include
#elif HGL_OS == HGL_OS_PSP2
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif
+ #if HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif
#elif HGL_OS == HGL_OS_AIX
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_IBM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_SGI
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif
+ #if HGL_COMPILER == HGL_COMPILER_IBM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_SGI
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif
#elif HGL_OS == HGL_OS_Android
- #include
+ #include
- #if HGL_COMPILER == HGL_COMPILER_LLVM
- #include
- #elif HGL_COMPILER == HGL_COMPILER_GNU
- #include
- #else
- #error Unrecognized compiler
- #endif//GNU
+ #if HGL_COMPILER == HGL_COMPILER_LLVM
+ #include
+ #elif HGL_COMPILER == HGL_COMPILER_GNU
+ #include
+ #else
+ #error Unrecognized compiler
+ #endif//GNU
#endif//HGL_OS
namespace hgl
diff --git a/inc/hgl/platform/SystemInfo.h b/inc/hgl/platform/SystemInfo.h
index 987efb99..ee72268b 100644
--- a/inc/hgl/platform/SystemInfo.h
+++ b/inc/hgl/platform/SystemInfo.h
@@ -43,9 +43,9 @@ namespace hgl
OSString mydata; ///<当前用户应用程序数据保存路径
OSString myprogram; ///<“我的程序”路径(Windows下为开始菜单程序路径,Mac下为应用程序路径)
OSString mydesktop; ///<“桌面”路径
-
+
OSString desktop; ///<所有用户桌面路径
-
+
OSString engine; ///<引擎所在路径
OSString plug_ins; ///<引擎插件路径
};//struct SystemPath
diff --git a/inc/hgl/platform/Window.h b/inc/hgl/platform/Window.h
index 9201efbe..4c56b2c8 100644
--- a/inc/hgl/platform/Window.h
+++ b/inc/hgl/platform/Window.h
@@ -38,8 +38,8 @@ namespace hgl
virtual void OnMouseDoubleClick (int,int,uint){}
//virtual void OnJoystickDown (uint){}
- //virtual void OnJoystickPress (uint){}
- //virtual void OnJoystickUp (uint){}
+ //virtual void OnJoystickPress (uint){}
+ //virtual void OnJoystickUp (uint){}
virtual void OnKeyDown (KeyboardButton);
virtual void OnKeyPress (KeyboardButton){}
@@ -85,7 +85,7 @@ namespace hgl
};//class Window
Window *CreateRenderWindow(const OSString &win_name);
-
+
void InitNativeWindowSystem();
}//namespace hgl
#endif//HGL_GRAPH_WINDOW_INCLUDE
diff --git a/inc/hgl/platform/compiler/DataTypeGNU.h b/inc/hgl/platform/compiler/DataTypeGNU.h
index de3df8d4..4fdd2c98 100644
--- a/inc/hgl/platform/compiler/DataTypeGNU.h
+++ b/inc/hgl/platform/compiler/DataTypeGNU.h
@@ -3,17 +3,17 @@
namespace hgl
{
- using int8 = signed char; ///<有符号 8位整型
- using uint8 =unsigned char; ///<无符号 8位整型
- using int16 = signed short; ///<有符号16位整型
- using uint16 =unsigned short; ///<无符号16位整型
- using int32 = signed int; ///<有符号32位整型
- using uint32 =unsigned int; ///<无符号32位整型
+ using int8 = signed char; ///<有符号 8位整型
+ using uint8 =unsigned char; ///<无符号 8位整型
+ using int16 = signed short; ///<有符号16位整型
+ using uint16 =unsigned short; ///<无符号16位整型
+ using int32 = signed int; ///<有符号32位整型
+ using uint32 =unsigned int; ///<无符号32位整型
- //64位系统下long/long long都是64位,32位系列下只有long long是64位
+ //64位系统下long/long long都是64位,32位系列下只有long long是64位
- using int64 = signed long long; ///<有符号64位整型
- using uint64 =unsigned long long; ///<无符号64位整型
+ using int64 = signed long long; ///<有符号64位整型
+ using uint64 =unsigned long long; ///<无符号64位整型
using float32 =float;
using float64 =double;
diff --git a/inc/hgl/platform/compiler/DataTypeTiny.h b/inc/hgl/platform/compiler/DataTypeTiny.h
index d3cc858e..2af4d18e 100644
--- a/inc/hgl/platform/compiler/DataTypeTiny.h
+++ b/inc/hgl/platform/compiler/DataTypeTiny.h
@@ -16,8 +16,8 @@ namespace hgl
using f32=float;
using f64=double;
- #define enum_int(name) enum name:int
- #define enum_uint(name) enum name:uint
+ #define enum_int(name) enum name:int
+ #define enum_uint(name) enum name:uint
using void_pointer=void *;
diff --git a/inc/hgl/platform/compiler/DataTypeWin.h b/inc/hgl/platform/compiler/DataTypeWin.h
index 75386460..166f94fa 100644
--- a/inc/hgl/platform/compiler/DataTypeWin.h
+++ b/inc/hgl/platform/compiler/DataTypeWin.h
@@ -2,14 +2,14 @@
#define HGL_DATATYPE_WINDOWS_INCLUDE
namespace hgl
{
- using int8 = signed __int8 ; ///<有符号 8位整型
- using uint8 =unsigned __int8 ; ///<无符号 8位整型
- using int16 = signed __int16; ///<有符号16位整型
- using uint16 =unsigned __int16; ///<无符号16位整型
- using int32 = signed __int32; ///<有符号32位整型
- using uint32 =unsigned __int32; ///<无符号32位整型
- using int64 = signed __int64; ///<有符号64位整型
- using uint64 =unsigned __int64; ///<无符号64位整型
+ using int8 = signed __int8 ; ///<有符号 8位整型
+ using uint8 =unsigned __int8 ; ///<无符号 8位整型
+ using int16 = signed __int16; ///<有符号16位整型
+ using uint16 =unsigned __int16; ///<无符号16位整型
+ using int32 = signed __int32; ///<有符号32位整型
+ using uint32 =unsigned __int32; ///<无符号32位整型
+ using int64 = signed __int64; ///<有符号64位整型
+ using uint64 =unsigned __int64; ///<无符号64位整型
using float32 =float;
using float64 =double;
diff --git a/inc/hgl/platform/compiler/EventFunc.h b/inc/hgl/platform/compiler/EventFunc.h
index 84aeaeee..3bb70e0b 100644
--- a/inc/hgl/platform/compiler/EventFunc.h
+++ b/inc/hgl/platform/compiler/EventFunc.h
@@ -5,40 +5,40 @@
#include
namespace hgl
{
- #ifdef __BORLANDC__
+ #ifdef __BORLANDC__
- #define SetEventCall(event_obj,obj_this,class_name,event_func) event_obj=obj_this->class_name::event_func
- #define SafeCallEvent(event_obj,intro) {if(event_obj)event_obj intro;}
- #define CallEvent(event_obj,intro) event_obj intro
- #define DefEvent(result,name,intro) result (__closure *name)intro
+ #define SetEventCall(event_obj,obj_this,class_name,event_func) event_obj=obj_this->class_name::event_func
+ #define SafeCallEvent(event_obj,intro) {if(event_obj)event_obj intro;}
+ #define CallEvent(event_obj,intro) event_obj intro
+ #define DefEvent(result,name,intro) result (__closure *name)intro
- #else
+ #else
- template struct EventFunc
- {
- typedef EventFunc