diff --git a/inc/hgl/CodePage.h b/inc/hgl/CodePage.h new file mode 100644 index 00000000..ef366f78 --- /dev/null +++ b/inc/hgl/CodePage.h @@ -0,0 +1,244 @@ +#ifndef HGL_CODE_PAGE_INCLUDE +#define HGL_CODE_PAGE_INCLUDE + +#include +#include +#include +namespace hgl +{ + struct CodePageAndCharSet + { + CharCodePage codepage; + CharSetName charset; + }; + + constexpr struct CodePageAndCharSet CodePage2CharSet[]= + { + {ccpNone, "us-ascii" }, + + {ccpGBK, "gbk" }, + {ccpBig5, "big5" }, + {ccpGB2312, "gb2312" }, + {ccpGB18030, "gb18030" }, + + {ccpShiftJIS, "shift-jis" }, + {ccpJISX, "iso-2022-jp" }, + + {ccpKorean, "ks_c_5601-1987"}, + + {ccpMacJanpan, "x-mac-japanese" }, + {ccpMacTraditionalChinese, "x-mac-chinesetrad" }, + {ccpMacSimplifiedChinese, "x-mac-chinesesimp" }, + + {ccpUTF7, "utf-7" }, + {ccpUTF8, "utf-8" }, + + {ccpUTF16LE, "utf-16le" }, + {ccpUTF16BE, "utf-16be" }, + {ccpUTF32LE, "utf-32le" }, + {ccpUTF32BE, "utf-32be" }, + };//const struct + + constexpr int CharSetCount=sizeof(CodePage2CharSet)/sizeof(CodePageAndCharSet); + + inline const char *FindCharSet(CharCodePage ccp) + { + for(int i=0;i(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); + + 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 char *str) + { + int wlen; + + u16char *ws=u8_to_u16(str,strlen(str),wlen); + + return UTF16String(ws,wlen,true); + } + + inline UTF8String to_u8(const u16char *wide_str,int length) + { + int ulen; + + char *us=u16_to_u8(wide_str,length,ulen); + + return UTF8String(us,ulen,true); + } + + 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);} + inline OSString ToOSString(const UTF8String &str){return to_u16(str.c_str(), (int)(str.Length()));} + + inline UTF8String ToUTF8String(const os_char *str){return to_u8(str,strlen(str));} + inline UTF8String ToUTF8String(const OSString &str){return to_u8(str);} +#else + inline OSString ToOSString(const char *str){return OSString(str);} + inline OSString ToOSString(const UTF8String &str){return str;} + + inline UTF8String ToUTF8String(const os_char *str){return UTF8String(str);} + inline UTF8String ToUTF8String(const OSString &str){return str;} +#endif// + + const BOMFileHeader *ParseBOM(const void *input); + + bool BOM2CharSet(CharSet *cs,const BOMFileHeader *bom); +}//namespace hgl +#endif//HGL_CODE_PAGE_INCLUDE diff --git a/inc/hgl/LogInfo.h b/inc/hgl/LogInfo.h new file mode 100644 index 00000000..7609e319 --- /dev/null +++ b/inc/hgl/LogInfo.h @@ -0,0 +1,54 @@ +#ifndef HGL_LOGINFO_INCLUDE +#define HGL_LOGINFO_INCLUDE + +#include +#include +namespace hgl +{ + namespace logger + { + enum LogLevel + { + llError=0, //错误,肯定出对话框 + llProblem, //问题,默认出对话框 + llHint, //提示,不重要,debug状态默认出对话框 + llLog //记录一下 + };//enum LogLevel + + 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) + { + 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 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 IF_FALSE_RETURN(str) if(!str)RETURN_FALSE; + }//namespace logger + + using namespace logger; +}//namespace hgl +#endif//HGL_LOGINFO_INCLUDE diff --git a/inc/hgl/graph/RenderPass.h b/inc/hgl/graph/RenderPass.h new file mode 100644 index 00000000..24165371 --- /dev/null +++ b/inc/hgl/graph/RenderPass.h @@ -0,0 +1,20 @@ +#ifndef HGL_GRAPH_RENDER_PASS_INCLUDE +#define HGL_GRAPH_RENDER_PASS_INCLUDE + +namespace hgl +{ + namespace graph + { + /** + * 单次渲染处理 + */ + class RenderPass + { + public: + + + };//class RenderPass + }//namespace graph +}//namespace hgl +#endif//HGL_GRAPH_RENDER_PASS_INCLUDE +