TrinityCore
Util.cpp File Reference
#include "Util.h"
#include "Common.h"
#include "Containers.h"
#include "IpAddress.h"
#include "StringConvert.h"
#include "StringFormat.h"
#include <boost/core/demangle.hpp>
#include <utf8.h>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <cctype>
#include <cstdarg>
#include <ctime>
+ Include dependency graph for Util.cpp:

Go to the source code of this file.

Functions

tm TimeBreakdown (time_t time)
 
time_t GetLocalHourTimestamp (time_t time, uint8 hour, bool onlyAfterTime)
 
std::string secsToTimeString (uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
 
Optional< int64MoneyStringToMoney (std::string const &moneyString)
 
uint32 TimeStringToSecs (std::string const &timestring)
 
std::string TimeToTimestampStr (time_t t)
 
std::string TimeToHumanReadable (time_t t)
 
bool IsIPAddress (char const *ipaddress)
 Check if the string is a valid ip address representation. More...
 
uint32 CreatePIDFile (std::string const &filename)
 create PID file More...
 
uint32 GetPID ()
 
size_t utf8length (std::string &utf8str)
 
void utf8truncate (std::string &utf8str, size_t len)
 
bool Utf8toWStr (char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
 
bool Utf8toWStr (std::string_view utf8str, std::wstring &wstr)
 
bool WStrToUtf8 (wchar_t const *wstr, size_t size, std::string &utf8str)
 
bool WStrToUtf8 (std::wstring_view wstr, std::string &utf8str)
 
void wstrToUpper (std::wstring &str)
 
void wstrToLower (std::wstring &str)
 
void strToUpper (std::string &str)
 
void strToLower (std::string &str)
 
std::wstring wstrCaseAccentInsensitiveParse (std::wstring_view wstr, LocaleConstant locale)
 
std::wstring GetMainPartOfName (std::wstring const &wname, uint32 declension)
 
bool utf8ToConsole (std::string_view utf8str, std::string &conStr)
 
bool consoleToUtf8 (std::string_view conStr, std::string &utf8str)
 
bool Utf8FitTo (std::string_view str, std::wstring_view search)
 
void utf8printf (FILE *out, const char *str,...)
 
void vutf8printf (FILE *out, const char *str, va_list *ap)
 
bool Utf8ToUpperOnlyLatin (std::string &utf8String)
 
bool ReadWinConsole (std::string &str, size_t size)
 
bool WriteWinConsole (std::string_view str, bool error)
 
TC_COMMON_API Optional< std::size_t > RemoveCRLF (std::string &str)
 
bool StringEqualI (std::string_view a, std::string_view b)
 
bool StringContainsStringI (std::string_view haystack, std::string_view needle)
 
bool StringCompareLessI (std::string_view a, std::string_view b)
 
float DegToRad (float degrees)
 

Function Documentation

◆ consoleToUtf8()

bool consoleToUtf8 ( std::string_view  conStr,
std::string &  utf8str 
)

Definition at line 735 of file Util.cpp.

+ Here is the call graph for this function:

◆ CreatePIDFile()

uint32 CreatePIDFile ( std::string const &  filename)

create PID file

Definition at line 324 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DegToRad()

float DegToRad ( float  degrees)

Definition at line 912 of file Util.cpp.

+ Here is the caller graph for this function:

◆ GetLocalHourTimestamp()

time_t GetLocalHourTimestamp ( time_t  time,
uint8  hour,
bool  onlyAfterTime 
)

Definition at line 100 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMainPartOfName()

std::wstring GetMainPartOfName ( std::wstring const &  wname,
uint32  declension 
)

Definition at line 669 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPID()

uint32 GetPID ( )

Definition at line 338 of file Util.cpp.

+ Here is the caller graph for this function:

◆ IsIPAddress()

bool IsIPAddress ( char const *  ipaddress)

Check if the string is a valid ip address representation.

Definition at line 313 of file Util.cpp.

+ Here is the caller graph for this function:

◆ MoneyStringToMoney()

Optional< int64 > MoneyStringToMoney ( std::string const &  moneyString)

Definition at line 216 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadWinConsole()

bool ReadWinConsole ( std::string &  str,
size_t  size 
)

Definition at line 807 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveCRLF()

TC_COMMON_API Optional< std::size_t > RemoveCRLF ( std::string &  str)

Definition at line 839 of file Util.cpp.

+ Here is the caller graph for this function:

◆ secsToTimeString()

std::string secsToTimeString ( uint64  timeInSecs,
TimeFormat  timeFormat,
bool  hoursOnly 
)

Definition at line 115 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StringCompareLessI()

bool StringCompareLessI ( std::string_view  a,
std::string_view  b 
)

Definition at line 902 of file Util.cpp.

+ Here is the caller graph for this function:

◆ StringContainsStringI()

bool StringContainsStringI ( std::string_view  haystack,
std::string_view  needle 
)

Definition at line 896 of file Util.cpp.

+ Here is the caller graph for this function:

◆ StringEqualI()

bool StringEqualI ( std::string_view  a,
std::string_view  b 
)

Definition at line 891 of file Util.cpp.

+ Here is the caller graph for this function:

◆ strToLower()

void strToLower ( std::string &  str)

Definition at line 482 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ strToUpper()

void strToUpper ( std::string &  str)

Definition at line 481 of file Util.cpp.

+ Here is the call graph for this function:

◆ TimeBreakdown()

tm TimeBreakdown ( time_t  time)

Definition at line 93 of file Util.cpp.

+ Here is the caller graph for this function:

◆ TimeStringToSecs()

uint32 TimeStringToSecs ( std::string const &  timestring)

Definition at line 258 of file Util.cpp.

+ Here is the caller graph for this function:

◆ TimeToHumanReadable()

std::string TimeToHumanReadable ( time_t  t)

Definition at line 303 of file Util.cpp.

+ Here is the caller graph for this function:

◆ TimeToTimestampStr()

std::string TimeToTimestampStr ( time_t  t)

Definition at line 290 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Utf8FitTo()

bool Utf8FitTo ( std::string_view  str,
std::wstring_view  search 
)

Definition at line 750 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ utf8length()

size_t utf8length ( std::string &  utf8str)

Definition at line 349 of file Util.cpp.

+ Here is the caller graph for this function:

◆ utf8printf()

void utf8printf ( FILE *  out,
const char *  str,
  ... 
)

Definition at line 766 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ utf8ToConsole()

bool utf8ToConsole ( std::string_view  utf8str,
std::string &  conStr 
)

Definition at line 718 of file Util.cpp.

+ Here is the call graph for this function:

◆ Utf8ToUpperOnlyLatin()

bool Utf8ToUpperOnlyLatin ( std::string &  utf8String)

Definition at line 795 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Utf8toWStr() [1/2]

bool Utf8toWStr ( char const *  utf8str,
size_t  csize,
wchar_t *  wstr,
size_t &  wsize 
)

Definition at line 383 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Utf8toWStr() [2/2]

bool Utf8toWStr ( std::string_view  utf8str,
std::wstring &  wstr 
)

Definition at line 417 of file Util.cpp.

+ Here is the caller graph for this function:

◆ utf8truncate()

void utf8truncate ( std::string &  utf8str,
size_t  len 
)

Definition at line 362 of file Util.cpp.

+ Here is the caller graph for this function:

◆ vutf8printf()

void vutf8printf ( FILE *  out,
const char *  str,
va_list *  ap 
)

Definition at line 774 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WriteWinConsole()

bool WriteWinConsole ( std::string_view  str,
bool  error 
)

Definition at line 826 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wstrCaseAccentInsensitiveParse()

std::wstring wstrCaseAccentInsensitiveParse ( std::wstring_view  wstr,
LocaleConstant  locale 
)

Definition at line 484 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wstrToLower()

void wstrToLower ( std::wstring &  str)

Definition at line 480 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wstrToUpper()

void wstrToUpper ( std::wstring &  str)

Definition at line 479 of file Util.cpp.

+ Here is the call graph for this function:

◆ WStrToUtf8() [1/2]

bool WStrToUtf8 ( std::wstring_view  wstr,
std::string &  utf8str 
)

Definition at line 456 of file Util.cpp.

◆ WStrToUtf8() [2/2]

bool WStrToUtf8 ( wchar_t const *  wstr,
size_t  size,
std::string &  utf8str 
)

Definition at line 433 of file Util.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: