diff options
author | Shocker <shocker@freakz.ro> | 2011-04-29 22:24:26 +0300 |
---|---|---|
committer | Shocker <shocker@freakz.ro> | 2011-04-29 22:24:26 +0300 |
commit | 0fb8f057974cdf3107084be65005956efb5191dc (patch) | |
tree | 8fe211ecee643625c01ec3970038e345ec44c5f0 /src/server/shared/Utilities | |
parent | f96e1ce1d7b10074750da761ff9b219a24d0f09f (diff) | |
parent | 1b1d7507f1c3ea768f3fdaf4e1729b66fe590a68 (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore
Diffstat (limited to 'src/server/shared/Utilities')
-rwxr-xr-x | src/server/shared/Utilities/Util.cpp | 76 | ||||
-rwxr-xr-x | src/server/shared/Utilities/Util.h | 18 |
2 files changed, 47 insertions, 47 deletions
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 2c72a1be8a1..47e91fbfa7d 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -147,7 +147,7 @@ void stripLineInvisibleChars(std::string &str) } if(wpos < str.size()) - str.erase(wpos,str.size()); + str.erase(wpos, str.size()); if(str.find("|TInterface")!=std::string::npos) str.clear(); @@ -218,7 +218,7 @@ std::string TimeToTimestampStr(time_t t) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) char buf[20]; - snprintf(buf,20,"%04d-%02d-%02d_%02d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm->tm_year+1900, aTm->tm_mon+1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); return std::string(buf); } @@ -229,7 +229,7 @@ bool IsIPAddress(char const* ipaddress) return false; // Let the big boys do it. - // Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD) + // Drawback: all valid ip address formats are recognized e.g.: 12.23, 121234, 0xABCD) return inet_addr(ipaddress) != INADDR_NONE; } @@ -256,7 +256,7 @@ size_t utf8length(std::string& utf8str) { try { - return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + return utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); } catch(std::exception) { @@ -265,19 +265,19 @@ size_t utf8length(std::string& utf8str) } } -void utf8truncate(std::string& utf8str,size_t len) +void utf8truncate(std::string& utf8str, size_t len) { try { - size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); if(wlen <= len) return; std::wstring wstr; wstr.resize(wlen); - utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); + utf8::utf8to16(utf8str.c_str(), utf8str.c_str()+utf8str.size(), &wstr[0]); wstr.resize(len); - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str[0]); + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str()+wstr.size(), &utf8str[0]); utf8str.resize(oend-(&utf8str[0])); // remove unused tail } catch(std::exception) @@ -290,7 +290,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) { try { - size_t len = utf8::distance(utf8str,utf8str+csize); + size_t len = utf8::distance(utf8str, utf8str+csize); if(len > wsize) { if(wsize > 0) @@ -300,7 +300,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) } wsize = len; - utf8::utf8to16(utf8str,utf8str+csize,wstr); + utf8::utf8to16(utf8str, utf8str+csize, wstr); wstr[len] = L'\0'; } catch(std::exception) @@ -318,11 +318,11 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr) { try { - size_t len = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t len = utf8::distance(utf8str.c_str(), utf8str.c_str()+utf8str.size()); wstr.resize(len); if (len) - utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); + utf8::utf8to16(utf8str.c_str(), utf8str.c_str()+utf8str.size(), &wstr[0]); } catch(std::exception) { @@ -342,7 +342,7 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str) if (size) { - char* oend = utf8::utf16to8(wstr,wstr+size,&utf8str2[0]); + char* oend = utf8::utf16to8(wstr, wstr+size, &utf8str2[0]); utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail } utf8str = utf8str2; @@ -365,7 +365,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str) if (wstr.size()) { - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str2[0]); + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str()+wstr.size(), &utf8str2[0]); utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail } utf8str = utf8str2; @@ -389,22 +389,22 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) - static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430),wchar_t(0x0000)}; - static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E),wchar_t(0x0000)}; - static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F),wchar_t(0x0000)}; - static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435),wchar_t(0x0000)}; - static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438),wchar_t(0x0000)}; - static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B),wchar_t(0x0000)}; - static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443),wchar_t(0x0000)}; - static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E),wchar_t(0x0000)}; - static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C),wchar_t(0x0000)}; - static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439),wchar_t(0x0000)}; + static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430), wchar_t(0x0000)}; + static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E), wchar_t(0x0000)}; + static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F), wchar_t(0x0000)}; + static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435), wchar_t(0x0000)}; + static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438), wchar_t(0x0000)}; + static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B), wchar_t(0x0000)}; + static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443), wchar_t(0x0000)}; + static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E), wchar_t(0x0000)}; + static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C), wchar_t(0x0000)}; + static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439), wchar_t(0x0000)}; static wchar_t const* const dropEnds[6][8] = { { &a_End[1], &o_End[1], &ya_End[1], &ie_End[1], &soft_End[1], &j_End[1], NULL, NULL }, @@ -419,8 +419,8 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) { size_t len = size_t((*itr)[-1]); // get length from string size field - if(wname.substr(wname.size()-len,len)==*itr) - return wname.substr(0,wname.size()-len); + if(wname.substr(wname.size()-len, len)==*itr) + return wname.substr(0, wname.size()-len); } return wname; @@ -430,11 +430,11 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; - if(!Utf8toWStr(utf8str,wstr)) + if(!Utf8toWStr(utf8str, wstr)) return false; conStr.resize(wstr.size()); - CharToOemBuffW(&wstr[0],&conStr[0],wstr.size()); + CharToOemBuffW(&wstr[0], &conStr[0], wstr.size()); #else // not implemented yet conStr = utf8str; @@ -443,14 +443,14 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) return true; } -bool consoleToUtf8(const std::string& conStr,std::string& utf8str) +bool consoleToUtf8(const std::string& conStr, std::string& utf8str) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; wstr.resize(conStr.size()); - OemToCharBuffW(&conStr[0],&wstr[0],conStr.size()); + OemToCharBuffW(&conStr[0], &wstr[0], conStr.size()); - return WStrToUtf8(wstr,utf8str); + return WStrToUtf8(wstr, utf8str); #else // not implemented yet utf8str = conStr; @@ -462,7 +462,7 @@ bool Utf8FitTo(const std::string& str, std::wstring search) { std::wstring temp; - if(!Utf8toWStr(str,temp)) + if(!Utf8toWStr(str, temp)) return false; // converting to lower case diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 2e5d9a12ad7..5ace48ee7be 100755 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -184,7 +184,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str); bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str); size_t utf8length(std::string& utf8str); // set string to "" if invalid utf8 sequence -void utf8truncate(std::string& utf8str,size_t len); +void utf8truncate(std::string& utf8str, size_t len); inline bool isBasicLatinCharacter(wchar_t wchar) { @@ -366,7 +366,7 @@ inline void wstrToLower(std::wstring& str) std::wstring GetMainPartOfName(std::wstring wname, uint32 declension); bool utf8ToConsole(const std::string& utf8str, std::string& conStr); -bool consoleToUtf8(const std::string& conStr,std::string& utf8str); +bool consoleToUtf8(const std::string& conStr, std::string& utf8str); bool Utf8FitTo(const std::string& str, std::wstring search); void utf8printf(FILE *out, const char *str, ...); void vutf8printf(FILE *out, const char *str, va_list* ap); @@ -423,7 +423,7 @@ class flag96 private: uint32 part[3]; public: - flag96(uint32 p1=0,uint32 p2=0,uint32 p3=0) + flag96(uint32 p1=0, uint32 p2=0, uint32 p3=0) { part[0]=p1; part[1]=p2; @@ -537,14 +537,14 @@ public: template<class type> inline flag96 operator & (type & right) { - flag96 ret(part[0] & right.part[0],part[1] & right.part[1],part[2] & right.part[2]); + flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]); return ret; }; template<class type> inline flag96 operator & (type & right) const { - flag96 ret(part[0] & right.part[0],part[1] & right.part[1],part[2] & right.part[2]); + flag96 ret(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]); return ret; }; @@ -558,7 +558,7 @@ public: template<class type> inline flag96 operator | (type & right) { - flag96 ret(part[0] | right.part[0],part[1] | right.part[1],part[2] | right.part[2]); + flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]); return ret; }; @@ -566,7 +566,7 @@ public: template<class type> inline flag96 operator | (type & right) const { - flag96 ret(part[0] | right.part[0],part[1] | right.part[1],part[2] | right.part[2]); + flag96 ret(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]); return ret; }; @@ -587,7 +587,7 @@ public: template<class type> inline flag96 operator ^ (type & right) { - flag96 ret(part[0] ^ right.part[0],part[1] ^ right.part[1],part[2] ^ right.part[2]); + flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]); return ret; }; @@ -595,7 +595,7 @@ public: template<class type> inline flag96 operator ^ (type & right) const { - flag96 ret(part[0] ^ right.part[0],part[1] ^ right.part[1],part[2] ^ right.part[2]); + flag96 ret(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]); return ret; }; |