aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.h
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
committerariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
commit85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch)
treedf3d2084ee2e35008903c03178039b9c986e2d08 /src/common/Utilities/Util.h
parent052fc24315ace866ea1cf610e85df119b68100c9 (diff)
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r--src/common/Utilities/Util.h72
1 files changed, 24 insertions, 48 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 92a2f601c3f..458c783152c 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -21,24 +21,10 @@
#include "Define.h"
#include "Errors.h"
-#include "Random.h"
-#include <algorithm>
#include <string>
+#include <sstream>
#include <vector>
-#include <list>
-#include <map>
-#include <ctime>
-
-// Searcher for map of structs
-template<typename T, class S> struct Finder
-{
- T val_;
- T S::* idMember_;
-
- Finder(T val, T S::* idMember) : val_(val), idMember_(idMember) {}
- bool operator()(const std::pair<int, S> &obj) { return obj.second.*idMember_ == val_; }
-};
class TC_COMMON_API Tokenizer
{
@@ -70,12 +56,12 @@ private:
TC_COMMON_API void stripLineInvisibleChars(std::string &src);
-TC_COMMON_API int32 MoneyStringToMoney(const std::string& moneyString);
+TC_COMMON_API int32 MoneyStringToMoney(std::string const& moneyString);
-TC_COMMON_API struct tm* localtime_r(const time_t* time, struct tm *result);
+TC_COMMON_API struct tm* localtime_r(time_t const* time, struct tm *result);
TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false);
-TC_COMMON_API uint32 TimeStringToSecs(const std::string& timestring);
+TC_COMMON_API uint32 TimeStringToSecs(std::string const& timestring);
TC_COMMON_API std::string TimeToTimestampStr(time_t t);
// Percentage calculation
@@ -289,15 +275,8 @@ inline wchar_t wcharToLower(wchar_t wchar)
return wchar;
}
-inline void wstrToUpper(std::wstring& str)
-{
- std::transform( str.begin(), str.end(), str.begin(), wcharToUpper );
-}
-
-inline void wstrToLower(std::wstring& str)
-{
- std::transform( str.begin(), str.end(), str.begin(), wcharToLower );
-}
+TC_COMMON_API void wstrToUpper(std::wstring& str);
+TC_COMMON_API void wstrToLower(std::wstring& str);
TC_COMMON_API std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension);
@@ -382,7 +361,7 @@ public:
part[2] = p3;
}
- inline bool operator <(const flag96 &right) const
+ inline bool operator<(flag96 const& right) const
{
for (uint8 i = 3; i > 0; --i)
{
@@ -394,7 +373,7 @@ public:
return false;
}
- inline bool operator ==(const flag96 &right) const
+ inline bool operator==(flag96 const& right) const
{
return
(
@@ -404,12 +383,12 @@ public:
);
}
- inline bool operator !=(const flag96 &right) const
+ inline bool operator!=(flag96 const& right) const
{
- return !this->operator ==(right);
+ return !(*this == right);
}
- inline flag96 & operator =(const flag96 &right)
+ inline flag96& operator=(flag96 const& right)
{
part[0] = right.part[0];
part[1] = right.part[1];
@@ -417,13 +396,12 @@ public:
return *this;
}
- inline flag96 operator &(const flag96 &right) const
+ inline flag96 operator&(flag96 const& right) const
{
- return flag96(part[0] & right.part[0], part[1] & right.part[1],
- part[2] & right.part[2]);
+ return flag96(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2]);
}
- inline flag96 & operator &=(const flag96 &right)
+ inline flag96& operator&=(flag96 const& right)
{
part[0] &= right.part[0];
part[1] &= right.part[1];
@@ -431,13 +409,12 @@ public:
return *this;
}
- inline flag96 operator |(const flag96 &right) const
+ inline flag96 operator|(flag96 const& right) const
{
- return flag96(part[0] | right.part[0], part[1] | right.part[1],
- part[2] | right.part[2]);
+ return flag96(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2]);
}
- inline flag96 & operator |=(const flag96 &right)
+ inline flag96& operator |=(flag96 const& right)
{
part[0] |= right.part[0];
part[1] |= right.part[1];
@@ -445,18 +422,17 @@ public:
return *this;
}
- inline flag96 operator ~() const
+ inline flag96 operator~() const
{
return flag96(~part[0], ~part[1], ~part[2]);
}
- inline flag96 operator ^(const flag96 &right) const
+ inline flag96 operator^(flag96 const& right) const
{
- return flag96(part[0] ^ right.part[0], part[1] ^ right.part[1],
- part[2] ^ right.part[2]);
+ return flag96(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2]);
}
- inline flag96 & operator ^=(const flag96 &right)
+ inline flag96& operator^=(flag96 const& right)
{
part[0] ^= right.part[0];
part[1] ^= right.part[1];
@@ -471,15 +447,15 @@ public:
inline bool operator !() const
{
- return !this->operator bool();
+ return !(bool(*this));
}
- inline uint32 & operator [](uint8 el)
+ inline uint32& operator[](uint8 el)
{
return part[el];
}
- inline const uint32 & operator [](uint8 el) const
+ inline uint32 const& operator [](uint8 el) const
{
return part[el];
}