Core/Common: Include cleanup

This commit is contained in:
Shauren
2017-05-11 22:29:51 +02:00
parent 8abc56c540
commit 3a418a0bbc
145 changed files with 1194 additions and 989 deletions

View File

@@ -18,11 +18,12 @@
#include "Util.h"
#include "Common.h"
#include "CompilerDefs.h"
#include "utf8.h"
#include "Errors.h" // for ASSERT
#include <stdarg.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/asio/ip/address.hpp>
#include <utf8.h>
#include <algorithm>
#include <sstream>
#include <cstdarg>
#include <ctime>
#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
#include <sys/socket.h>
@@ -149,7 +150,7 @@ int64 MoneyStringToMoney(const std::string& moneyString)
if (gCount + sCount + cCount != 1)
return 0;
uint64 amount = atoull(*itr);
uint64 amount = strtoull(*itr, nullptr, 10);
if (gCount == 1)
money += amount * 100 * 100;
else if (sCount == 1)
@@ -171,8 +172,8 @@ uint32 TimeStringToSecs(const std::string& timestring)
{
if (isdigit(*itr))
{
buffer*=10;
buffer+= (*itr)-'0';
buffer *= 10;
buffer += *itr - '0';
}
else
{
@@ -184,9 +185,9 @@ uint32 TimeStringToSecs(const std::string& timestring)
case 's': multiplier = 1; break;
default : return 0; //bad format
}
buffer*=multiplier;
secs+=buffer;
buffer=0;
buffer *= multiplier;
secs += buffer;
buffer = 0;
}
}
@@ -214,9 +215,9 @@ bool IsIPAddress(char const* ipaddress)
if (!ipaddress)
return false;
// Let the big boys do it.
// Drawback: all valid ip address formats are recognized e.g.: 12.23, 121234, 0xABCD)
return inet_addr(ipaddress) != INADDR_NONE;
boost::system::error_code error;
boost::asio::ip::address::from_string(ipaddress, error);
return !error;
}
/// create PID file
@@ -374,6 +375,16 @@ bool WStrToUtf8(std::wstring const& wstr, std::string& utf8str)
typedef wchar_t const* const* wstrlist;
void wstrToUpper(std::wstring& str)
{
std::transform(str.begin(), str.end(), str.begin(), wcharToUpper);
}
void wstrToLower(std::wstring& str)
{
std::transform(str.begin(), str.end(), str.begin(), wcharToLower);
}
std::wstring GetMainPartOfName(std::wstring const& wname, uint32 declension)
{
// supported only Cyrillic cases
@@ -558,6 +569,7 @@ void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= fals
bool StringToBool(std::string const& str)
{
std::string lowerStr = boost::algorithm::to_lower_copy(str);
std::string lowerStr = str;
std::transform(str.begin(), str.end(), lowerStr.begin(), ::tolower);
return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes";
}