AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
anonymous_namespace{Field.cpp} Namespace Reference

Functions

template<typename T >
constexpr T GetDefaultValue ()
 
template<typename T >
bool IsCorrectFieldType (DatabaseFieldTypes type)
 
Optional< std::string_view > GetCleanAliasName (std::string_view alias)
 
template<typename T >
bool IsCorrectAlias (DatabaseFieldTypes type, std::string_view alias)
 

Function Documentation

◆ GetCleanAliasName()

Optional< std::string_view > anonymous_namespace{Field.cpp}::GetCleanAliasName ( std::string_view  alias)
inline
106 {
107 if (alias.empty())
108 return {};
109
110 auto pos = alias.find_first_of('(');
111 if (pos == std::string_view::npos)
112 return {};
113
114 alias.remove_suffix(alias.length() - pos);
115
116 return { alias };
117 }

◆ GetDefaultValue()

template<typename T >
constexpr T anonymous_namespace{Field.cpp}::GetDefaultValue ( )
constexpr
37 {
38 if constexpr (std::is_same_v<T, bool>)
39 return false;
40 else if constexpr (std::is_integral_v<T>)
41 return 0;
42 else if constexpr (std::is_floating_point_v<T>)
43 return 1.0f;
44 else if constexpr (std::is_same_v<T, std::vector<uint8>> || std::is_same_v<std::string_view, T>)
45 return {};
46 else
47 return "";
48 }

◆ IsCorrectAlias()

template<typename T >
bool anonymous_namespace{Field.cpp}::IsCorrectAlias ( DatabaseFieldTypes  type,
std::string_view  alias 
)
inline
121 {
122 if constexpr (std::is_same_v<T, double>)
123 {
124 if ((StringEqualI(alias, "sum") || StringEqualI(alias, "avg")) && type == DatabaseFieldTypes::Decimal)
125 return true;
126
127 return false;
128 }
129
130 if constexpr (std::is_same_v<T, uint64>)
131 {
132 if (StringEqualI(alias, "count") && type == DatabaseFieldTypes::Int64)
133 return true;
134
135 return false;
136 }
137
138 if ((StringEqualI(alias, "min") || StringEqualI(alias, "max")) && IsCorrectFieldType<T>(type))
139 {
140 return true;
141 }
142
143 return false;
144 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:587

References Decimal, Int64, and StringEqualI().

◆ IsCorrectFieldType()

template<typename T >
bool anonymous_namespace{Field.cpp}::IsCorrectFieldType ( DatabaseFieldTypes  type)
inline
52 {
53 // Int8
54 if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, int8> || std::is_same_v<T, uint8>)
55 {
56 if (type == DatabaseFieldTypes::Int8)
57 return true;
58 }
59
60 // In16
61 if constexpr (std::is_same_v<T, uint16> || std::is_same_v<T, int16>)
62 {
63 if (type == DatabaseFieldTypes::Int16)
64 return true;
65 }
66
67 // Int32
68 if constexpr (std::is_same_v<T, uint32> || std::is_same_v<T, int32>)
69 {
70 if (type == DatabaseFieldTypes::Int32)
71 return true;
72 }
73
74 // Int64
75 if constexpr (std::is_same_v<T, uint64> || std::is_same_v<T, int64>)
76 {
77 if (type == DatabaseFieldTypes::Int64)
78 return true;
79 }
80
81 // float
82 if constexpr (std::is_same_v<T, float>)
83 {
84 if (type == DatabaseFieldTypes::Float)
85 return true;
86 }
87
88 // dobule
89 if constexpr (std::is_same_v<T, double>)
90 {
92 return true;
93 }
94
95 // Binary
96 if constexpr (std::is_same_v<T, Binary>)
97 {
99 return true;
100 }
101
102 return false;
103 }

References Binary, Decimal, Double, Float, Int16, Int32, Int64, and Int8.