diff --git a/inc/hgl/CodePage.h b/inc/hgl/CodePage.h index e8fb81f..7e79e70 100644 --- a/inc/hgl/CodePage.h +++ b/inc/hgl/CodePage.h @@ -7,52 +7,59 @@ namespace hgl { struct CodePageAndCharSet { - CharCodePage codepage; + uint16 codepage; CharSetName charset; }; - + + #define HGL_CODE_PAGE_AND_CHAR_SET(codepage,charset) {uint16(CharCodePage::codepage),charset} + constexpr struct CodePageAndCharSet CodePage2CharSet[]= { - {CharCodePage::NONE, "us-ascii" }, - {CharCodePage::GBK, "gbk" }, - {CharCodePage::Big5, "big5" }, - {CharCodePage::GB2312, "gb2312" }, - {CharCodePage::GB18030, "gb18030" }, + HGL_CODE_PAGE_AND_CHAR_SET(NONE, "us-ascii" ), + HGL_CODE_PAGE_AND_CHAR_SET(IBM437, "IBM437" ), - {CharCodePage::ShiftJIS, "shift-jis" }, - {CharCodePage::JISX, "iso-2022-jp" }, + HGL_CODE_PAGE_AND_CHAR_SET(GBK, "gbk" ), + HGL_CODE_PAGE_AND_CHAR_SET(Big5, "big5" ), + HGL_CODE_PAGE_AND_CHAR_SET(GB2312, "gb2312" ), + HGL_CODE_PAGE_AND_CHAR_SET(GB18030, "gb18030" ), + + HGL_CODE_PAGE_AND_CHAR_SET(ShiftJIS, "shift-jis" ), + HGL_CODE_PAGE_AND_CHAR_SET(EUC_JP, "EUC-JP" ), + HGL_CODE_PAGE_AND_CHAR_SET(ISO2022JP, "iso-2022-jp" ), + HGL_CODE_PAGE_AND_CHAR_SET(csISO2022JP, "csISO2022JP" ), + HGL_CODE_PAGE_AND_CHAR_SET(JISX, "iso-2022-jp" ), - {CharCodePage::Korean, "ks_c_5601-1987"}, + HGL_CODE_PAGE_AND_CHAR_SET(Korean, "ks_c_5601-1987"), - {CharCodePage::MacJanpan, "x-mac-japanese" }, - {CharCodePage::MacTraditionalChinese, "x-mac-chinesetrad" }, - {CharCodePage::MacSimplifiedChinese, "x-mac-chinesesimp" }, + HGL_CODE_PAGE_AND_CHAR_SET(MacJanpan, "x-mac-japanese" ), + HGL_CODE_PAGE_AND_CHAR_SET(MacTraditionalChinese, "x-mac-chinesetrad" ), + HGL_CODE_PAGE_AND_CHAR_SET(MacSimplifiedChinese, "x-mac-chinesesimp" ), - {CharCodePage::ISO_8859_1, "iso-8859-1"}, - {CharCodePage::ISO_8859_2, "iso-8859-2"}, - {CharCodePage::ISO_8859_3, "iso-8859-3"}, - {CharCodePage::ISO_8859_4, "iso-8859-4"}, - {CharCodePage::ISO_8859_5, "iso-8859-5"}, - {CharCodePage::ISO_8859_6, "iso-8859-6"}, - {CharCodePage::ISO_8859_7, "iso-8859-7"}, - {CharCodePage::ISO_8859_8, "iso-8859-8"}, - {CharCodePage::ISO_8859_9, "iso-8859-9"}, - {CharCodePage::ISO_8859_13, "iso-8859-13"}, - {CharCodePage::ISO_8859_15, "iso-8859-15"}, + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_1, "iso-8859-1"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_2, "iso-8859-2"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_3, "iso-8859-3"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_4, "iso-8859-4"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_5, "iso-8859-5"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_6, "iso-8859-6"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_7, "iso-8859-7"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_8, "iso-8859-8"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_9, "iso-8859-9"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_13, "iso-8859-13"), + HGL_CODE_PAGE_AND_CHAR_SET(ISO_8859_15, "iso-8859-15"), - {CharCodePage::UTF7, "utf-7" }, - {CharCodePage::UTF8, "utf-8" }, + HGL_CODE_PAGE_AND_CHAR_SET(UTF7, "utf-7" ), + HGL_CODE_PAGE_AND_CHAR_SET(UTF8, "utf-8" ), - {CharCodePage::UTF16LE, "utf-16le" }, - {CharCodePage::UTF16BE, "utf-16be" }, - {CharCodePage::UTF32LE, "utf-32le" }, - {CharCodePage::UTF32BE, "utf-32be" }, + HGL_CODE_PAGE_AND_CHAR_SET(UTF16LE, "utf-16le" ), + HGL_CODE_PAGE_AND_CHAR_SET(UTF16BE, "utf-16be" ), + HGL_CODE_PAGE_AND_CHAR_SET(UTF32LE, "utf-32le" ), + HGL_CODE_PAGE_AND_CHAR_SET(UTF32BE, "utf-32be" ), };//const struct constexpr int CharSetCount=sizeof(CodePage2CharSet)/sizeof(CodePageAndCharSet); - inline const char *FindCharSet(CharCodePage ccp) + inline const char *FindCharSet(uint16 ccp) { for(int i=0;i namespace hgl { - #define HGL_OFFICAL_WEB "www.hyzgame.com" - #define HGL_OFFICAL_WEB_U8 u8"www.hyzgame.com" - #define HGL_OFFICAL_WEB_URL "http://www.hyzgame.com" - #define HGL_OFFICAL_WEB_URL_u8 u8"http://www.hyzgame.com" + #define HGL_OFFICAL_WEB "www.hyzgame.com" + #define HGL_OFFICAL_WEB_U8 U8_TEXT("www.hyzgame.com") + #define HGL_OFFICAL_WEB_OS OS_TEXT("www.hyzgame.com") + #define HGL_OFFICAL_WEB_URL "http://www.hyzgame.com" + #define HGL_OFFICAL_WEB_URL_u8 U8_TEXT("http://www.hyzgame.com") + #define HGL_OFFICAL_WEB_URL_OS OS_TEXT("http://www.hyzgame.com") #define HGL_COPYRIGHT_STRING "(C)Copyright 2022 www.hyzgame.com" - #define HGL_COPYRIGHT_STRING_U8 u8"(C)Copyright 2022 www.hyzgame.com" + #define HGL_COPYRIGHT_STRING_U8 U8_TEXT("(C)Copyright 2022 www.hyzgame.com") #define HGL_COPYRIGHT_STRING_OS OS_TEXT("(C)Copyright 2022 www.hyzgame.com") #define ENUM_CLASS_RANGE(begin,end) BEGIN_RANGE=begin,END_RANGE=end,RANGE_SIZE=(END_RANGE-BEGIN_RANGE)+1 diff --git a/inc/hgl/URI.h b/inc/hgl/URI.h new file mode 100644 index 0000000..c60fb05 --- /dev/null +++ b/inc/hgl/URI.h @@ -0,0 +1,97 @@ +#ifndef HGL_URI_INCLUDE +#define HGL_URI_INCLUDE + +#include +namespace hgl +{ + const uint16 GetSchemePort(const char *scheme); + + /** + * 统一地址标识符类
+ *

注:此类只处理名称,与真实文件系统/网络系统没有任何相关操作

+ * + *

example 1: + * http:// www.hyzgame.com / index .php + * ------- --------------- ----- --- + * scheme path main_name ext_name + * + * scheme: http + * path: www.hyzgame.com + * main_name: index + * ext_name: php + *

+ * + *

example 2: + * file:// C:/windows/system32/1234.dll + * + * scheme: file + * driver: C + * path: Windows\System32 + * main_name: 1234 + * ext_name: dll + * fullname: C:\windows\system32\1234.dll + *

+ * + *

example 3: + * C:\windows\system32\1234.dll + * + * scheme: + * driver: C + * path: Windows\System32 + * main_name: 1234 + * ext_name: dll + * fullname: C:\windows\system32\1234.dll + *

+ */ + class URI + { + public: + + enum class SchemeType + { + Unknow=0, + LocalFile, ///<本地文件系统 + ArachivesFile, ///<档案文件(压缩包/tar/ISO镜像之类) + Device, ///<设备虚拟文件 + Network, ///<网络 + }; + + protected: + + OSString origin_name; + + OSString scheme_name; ///<协议名称(如http,ftp之类) + SchemeType scheme_type; ///<协议 + + UTF8String network_host; ///<网络主机(IP或网址) + uint16 network_port; ///<网络协议默认端口 + + OSString fullname; ///<完整文件名 + + OSString path_name; ///<路径名 + OSString main_name; ///<主名称 + OSString ext_name; ///<文件扩展名 + + UTF8String url; + + public: + + URI(const OSString &); + URI(const OSString &scheme,const OSString &path,const OSString &filename); + ~URI()=default; + + const bool isFile(); + const bool isDevice(); + const bool isNetwork(); + + public: + + const OSString &path(); + const OSString &main(); + const OSString &ext(); + const OSString &full(); + + const UTF8String &URL(); + };//class Filename +}//namespace hgl +#endif//HGL_URI_INCLUDE diff --git a/inc/hgl/filesystem/Filename.h b/inc/hgl/filesystem/Filename.h index 4d065ad..1a41f14 100644 --- a/inc/hgl/filesystem/Filename.h +++ b/inc/hgl/filesystem/Filename.h @@ -2,6 +2,7 @@ #define HGL_FILESYSTEM_FILENAME_INCLUDE #include +#include /** * Maximum Path Length Limitation @@ -68,7 +69,7 @@ namespace hgl { int str_len[count]; - for(int i=0;i const T sum(const T *data,const int count) @@ -20,7 +20,7 @@ namespace hgl } /** - * һĺ + * 求一批数的合 */ template const R sum(const T *data,const int count) diff --git a/inc/hgl/type/Color.h b/inc/hgl/type/Color.h index 0d15cd5..728daae 100644 --- a/inc/hgl/type/Color.h +++ b/inc/hgl/type/Color.h @@ -9,15 +9,8 @@ namespace hgl #define DEF_RGB_U8_TO_F(r,g,b) {float(r)/255.0f,float(g)/255.0f,float(b)/255.0f} #define DEF_RGBA_U8_TO_F(r,g,b,a) {float(r)/255.0f,float(g)/255.0f,float(b)/255.0f,float(a)/255.0f} - inline constexpr uint8 RGB2Lum(const uint8 red,const uint8 green,const uint8 blue) - { - return float(red)*0.299+float(green)*0.587+float(blue)*0.114; - } - - inline constexpr float RGB2Lumf(const float red,const float green,const float blue) - { - return red*0.299+green*0.587+blue*0.114; - } + #define HEXColor3(value) (0x##value>>16),((0x##value&0xFF00)>>8),(0x##value&0xFF) + #define HEXColor3f(value) float(0x##value>>16)/255.0f,float((0x##value&0xFF00)>>8)/255.0f,float(0x##value&0xFF)/255.0f const Color3f GetSpectralColor(const double l); ///<根据光谱值获取对应的RGB值 diff --git a/inc/hgl/type/ColorSpace.h b/inc/hgl/type/ColorSpace.h index 46f7e63..409d618 100644 --- a/inc/hgl/type/ColorSpace.h +++ b/inc/hgl/type/ColorSpace.h @@ -2,96 +2,113 @@ #define HGL_COLOR_SPACE_INCLUDE #include -#include namespace hgl { - namespace graph + enum class ColorSpace { - enum class ColorSpace - { - Linear=0, - sRGB, - YCbCr, + Linear=0, + sRGB, + YCbCr, - ENUM_CLASS_RANGE(Linear,YCbCr) - };//enum class ColorSpace + ENUM_CLASS_RANGE(Linear,YCbCr) + };//enum class ColorSpace - constexpr double GAMMA =2.4f; - constexpr double INV_GAMMA =1.0f/GAMMA; - constexpr double SRGB_ALPHA =0.055f; + constexpr double GAMMA =2.4f; + constexpr double INV_GAMMA =1.0f/GAMMA; + constexpr double SRGB_ALPHA =0.055f; - template - inline constexpr T sRGB2Linear(const T &in) - { - if(in<=0.4045) - return (double)in/12.92; - else - return pow((double(in)+SRGB_ALPHA)/(1.0f+SRGB_ALPHA),GAMMA); - } + template + inline constexpr T sRGB2Linear(const T &in,const T &gamma=GAMMA,const T &srgb_alpha=SRGB_ALPHA) + { + if(in<=0.4045) + return (double)in/12.92; + else + return pow((double(in)+srgb_alpha)/(1.0f+srgb_alpha),gamma); + } - template - inline constexpr T Linear2sRGB(const T &in) - { - if(in<=0.0031308f) - return double(in)*12.92f; - else - return pow(double(in),INV_GAMMA)*(1.0f+SRGB_ALPHA)-SRGB_ALPHA; - } + template + inline constexpr T Linear2sRGB(const T &in,const T &inv_gamma=INV_GAMMA,const T &srgb_alpha=SRGB_ALPHA) + { + if(in<=0.0031308f) + return double(in)*12.92f; + else + return pow(double(in),inv_gamma)*(1.0f+srgb_alpha)-srgb_alpha; + } - template - inline constexpr T sRGB2LinearCheaper(const T &in) - { - return (T)pow(double(in),GAMMA); - } + template + inline constexpr T sRGB2LinearCheaper(const T &in,const T &gamma=GAMMA) + { + return (T)pow(double(in),gamma); + } - template - inline constexpr T Linear2sRGBCheaper(const T &in) - { - return (T)pow((double)in,INV_GAMMA); - } + template + inline constexpr T Linear2sRGBCheaper(const T &in,const T &inv_gamma=INV_GAMMA) + { + return (T)pow((double)in,inv_gamma); + } - template - inline constexpr T sRGB2LinearCheapest(const T &in) - { - return in*in; - } + template + inline constexpr T sRGB2LinearCheapest(const T &in) + { + return in*in; + } - template - inline void sRGB2LinearFast(T &x,T &y,T &z,const T &r,const T &g,const T &b) - { - x=0.4124f*r+0.3576f*g+0.1805f*b; - y=0.2126f*r+0.7152f*g+0.0722f*b; - z=0.0193f*r+0.1192f*g+0.9505f*b; - } + template + inline void sRGB2LinearFast(T &x,T &y,T &z,const T &r,const T &g,const T &b) + { + x=0.4124f*r+0.3576f*g+0.1805f*b; + y=0.2126f*r+0.7152f*g+0.0722f*b; + z=0.0193f*r+0.1192f*g+0.9505f*b; + } - template - inline void Linear2sRGBFast(T &r,T &g,T &b,const T &x,const T &y,const T &z) - { - r= 3.2406f*x-1.5373f*y-0.4986f*z; - g=-0.9689f*x+1.8758f*y+0.0416f*z; - b= 0.0557f*x-0.2040f*y+1.0570f*z; - } + template + inline void Linear2sRGBFast(T &r,T &g,T &b,const T &x,const T &y,const T &z) + { + r= 3.2406f*x-1.5373f*y-0.4986f*z; + g=-0.9689f*x+1.8758f*y+0.0416f*z; + b= 0.0557f*x-0.2040f*y+1.0570f*z; + } - template - inline constexpr T Clamp(const T &value,const T &min_value,const T &max_value) - { - if(valuemax_value)return max_value; + template + inline constexpr T Clamp(const T &value,const T &min_value,const T &max_value) + { + if(valuemax_value)return max_value; - return value; - } + return value; + } - template - inline constexpr T Clamp(const T &value) - { - return Clamp(value,T(0),T(1)); - } + template + inline constexpr T Clamp(const T &value) + { + return Clamp(value,T(0),T(1)); + } - template<> inline constexpr uint8 Clamp(const uint8 &value) - { - return Clamp(value,0,255); - } - }//namespace graph + template + inline constexpr T RGB2Lum(const T &r,const T &g,const T &b) + { + return 0.299f*r+0.587f*g+0.114f*b; + } + + template + inline constexpr T RGB2Cb(const T &r,const T &g,const T &b) + { + return -0.168736f*r-0.331264f*g+0.5f*b; + } + + template + inline constexpr T RGB2Cr(const T &r,const T &g,const T &b) + { + return 0.5f*r-0.418688f*g-0.081312f*b; + } + + template + inline void RGB2YCbCr(T &y,T &cb,T &cr,const T &r,const T &g,const T &b) + { + y =RGB2Lum(r,g,b); + cb=RGB2Cb(r,g,b); + cr=RGB2Cr(r,g,b); + } }//namespace hgl #endif//HGL_COLOR_SPACE_INCLUDE diff --git a/inc/hgl/type/MemBlock.h b/inc/hgl/type/MemBlock.h index 1f114bd..5dea4b6 100644 --- a/inc/hgl/type/MemBlock.h +++ b/inc/hgl/type/MemBlock.h @@ -165,7 +165,12 @@ namespace hgl T &operator[](int n) { - return buf+n; + return buf[n]; + } + + const T &operator[](int n)const + { + return buf[n]; } };//template class MemBlock diff --git a/inc/hgl/type/ObjectList.cpp b/inc/hgl/type/ObjectList.cpp index 0bd155f..d8b9f6b 100644 --- a/inc/hgl/type/ObjectList.cpp +++ b/inc/hgl/type/ObjectList.cpp @@ -251,7 +251,7 @@ namespace hgl if(!new_items) return(false); - items=new_items; + this->items=new_items; } return(true); diff --git a/inc/hgl/type/SortedSets.h b/inc/hgl/type/SortedSets.h index 7015167..e8561c0 100644 --- a/inc/hgl/type/SortedSets.h +++ b/inc/hgl/type/SortedSets.h @@ -15,7 +15,7 @@ namespace hgl List data_list; bool FindPos(const T &,int &)const; ///<查找数据如果插入后,会所在的位置,返回是否存在这个数据 - int FindPos(const T &flag)const{int pos;return FindPos(flag,pos)?return(pos):-1;} ///<查找数据如果插入后,会所在的位置 + int FindPos(const T &flag)const{int pos;return FindPos(flag,pos)?pos:-1;} ///<查找数据如果插入后,会所在的位置 public: //属性 diff --git a/inc/hgl/type/StdString.h b/inc/hgl/type/StdString.h index b72fd84..1a155e4 100644 --- a/inc/hgl/type/StdString.h +++ b/inc/hgl/type/StdString.h @@ -4,31 +4,61 @@ #include #include -#if HGL_OS == HGL_OS_Windows -inline hgl::OSString std_to_os(const std::string &str) +namespace hgl { - return hgl::to_u16((hgl::u8char *)str.c_str(),(int)(str.length())); -} + #if HGL_OS == HGL_OS_Windows + inline hgl::OSString ToOSString(const std::string &str) + { + return hgl::to_u16((hgl::u8char *)str.c_str(),(int)(str.length())); + } -inline std::string to_std(const hgl::OSString &str) -{ - hgl::UTF8String u8_str=hgl::to_u8(str); + inline hgl::OSString ToOSString(const std::wstring &str) + { + return hgl::OSString(str.c_str(),(int)str.length()); + } - return std::string((char *)u8_str.c_str(),str.Length()); -} -#else -inline hgl::OSString std_to_os(const std::string &str) -{ - return hgl::OSString(str.c_str(),str.size()); -} + inline hgl::UTF8String ToUTF8String(const std::wstring &str) + { + return hgl::to_u8(str.c_str(),(int)str.length()); + } -inline std::string to_std(const hgl::OSString &str) -{ - return std::string(str.c_str(),str.Length()); -} -#endif// + inline std::string ToStdString(const hgl::OSString &str) + { + hgl::UTF8String u8_str=hgl::to_u8(str); -inline hgl::UTF8String std_to_u8(const std::string &str) -{ - return hgl::UTF8String((hgl::u8char *)str.c_str(),int(str.size())); -} + return std::string((char *)u8_str.c_str(),str.Length()); + } + + inline std::wstring ToStdWString(const hgl::OSString &str) + { + return std::wstring(str.c_str(),str.Length()); + } + #else + inline hgl::OSString ToOSString(const std::string &str) + { + return hgl::OSString(str.c_str(),str.size()); + } + + inline hgl::OSString ToOSString(const std::wstring &str) + { + return hgl::to_u8(str.c_str(),str.size()); + } + + inline std::string ToStdString(const hgl::OSString &str) + { + return std::string(str.c_str(),str.Length()); + } + + inline std::wstring ToStdWString(const OSString &str) + { + hgl::WideString w_str=hgl::to_wide(str); + + return std::wstring(w_str.c_str(),w_str.Length()); + } + #endif// + + inline hgl::UTF8String ToUTF8String(const std::string &str) + { + return hgl::UTF8String((hgl::u8char *)str.c_str(),int(str.size())); + } +} \ No newline at end of file diff --git a/inc/hgl/type/String.h b/inc/hgl/type/String.h index 7792a3e..4399a44 100644 --- a/inc/hgl/type/String.h +++ b/inc/hgl/type/String.h @@ -44,7 +44,7 @@ namespace hgl } /** - * 根据一个C指针风格字符串设置当前字符串内容(传入的str需要delete[]) + * 根据一个C指针风格字符串设置当前字符串内容(传入的str会被复制一份,所以需要传入者自行delete[]) * @param str 字符串内容,在len<0的情况下,需以0为结尾 * @param len 字符串长度,如果str以0为结尾,可以为负值,将启用自动计算长度 */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a321b19..fe838bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,7 @@ file(GLOB TYPE_TEMPLATE_HEADER ${TYPE_INCLUDE_PATH}/*.h) SET(TYPE_SOURCE_FILES Type/Collection.cpp) -SOURCE_GROUP("DataType\\Collection" FILES ${TYPE_INCLUDE_PATH}/Collection.h +SOURCE_GROUP("DataType\\Collection" FILES ${TYPE_INCLUDE_PATH}/Collection.h ${COLLECTION_SOURCE}) SET(SYSTEM_INFO_SOURCE ${CORE_PLATFORM_INCLUDE_PATH}/SystemInfo.h @@ -145,12 +145,11 @@ SET(IO_SOURCE_FILES ${IO_BASE_FILES} SET(FILESYSTEM_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/filesystem) SET(FILESYSTEM_HEADER_FILES ${FILESYSTEM_INCLUDE_PATH}/EnumFile.h - ${FILESYSTEM_INCLUDE_PATH}/EnumVolume.h - ${FILESYSTEM_INCLUDE_PATH}/Filename.h - ${FILESYSTEM_INCLUDE_PATH}/FileSystem.h) + ${FILESYSTEM_INCLUDE_PATH}/EnumVolume.h + ${FILESYSTEM_INCLUDE_PATH}/FileSystem.h) SET(FILESYSTEM_SOURCE_FILES FileSystem/FileSystem.cpp - FileSystem/EnumFile.cpp) + FileSystem/EnumFile.cpp) SOURCE_GROUP("FileSystem" FILES ${FILESYSTEM_HEADER_FILES} ${FILESYSTEM_SOURCE_FILES}) diff --git a/src/Color/Color3f.cpp b/src/Color/Color3f.cpp index c0b1275..bc5b0b2 100644 --- a/src/Color/Color3f.cpp +++ b/src/Color/Color3f.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace hgl { void Color3f::Clamp() @@ -16,20 +17,20 @@ namespace hgl */ void Color3f::To(float nr,float ng,float nb,float pos) { - if(pos==0)return; - if(pos==1) + if(pos<=0)return; + if(pos>=1) { r=nr; g=ng; b=nb; return; } - + r+=(nr-r)*pos; g+=(ng-g)*pos; b+=(nb-b)*pos; } -//-------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------------------- void Color3f::Grey(float v1,float v2,float v3) { float lum=RGB2Lum(v1,v2,v3); diff --git a/src/Color/Color4f.cpp b/src/Color/Color4f.cpp index d14879d..889a0ee 100644 --- a/src/Color/Color4f.cpp +++ b/src/Color/Color4f.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace hgl { void Color4f::Clamp() @@ -17,8 +18,8 @@ namespace hgl */ void Color4f::To(float nr,float ng,float nb,float pos) { - if(pos==0)return; - if(pos==1) + if(pos<=0)return; + if(pos>=1) { r=nr; g=ng; diff --git a/src/Text/CodePage.cpp b/src/Text/CodePage.cpp index a2b1003..540e522 100644 --- a/src/Text/CodePage.cpp +++ b/src/Text/CodePage.cpp @@ -4,9 +4,9 @@ namespace hgl { CharSet DefaultCharSet(); - CharSet UTF8CharSet (CharCodePage::UTF8, utf8_charset ); - CharSet UTF16LECharSet (CharCodePage::UTF16LE,utf16le_charset ); - CharSet UTF16BECharSet (CharCodePage::UTF16BE,utf16be_charset ); + CharSet UTF8CharSet ((uint16)CharCodePage::UTF8, utf8_charset ); + CharSet UTF16LECharSet ((uint16)CharCodePage::UTF16LE,utf16le_charset ); + CharSet UTF16BECharSet ((uint16)CharCodePage::UTF16BE,utf16be_charset ); int u16_to_u8(u8char *dst,int dst_size,const u16char *src,const int src_size) { diff --git a/src/URI.cpp b/src/URI.cpp new file mode 100644 index 0000000..305e009 --- /dev/null +++ b/src/URI.cpp @@ -0,0 +1,89 @@ +#include + +namespace hgl +{ + namespace + { + // https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers + + struct SchemePort + { + uint16 port; + char scheme[16]; + }; + + const SchemePort SchemePortList[]= + { + {7, "echo"}, + {21, "ftp"}, + {22, "ssh"}, + {23, "telnet"}, + {25, "smtp"}, + {53, "dns"}, + {69, "tftp"}, + {80, "http"}, + {80, "ws"}, + {110, "pop3"}, + {119, "nntp"}, + {123, "ntp"}, + {143, "imap"}, + {161, "snmp"}, + {162, "snmptrap"}, + {194, "irc"}, + {199, "smux"}, + {389, "ldap"}, + {443, "https"}, + {443, "wss"}, + {445, "smb"}, + {465, "smtps"}, + {548, "afp"}, //Apple File Services + {554, "rtsp"}, + {636, "ldaps"}, + {853, "dnss"}, + {873, "rsync"}, + {993, "imaps"}, + {5060, "sip"}, + {5061, "sips"}, + {5222, "xmpp"} + }; + } + + const uint16 GetSchemePort(const char *scheme) + { + for(const SchemePort &sp:SchemePortList) + if(strcmp(scheme,sp.scheme)==0) + return sp.port; + + return 0; + } + + URI::URI(const OSString &fn) + { + origin_name=fn; + + scheme_type=SchemeType::Unknow; + } + + URI::URI(const OSString &scheme,const OSString &path,const OSString &filename) + { + scheme_name=scheme; + + if(scheme=="file") + scheme_type=SchemeType::LocalFile; + else + + } + + const bool URI::isFile() + { + if(scheme_type==SchemeType::Unknow) + { + + } + + if(scheme_type==SchemeType::LocalFile) + return(true); + + return(false); + } +}//namespace hgl