TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Util.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _UTIL_H
20 #define _UTIL_H
21 
22 #include "Define.h"
23 #include "Errors.h"
24 #include "Random.h"
25 
26 #include <algorithm>
27 #include <string>
28 #include <vector>
29 #include <list>
30 #include <map>
31 #include <stdarg.h>
32 #include <cstring>
33 #include <ctime>
34 
35 // Searcher for map of structs
36 template<typename T, class S> struct Finder
37 {
38  T val_;
39  T S::* idMember_;
40 
41  Finder(T val, T S::* idMember) : val_(val), idMember_(idMember) {}
42  bool operator()(const std::pair<int, S> &obj) { return obj.second.*idMember_ == val_; }
43 };
44 
46 {
47 public:
48  typedef std::vector<char const*> StorageType;
49 
50  typedef StorageType::size_type size_type;
51 
52  typedef StorageType::const_iterator const_iterator;
53  typedef StorageType::reference reference;
54  typedef StorageType::const_reference const_reference;
55 
56 public:
57  Tokenizer(const std::string &src, char const sep, uint32 vectorReserve = 0);
58  ~Tokenizer() { delete[] m_str; }
59 
60  const_iterator begin() const { return m_storage.begin(); }
61  const_iterator end() const { return m_storage.end(); }
62 
63  size_type size() const { return m_storage.size(); }
64 
65  reference operator [] (size_type i) { return m_storage[i]; }
66  const_reference operator [] (size_type i) const { return m_storage[i]; }
67 
68 private:
69  char* m_str;
70  StorageType m_storage;
71 };
72 
73 TC_COMMON_API void stripLineInvisibleChars(std::string &src);
74 
75 TC_COMMON_API int64 MoneyStringToMoney(const std::string& moneyString);
76 
77 TC_COMMON_API struct tm* localtime_r(const time_t* time, struct tm *result);
78 
79 TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false);
80 TC_COMMON_API uint32 TimeStringToSecs(const std::string& timestring);
81 TC_COMMON_API std::string TimeToTimestampStr(time_t t);
82 
83 inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
84 {
85  if (val == -100.0f) // prevent set var to zero
86  val = -99.99f;
87  var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
88 }
89 
90 // Percentage calculation
91 template <class T, class U>
92 inline T CalculatePct(T base, U pct)
93 {
94  return T(base * static_cast<float>(pct) / 100.0f);
95 }
96 
97 template <class T, class U>
98 inline T AddPct(T &base, U pct)
99 {
100  return base += CalculatePct(base, pct);
101 }
102 
103 template <class T, class U>
104 inline T ApplyPct(T &base, U pct)
105 {
106  return base = CalculatePct(base, pct);
107 }
108 
109 template <class T>
110 inline T RoundToInterval(T& num, T floor, T ceil)
111 {
112  return num = std::min(std::max(num, floor), ceil);
113 }
114 
115 // UTF8 handling
116 TC_COMMON_API bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr);
117 
118 // in wsize==max size of buffer, out wsize==real string size
119 TC_COMMON_API bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
120 
121 inline bool Utf8toWStr(const std::string& utf8str, wchar_t* wstr, size_t& wsize)
122 {
123  return Utf8toWStr(utf8str.c_str(), utf8str.size(), wstr, wsize);
124 }
125 
126 TC_COMMON_API bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str);
127 // size==real string size
128 TC_COMMON_API bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str);
129 
130 // set string to "" if invalid utf8 sequence
131 TC_COMMON_API size_t utf8length(std::string& utf8str);
132 TC_COMMON_API void utf8truncate(std::string& utf8str, size_t len);
133 
134 inline bool isBasicLatinCharacter(wchar_t wchar)
135 {
136  if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
137  return true;
138  if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
139  return true;
140  return false;
141 }
142 
143 inline bool isExtendedLatinCharacter(wchar_t wchar)
144 {
145  if (isBasicLatinCharacter(wchar))
146  return true;
147  if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
148  return true;
149  if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
150  return true;
151  if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
152  return true;
153  if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
154  return true;
155  if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
156  return true;
157  if (wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK
158  return true;
159  if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
160  return true;
161  return false;
162 }
163 
164 inline bool isCyrillicCharacter(wchar_t wchar)
165 {
166  if (wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA
167  return true;
168  if (wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO
169  return true;
170  return false;
171 }
172 
173 inline bool isEastAsianCharacter(wchar_t wchar)
174 {
175  if (wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo
176  return true;
177  if (wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana
178  return true;
179  if (wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo
180  return true;
181  if (wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext.
182  return true;
183  if (wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A
184  return true;
185  if (wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs
186  return true;
187  if (wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables
188  return true;
189  if (wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms
190  return true;
191  return false;
192 }
193 
194 inline bool isNumeric(wchar_t wchar)
195 {
196  return (wchar >= L'0' && wchar <=L'9');
197 }
198 
199 inline bool isNumeric(char c)
200 {
201  return (c >= '0' && c <='9');
202 }
203 
204 inline bool isNumeric(char const* str)
205 {
206  for (char const* c = str; *c; ++c)
207  if (!isNumeric(*c))
208  return false;
209 
210  return true;
211 }
212 
213 inline bool isNumericOrSpace(wchar_t wchar)
214 {
215  return isNumeric(wchar) || wchar == L' ';
216 }
217 
218 inline bool isBasicLatinString(const std::wstring &wstr, bool numericOrSpace)
219 {
220  for (size_t i = 0; i < wstr.size(); ++i)
221  if (!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
222  return false;
223  return true;
224 }
225 
226 inline bool isExtendedLatinString(const std::wstring &wstr, bool numericOrSpace)
227 {
228  for (size_t i = 0; i < wstr.size(); ++i)
229  if (!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
230  return false;
231  return true;
232 }
233 
234 inline bool isCyrillicString(const std::wstring &wstr, bool numericOrSpace)
235 {
236  for (size_t i = 0; i < wstr.size(); ++i)
237  if (!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
238  return false;
239  return true;
240 }
241 
242 inline bool isEastAsianString(const std::wstring &wstr, bool numericOrSpace)
243 {
244  for (size_t i = 0; i < wstr.size(); ++i)
245  if (!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i])))
246  return false;
247  return true;
248 }
249 
250 inline wchar_t wcharToUpper(wchar_t wchar)
251 {
252  if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z
253  return wchar_t(uint16(wchar)-0x0020);
254  if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S
255  return wchar_t(0x1E9E);
256  if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS
257  return wchar_t(uint16(wchar)-0x0020);
258  if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN
259  return wchar_t(uint16(wchar)-0x0020);
260  if (wchar >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1)
261  {
262  if (wchar % 2 == 1)
263  return wchar_t(uint16(wchar)-0x0001);
264  }
265  if (wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA
266  return wchar_t(uint16(wchar)-0x0020);
267  if (wchar == 0x0451) // CYRILLIC SMALL LETTER IO
268  return wchar_t(0x0401);
269 
270  return wchar;
271 }
272 
273 inline wchar_t wcharToUpperOnlyLatin(wchar_t wchar)
274 {
275  return isBasicLatinCharacter(wchar) ? wcharToUpper(wchar) : wchar;
276 }
277 
278 inline wchar_t wcharToLower(wchar_t wchar)
279 {
280  if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z
281  return wchar_t(uint16(wchar)+0x0020);
282  if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS
283  return wchar_t(uint16(wchar)+0x0020);
284  if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN
285  return wchar_t(uint16(wchar)+0x0020);
286  if (wchar >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0)
287  {
288  if (wchar % 2 == 0)
289  return wchar_t(uint16(wchar)+0x0001);
290  }
291  if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S
292  return wchar_t(0x00DF);
293  if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO
294  return wchar_t(0x0451);
295  if (wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA
296  return wchar_t(uint16(wchar)+0x0020);
297 
298  return wchar;
299 }
300 
301 inline void wstrToUpper(std::wstring& str)
302 {
303  std::transform( str.begin(), str.end(), str.begin(), wcharToUpper );
304 }
305 
306 inline void wstrToLower(std::wstring& str)
307 {
308  std::transform( str.begin(), str.end(), str.begin(), wcharToLower );
309 }
310 
311 TC_COMMON_API std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension);
312 
313 TC_COMMON_API bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
314 TC_COMMON_API bool consoleToUtf8(const std::string& conStr, std::string& utf8str);
315 TC_COMMON_API bool Utf8FitTo(const std::string& str, std::wstring const& search);
316 TC_COMMON_API void utf8printf(FILE* out, const char *str, ...);
317 TC_COMMON_API void vutf8printf(FILE* out, const char *str, va_list* ap);
318 TC_COMMON_API bool Utf8ToUpperOnlyLatin(std::string& utf8String);
319 
320 TC_COMMON_API bool IsIPAddress(char const* ipaddress);
321 
322 TC_COMMON_API uint32 CreatePIDFile(std::string const& filename);
324 
325 TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, bool reverse = false);
326 TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false);
327 
328 TC_COMMON_API bool StringToBool(std::string const& str);
329 
330 // simple class for not-modifyable list
331 template <typename T>
332 class HookList
333 {
334  typedef typename std::list<T>::iterator ListIterator;
335  private:
336  typename std::list<T> m_list;
337  public:
339  {
340  m_list.push_back(t);
341  return *this;
342  }
344  {
345  m_list.remove(t);
346  return *this;
347  }
348  size_t size()
349  {
350  return m_list.size();
351  }
352  ListIterator begin()
353  {
354  return m_list.begin();
355  }
356  ListIterator end()
357  {
358  return m_list.end();
359  }
360 };
361 
363 {
364 private:
365  uint32 part[4];
366 
367 public:
368  flag128(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0, uint32 p4 = 0)
369  {
370  part[0] = p1;
371  part[1] = p2;
372  part[2] = p3;
373  part[3] = p4;
374  }
375 
376  inline bool IsEqual(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0, uint32 p4 = 0) const
377  {
378  return (part[0] == p1 && part[1] == p2 && part[2] == p3 && part[3] == p4);
379  }
380 
381  inline bool HasFlag(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0, uint32 p4 = 0) const
382  {
383  return (part[0] & p1 || part[1] & p2 || part[2] & p3 || part[3] & p4);
384  }
385 
386  inline void Set(uint32 p1 = 0, uint32 p2 = 0, uint32 p3 = 0, uint32 p4 = 0)
387  {
388  part[0] = p1;
389  part[1] = p2;
390  part[2] = p3;
391  part[3] = p4;
392  }
393 
394  inline bool operator <(const flag128 &right) const
395  {
396  for (uint8 i = 4; i > 0; --i)
397  {
398  if (part[i - 1] < right.part[i - 1])
399  return true;
400  else if (part[i - 1] > right.part[i - 1])
401  return false;
402  }
403  return false;
404  }
405 
406  inline bool operator ==(const flag128 &right) const
407  {
408  return
409  (
410  part[0] == right.part[0] &&
411  part[1] == right.part[1] &&
412  part[2] == right.part[2] &&
413  part[3] == right.part[3]
414  );
415  }
416 
417  inline bool operator !=(const flag128 &right) const
418  {
419  return !this->operator ==(right);
420  }
421 
422  inline flag128 & operator =(const flag128 &right)
423  {
424  part[0] = right.part[0];
425  part[1] = right.part[1];
426  part[2] = right.part[2];
427  part[3] = right.part[3];
428  return *this;
429  }
430 
431  inline flag128 operator &(const flag128 &right) const
432  {
433  return flag128(part[0] & right.part[0], part[1] & right.part[1],
434  part[2] & right.part[2], part[3] & right.part[3]);
435  }
436 
437  inline flag128 & operator &=(const flag128 &right)
438  {
439  part[0] &= right.part[0];
440  part[1] &= right.part[1];
441  part[2] &= right.part[2];
442  part[3] &= right.part[3];
443  return *this;
444  }
445 
446  inline flag128 operator |(const flag128 &right) const
447  {
448  return flag128(part[0] | right.part[0], part[1] | right.part[1],
449  part[2] | right.part[2], part[3] | right.part[3]);
450  }
451 
452  inline flag128 & operator |=(const flag128 &right)
453  {
454  part[0] |= right.part[0];
455  part[1] |= right.part[1];
456  part[2] |= right.part[2];
457  part[3] |= right.part[3];
458  return *this;
459  }
460 
461  inline flag128 operator ~() const
462  {
463  return flag128(~part[0], ~part[1], ~part[2], ~part[3]);
464  }
465 
466  inline flag128 operator ^(const flag128 &right) const
467  {
468  return flag128(part[0] ^ right.part[0], part[1] ^ right.part[1],
469  part[2] ^ right.part[2], part[3] ^ right.part[3]);
470  }
471 
472  inline flag128 & operator ^=(const flag128 &right)
473  {
474  part[0] ^= right.part[0];
475  part[1] ^= right.part[1];
476  part[2] ^= right.part[2];
477  part[3] ^= right.part[3];
478  return *this;
479  }
480 
481  inline operator bool() const
482  {
483  return (part[0] != 0 || part[1] != 0 || part[2] != 0 || part[3] != 0);
484  }
485 
486  inline bool operator !() const
487  {
488  return !this->operator bool();
489  }
490 
491  inline uint32 & operator [](uint8 el)
492  {
493  return part[el];
494  }
495 
496  inline const uint32 & operator [](uint8 el) const
497  {
498  return part[el];
499  }
500 };
501 
503 {
510 };
511 
512 template <class T>
513 bool CompareValues(ComparisionType type, T val1, T val2)
514 {
515  switch (type)
516  {
517  case COMP_TYPE_EQ:
518  return val1 == val2;
519  case COMP_TYPE_HIGH:
520  return val1 > val2;
521  case COMP_TYPE_LOW:
522  return val1 < val2;
523  case COMP_TYPE_HIGH_EQ:
524  return val1 >= val2;
525  case COMP_TYPE_LOW_EQ:
526  return val1 <= val2;
527  default:
528  // incorrect parameter
529  ABORT();
530  return false;
531  }
532 }
533 
534 #endif
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
Definition: Util.h:509
bool isCyrillicCharacter(wchar_t wchar)
Definition: Util.h:164
T S::* idMember_
Definition: Util.h:39
Definition: Util.h:45
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
Definition: Util.h:507
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
Definition: Util.h:36
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
Definition: Util.h:506
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
Definition: Util.h:504
Definition: Util.h:505
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
Definition: Util.h:362
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
Definition: Util.h:508
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 &timestring)
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
Definition: Util.h:332
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