TrinityCore
Common.h File Reference
#include "Define.h"
#include <array>
#include <memory>
#include <string>
#include <utility>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
#include <cstdlib>
+ Include dependency graph for Common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LocalizedString
 

Macros

#define atoll   _atoi64
 
#define llabs   _abs64
 
#define STRINGIZE(a)   #a
 
#define DEFAULT_LOCALE   LOCALE_enUS
 
#define M_PI   3.14159265358979323846
 
#define M_PI_4   0.785398163397448309616
 
#define MAX_QUERY_LEN   32*1024
 

Enumerations

enum  TimeConstants {
  MINUTE = 60, HOUR = MINUTE*60, DAY = HOUR*24, WEEK = DAY*7,
  MONTH = DAY*30, YEAR = MONTH*12, IN_MILLISECONDS = 1000
}
 
enum  AccountTypes {
  SEC_PLAYER = 0, SEC_MODERATOR = 1, SEC_GAMEMASTER = 2, SEC_ADMINISTRATOR = 3,
  SEC_CONSOLE = 4
}
 
enum  LocaleConstant : uint8 {
  LOCALE_enUS = 0, LOCALE_koKR = 1, LOCALE_frFR = 2, LOCALE_deDE = 3,
  LOCALE_zhCN = 4, LOCALE_zhTW = 5, LOCALE_esES = 6, LOCALE_esMX = 7,
  LOCALE_ruRU = 8, LOCALE_none = 9, LOCALE_ptBR = 10, LOCALE_itIT = 11,
  TOTAL_LOCALES
}
 

Functions

unsigned long atoul (char const *str)
 
unsigned long long atoull (char const *str)
 
TC_COMMON_API LocaleConstant GetLocaleByName (std::string const &name)
 
constexpr bool IsValidLocale (LocaleConstant locale)
 

Variables

const uint8 OLD_TOTAL_LOCALES = 9
 
TC_COMMON_API char const * localeNames [TOTAL_LOCALES]
 

Macro Definition Documentation

◆ atoll

#define atoll   _atoi64

◆ DEFAULT_LOCALE

#define DEFAULT_LOCALE   LOCALE_enUS
Todo:
convert in simple system

◆ llabs

#define llabs   _abs64

◆ M_PI

#define M_PI   3.14159265358979323846

◆ M_PI_4

#define M_PI_4   0.785398163397448309616

◆ MAX_QUERY_LEN

#define MAX_QUERY_LEN   32*1024

◆ STRINGIZE

#define STRINGIZE (   a)    #a

Enumeration Type Documentation

◆ AccountTypes

Enumerator
SEC_PLAYER 
SEC_MODERATOR 
SEC_GAMEMASTER 
SEC_ADMINISTRATOR 
SEC_CONSOLE 
72 {
73  SEC_PLAYER = 0,
74  SEC_MODERATOR = 1,
75  SEC_GAMEMASTER = 2,
77  SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
78 };
Definition: Common.h:76
Definition: Common.h:74
Definition: Common.h:75
Definition: Common.h:73
Definition: Common.h:77

◆ LocaleConstant

Enumerator
LOCALE_enUS 
LOCALE_koKR 
LOCALE_frFR 
LOCALE_deDE 
LOCALE_zhCN 
LOCALE_zhTW 
LOCALE_esES 
LOCALE_esMX 
LOCALE_ruRU 
LOCALE_none 
LOCALE_ptBR 
LOCALE_itIT 
TOTAL_LOCALES 
80  : uint8
81 {
82  LOCALE_enUS = 0,
83  LOCALE_koKR = 1,
84  LOCALE_frFR = 2,
85  LOCALE_deDE = 3,
86  LOCALE_zhCN = 4,
87  LOCALE_zhTW = 5,
88  LOCALE_esES = 6,
89  LOCALE_esMX = 7,
90  LOCALE_ruRU = 8,
91  LOCALE_none = 9,
92  LOCALE_ptBR = 10,
93  LOCALE_itIT = 11,
94 
96 };
Definition: Common.h:89
Definition: Common.h:88
Definition: Common.h:84
Definition: Common.h:93
Definition: Common.h:90
Definition: Common.h:86
Definition: Common.h:92
Definition: Common.h:91
Definition: Common.h:83
Definition: Common.h:82
Definition: Common.h:95
Definition: Common.h:85
uint8_t uint8
Definition: Define.h:154
Definition: Common.h:87

◆ TimeConstants

Enumerator
MINUTE 
HOUR 
DAY 
WEEK 
MONTH 
YEAR 
IN_MILLISECONDS 
61 {
62  MINUTE = 60,
63  HOUR = MINUTE*60,
64  DAY = HOUR*24,
65  WEEK = DAY*7,
66  MONTH = DAY*30,
67  YEAR = MONTH*12,
68  IN_MILLISECONDS = 1000
69 };
Definition: Common.h:67
Definition: Common.h:64
Definition: Common.h:62
Definition: Common.h:65
Definition: Common.h:68
Definition: Common.h:66
Definition: Common.h:63

Function Documentation

◆ atoul()

unsigned long atoul ( char const *  str)
inline
55 { return strtoul(str, nullptr, 10); }
+ Here is the caller graph for this function:

◆ atoull()

unsigned long long atoull ( char const *  str)
inline
56 { return strtoull(str, nullptr, 10); }
+ Here is the caller graph for this function:

◆ GetLocaleByName()

TC_COMMON_API LocaleConstant GetLocaleByName ( std::string const &  name)
37 {
38  for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
39  if (name == localeNames[i])
40  return LocaleConstant(i);
41 
42  return TOTAL_LOCALES;
43 }
LocaleConstant
Definition: Common.h:80
uint32_t uint32
Definition: Define.h:152
Definition: Common.h:95
char const * localeNames[TOTAL_LOCALES]
Definition: Common.cpp:20
+ Here is the caller graph for this function:

◆ IsValidLocale()

constexpr bool IsValidLocale ( LocaleConstant  locale)
inline
106 {
107  return locale < TOTAL_LOCALES && locale != LOCALE_none;
108 }
Definition: Common.h:91
Definition: Common.h:95
+ Here is the caller graph for this function:

Variable Documentation

◆ localeNames

TC_COMMON_API char const* localeNames[TOTAL_LOCALES]

◆ OLD_TOTAL_LOCALES

const uint8 OLD_TOTAL_LOCALES = 9