36 template<
typename T,
class S>
struct Finder
57 Tokenizer(
const std::string &src,
char const sep,
uint32 vectorReserve = 0);
60 const_iterator
begin()
const {
return m_storage.begin(); }
61 const_iterator
end()
const {
return m_storage.end(); }
63 size_type
size()
const {
return m_storage.size(); }
66 const_reference
operator [] (size_type i)
const {
return m_storage[i]; }
87 var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
91 template <
class T,
class U>
94 return T(base * static_cast<float>(pct) / 100.0f);
97 template <
class T,
class U>
103 template <
class T,
class U>
121 inline bool Utf8toWStr(
const std::string& utf8str,
wchar_t* wstr,
size_t& wsize)
123 return Utf8toWStr(utf8str.c_str(), utf8str.size(), wstr, wsize);
136 if (wchar >= L
'a' && wchar <= L
'z')
138 if (wchar >= L
'A' && wchar <= L
'Z')
147 if (wchar >= 0x00C0 && wchar <= 0x00D6)
149 if (wchar >= 0x00D8 && wchar <= 0x00DE)
153 if (wchar >= 0x00E0 && wchar <= 0x00F6)
155 if (wchar >= 0x00F8 && wchar <= 0x00FE)
157 if (wchar >= 0x0100 && wchar <= 0x012F)
166 if (wchar >= 0x0410 && wchar <= 0x044F)
168 if (wchar == 0x0401 || wchar == 0x0451)
175 if (wchar >= 0x1100 && wchar <= 0x11F9)
177 if (wchar >= 0x3041 && wchar <= 0x30FF)
179 if (wchar >= 0x3131 && wchar <= 0x318E)
181 if (wchar >= 0x31F0 && wchar <= 0x31FF)
183 if (wchar >= 0x3400 && wchar <= 0x4DB5)
185 if (wchar >= 0x4E00 && wchar <= 0x9FC3)
187 if (wchar >= 0xAC00 && wchar <= 0xD7A3)
189 if (wchar >= 0xFF01 && wchar <= 0xFFEE)
196 return (wchar >= L
'0' && wchar <=L
'9');
201 return (c >=
'0' && c <=
'9');
206 for (
char const* c = str; *c; ++c)
215 return isNumeric(wchar) || wchar == L
' ';
220 for (
size_t i = 0; i < wstr.size(); ++i)
228 for (
size_t i = 0; i < wstr.size(); ++i)
236 for (
size_t i = 0; i < wstr.size(); ++i)
244 for (
size_t i = 0; i < wstr.size(); ++i)
252 if (wchar >= L
'a' && wchar <= L
'z')
253 return wchar_t(
uint16(wchar)-0x0020);
255 return wchar_t(0x1E9E);
256 if (wchar >= 0x00E0 && wchar <= 0x00F6)
257 return wchar_t(
uint16(wchar)-0x0020);
258 if (wchar >= 0x00F8 && wchar <= 0x00FE)
259 return wchar_t(
uint16(wchar)-0x0020);
260 if (wchar >= 0x0101 && wchar <= 0x012F)
263 return wchar_t(
uint16(wchar)-0x0001);
265 if (wchar >= 0x0430 && wchar <= 0x044F)
266 return wchar_t(
uint16(wchar)-0x0020);
268 return wchar_t(0x0401);
280 if (wchar >= L
'A' && wchar <= L
'Z')
281 return wchar_t(
uint16(wchar)+0x0020);
282 if (wchar >= 0x00C0 && wchar <= 0x00D6)
283 return wchar_t(
uint16(wchar)+0x0020);
284 if (wchar >= 0x00D8 && wchar <= 0x00DE)
285 return wchar_t(
uint16(wchar)+0x0020);
286 if (wchar >= 0x0100 && wchar <= 0x012E)
289 return wchar_t(
uint16(wchar)+0x0001);
292 return wchar_t(0x00DF);
294 return wchar_t(0x0451);
295 if (wchar >= 0x0410 && wchar <= 0x042F)
296 return wchar_t(
uint16(wchar)+0x0020);
303 std::transform( str.begin(), str.end(), str.begin(),
wcharToUpper );
308 std::transform( str.begin(), str.end(), str.begin(),
wcharToLower );
331 template <
typename T>
350 return m_list.size();
354 return m_list.begin();
378 return (part[0] == p1 && part[1] == p2 && part[2] == p3 && part[3] == p4);
383 return (part[0] & p1 || part[1] & p2 || part[2] & p3 || part[3] & p4);
396 for (
uint8 i = 4; i > 0; --i)
398 if (part[i - 1] < right.
part[i - 1])
400 else if (part[i - 1] > right.
part[i - 1])
410 part[0] == right.
part[0] &&
411 part[1] == right.
part[1] &&
412 part[2] == right.
part[2] &&
413 part[3] == right.
part[3]
424 part[0] = right.
part[0];
425 part[1] = right.
part[1];
426 part[2] = right.
part[2];
427 part[3] = right.
part[3];
434 part[2] & right.
part[2], part[3] & right.
part[3]);
439 part[0] &= right.
part[0];
440 part[1] &= right.
part[1];
441 part[2] &= right.
part[2];
442 part[3] &= right.
part[3];
449 part[2] | right.
part[2], part[3] | right.
part[3]);
454 part[0] |= right.
part[0];
455 part[1] |= right.
part[1];
456 part[2] |= right.
part[2];
457 part[3] |= right.
part[3];
463 return flag128(~part[0], ~part[1], ~part[2], ~part[3]);
469 part[2] ^ right.
part[2], part[3] ^ right.
part[3]);
474 part[0] ^= right.
part[0];
475 part[1] ^= right.
part[1];
476 part[2] ^= right.
part[2];
477 part[3] ^= right.
part[3];
483 return (part[0] != 0 || part[1] != 0 || part[2] != 0 || part[3] != 0);
486 inline bool operator !()
const
488 return !this->
operator bool();
wchar_t wcharToUpperOnlyLatin(wchar_t wchar)
Definition: Util.h:273
uint32 part[4]
Definition: Util.h:365
TC_COMMON_API bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
TC_COMMON_API std::string ByteArrayToHexStr(uint8 const *bytes, uint32 length, bool reverse=false)
Definition: Util.cpp:509
static void var(TextOutput &t, const std::string &name, const std::string &val)
Definition: System.cpp:1582
TC_COMMON_API std::wstring GetMainPartOfName(std::wstring const &wname, uint32 declension)
Definition: Util.cpp:376
bool CompareValues(ComparisionType type, T val1, T val2)
Definition: Util.h:513
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:110
TC_COMMON_API int64 MoneyStringToMoney(const std::string &moneyString)
Definition: Util.cpp:132
bool operator()(const std::pair< int, S > &obj)
Definition: Util.h:42
TC_COMMON_API bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:498
TC_COMMON_API size_t utf8length(std::string &utf8str)
Definition: Util.cpp:247
StorageType::reference reference
Definition: Util.h:53
int64_t int64
Definition: Define.h:145
TC_COMMON_API void utf8printf(FILE *out, const char *str,...)
Definition: Util.cpp:469
bool isCyrillicCharacter(wchar_t wchar)
Definition: Util.h:164
T S::* idMember_
Definition: Util.h:39
char * m_str
Definition: Util.h:69
bool isExtendedLatinCharacter(wchar_t wchar)
Definition: Util.h:143
static Vector3int16 floor(const Vector3 &v)
TC_COMMON_API bool StringToBool(std::string const &str)
Definition: Util.cpp:558
UsedPosType operator~(UsedPosType uptype)
Definition: ObjectPosSelector.h:28
TC_COMMON_API void HexStrToByteArray(std::string const &str, uint8 *out, bool reverse=false)
Definition: Util.cpp:533
T ApplyPct(T &base, U pct)
Definition: Util.h:104
TC_COMMON_API bool consoleToUtf8(const std::string &conStr, std::string &utf8str)
Definition: Util.cpp:438
T val_
Definition: Util.h:38
bool isEastAsianCharacter(wchar_t wchar)
Definition: Util.h:173
bool operator<(const String &left, const String &right)
Definition: String.cpp:785
TC_COMMON_API bool WStrToUtf8(std::wstring const &wstr, std::string &utf8str)
Definition: Util.cpp:351
void apply(T *val)
Definition: ByteConverter.h:41
uint16_t uint16
Definition: g3dmath.h:166
void wstrToLower(std::wstring &str)
Definition: Util.h:306
StorageType m_storage
Definition: Util.h:70
T max(const T &x, const T &y)
Definition: g3dmath.h:320
#define bool
Definition: CascPort.h:16
std::list< T > m_list
Definition: Util.h:336
size_type size() const
Definition: Util.h:63
StorageType::size_type size_type
Definition: Util.h:50
T min(const T &x, const T &y)
Definition: g3dmath.h:305
bool IsEqual(uint32 p1=0, uint32 p2=0, uint32 p3=0, uint32 p4=0) const
Definition: Util.h:376
std::vector< char const * > StorageType
Definition: Util.h:48
bool isBasicLatinCharacter(wchar_t wchar)
Definition: Util.h:134
StorageType::const_iterator const_iterator
Definition: Util.h:52
TC_COMMON_API uint32 GetPID()
Definition: Util.cpp:236
TC_COMMON_API void utf8truncate(std::string &utf8str, size_t len)
Definition: Util.cpp:260
TC_COMMON_API void vutf8printf(FILE *out, const char *str, va_list *ap)
Definition: Util.cpp:477
bool operator!=(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:166
Vector3int16 operator&(int16 i) const
Definition: Vector3int16.h:149
Vector2int16 & operator=(const Any &a)
bool isCyrillicString(const std::wstring &wstr, bool numericOrSpace)
Definition: Util.h:234
bool operator==(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:160
TC_COMMON_API std::string TimeToTimestampStr(time_t t)
Definition: Util.cpp:195
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
TC_COMMON_API bool IsIPAddress(char const *ipaddress)
Check if the string is a valid ip address representation.
Definition: Util.cpp:211
G3D::int16 & operator[](int i)
Definition: Vector2int16.h:51
ComparisionType
Definition: Util.h:502
ListIterator begin()
Definition: Util.h:352
#define TC_COMMON_API
Definition: Define.h:116
T CalculatePct(T base, U pct)
Definition: Util.h:92
float length(float v)
Definition: vectorMath.h:208
void ApplyPercentModFloatVar(float &var, float val, bool apply)
Definition: Util.h:83
const_iterator end() const
Definition: Util.h:61
TC_COMMON_API struct tm * localtime_r(const time_t *time, struct tm *result)
TC_COMMON_API bool utf8ToConsole(const std::string &utf8str, std::string &conStr)
Definition: Util.cpp:421
TC_COMMON_API bool Utf8toWStr(const std::string &utf8str, std::wstring &wstr)
Definition: Util.cpp:309
bool isNumeric(wchar_t wchar)
Definition: Util.h:194
TC_COMMON_API void stripLineInvisibleChars(std::string &src)
Definition: Util.cpp:67
bool HasFlag(uint32 p1=0, uint32 p2=0, uint32 p3=0, uint32 p4=0) const
Definition: Util.h:381
HookList< T > & operator+=(T t)
Definition: Util.h:338
bool isNumericOrSpace(wchar_t wchar)
Definition: Util.h:213
size_t size()
Definition: Util.h:348
#define ABORT
Definition: Errors.h:56
TC_COMMON_API uint32 TimeStringToSecs(const std::string ×tring)
Definition: Util.cpp:163
wchar_t wcharToLower(wchar_t wchar)
Definition: Util.h:278
T AddPct(T &base, U pct)
Definition: Util.h:98
bool isBasicLatinString(const std::wstring &wstr, bool numericOrSpace)
Definition: Util.h:218
void Set(uint32 p1=0, uint32 p2=0, uint32 p3=0, uint32 p4=0)
Definition: Util.h:386
uint8_t uint8
Definition: Define.h:152
ListIterator end()
Definition: Util.h:356
TC_COMMON_API uint32 CreatePIDFile(std::string const &filename)
create PID file
Definition: Util.cpp:222
bool isEastAsianString(const std::wstring &wstr, bool numericOrSpace)
Definition: Util.h:242
void wstrToUpper(std::wstring &str)
Definition: Util.h:301
wchar_t wcharToUpper(wchar_t wchar)
Definition: Util.h:250
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55
bool isExtendedLatinString(const std::wstring &wstr, bool numericOrSpace)
Definition: Util.h:226
Finder(T val, T S::*idMember)
Definition: Util.h:41
TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText=false, bool hoursOnly=false)
Definition: Util.cpp:109
std::list< T >::iterator ListIterator
Definition: Util.h:334
flag128(uint32 p1=0, uint32 p2=0, uint32 p3=0, uint32 p4=0)
Definition: Util.h:368
~Tokenizer()
Definition: Util.h:58
const_iterator begin() const
Definition: Util.h:60
StorageType::const_reference const_reference
Definition: Util.h:54
HookList< T > & operator-=(T t)
Definition: Util.h:343