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
105 {
106 if (alias.empty())
107 return {};
108
109 auto pos = alias.find_first_of('(');
110 if (pos == std::string_view::npos)
111 return {};
112
113 alias.remove_suffix(alias.length() - pos);
114
115 return { alias };
116 }

◆ GetDefaultValue()

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

◆ IsCorrectAlias()

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

References Decimal, Int64, and StringEqualI().

◆ IsCorrectFieldType()

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

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