TrinityCore
Loading...
Searching...
No Matches
Field.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef TRINITY_DATABASE_FIELD_H
19
#define TRINITY_DATABASE_FIELD_H
20
21
#include "
Define.h
"
22
#include "
Duration.h
"
23
#include <array>
24
#include <string>
25
#include <string_view>
26
#include <vector>
27
28
class
BaseDatabaseResultValueConverter
;
29
30
enum class
DatabaseFieldTypes
:
uint8
31
{
32
Null
,
33
UInt8
,
34
Int8
,
35
UInt16
,
36
Int16
,
37
UInt32
,
38
Int32
,
39
UInt64
,
40
Int64
,
41
Float
,
42
Double
,
43
Decimal
,
44
Date
,
45
Time
,
46
Binary
47
};
48
49
struct
QueryResultFieldMetadata
50
{
51
char
const
*
TableName
=
nullptr
;
52
char
const
*
TableAlias
=
nullptr
;
53
char
const
*
Name
=
nullptr
;
54
char
const
*
Alias
=
nullptr
;
55
char
const
*
TypeName
=
nullptr
;
56
uint32
Index
= 0;
57
DatabaseFieldTypes
Type
=
DatabaseFieldTypes::Null
;
58
BaseDatabaseResultValueConverter
const
*
Converter
=
nullptr
;
59
};
60
91
class
TC_DATABASE_API
Field
92
{
93
friend
class
ResultSet
;
94
friend
class
PreparedResultSet
;
95
96
public
:
97
Field
();
98
~Field
();
99
100
bool
GetBool
() const
// Wrapper, actually gets integer
101
{
102
return
GetUInt8() == 1 ? true :
false
;
103
}
104
105
uint8
GetUInt8()
const
;
106
int8
GetInt8()
const
;
107
uint16
GetUInt16()
const
;
108
int16
GetInt16()
const
;
109
uint32
GetUInt32()
const
;
110
int32
GetInt32()
const
;
111
uint64
GetUInt64()
const
;
112
int64
GetInt64()
const
;
113
float
GetFloat()
const
;
114
double
GetDouble()
const
;
115
SystemTimePoint
GetDate()
const
;
116
char
const
* GetCString()
const
;
117
std::string GetString()
const
;
118
std::string_view GetStringView()
const
;
119
std::vector<uint8> GetBinary()
const
;
120
template
<
size_t
S>
121
std::array<uint8, S>
GetBinary
()
const
122
{
123
std::array<uint8, S> buf;
124
GetBinarySizeChecked(buf.data(), S);
125
return
buf;
126
}
127
128
bool
IsNull
()
const
129
{
130
return
_value ==
nullptr
;
131
}
132
133
private
:
134
char
const
*
_value
;
// Actual data in memory
135
uint32
_length
;
// Length
136
137
void
SetValue(
char
const
* newValue,
uint32
length);
138
139
QueryResultFieldMetadata
const
*
_meta
;
140
void
SetMetadata(
QueryResultFieldMetadata
const
* meta);
141
142
void
GetBinarySizeChecked(
uint8
* buf,
size_t
size)
const
;
143
};
144
145
#endif
Define.h
uint8
uint8_t uint8
Definition
Define.h:135
TC_DATABASE_API
#define TC_DATABASE_API
Definition
Define.h:102
int64
int64_t int64
Definition
Define.h:128
int16
int16_t int16
Definition
Define.h:130
int8
int8_t int8
Definition
Define.h:131
int32
int32_t int32
Definition
Define.h:129
uint64
uint64_t uint64
Definition
Define.h:132
uint16
uint16_t uint16
Definition
Define.h:134
uint32
uint32_t uint32
Definition
Define.h:133
Duration.h
SystemTimePoint
std::chrono::system_clock::time_point SystemTimePoint
Definition
Duration.h:37
DatabaseFieldTypes
DatabaseFieldTypes
Definition
Field.h:31
DatabaseFieldTypes::Float
@ Float
DatabaseFieldTypes::Int16
@ Int16
DatabaseFieldTypes::Date
@ Date
DatabaseFieldTypes::Binary
@ Binary
DatabaseFieldTypes::Int8
@ Int8
DatabaseFieldTypes::UInt16
@ UInt16
DatabaseFieldTypes::Decimal
@ Decimal
DatabaseFieldTypes::Time
@ Time
DatabaseFieldTypes::UInt64
@ UInt64
DatabaseFieldTypes::UInt8
@ UInt8
DatabaseFieldTypes::Null
@ Null
DatabaseFieldTypes::Int32
@ Int32
DatabaseFieldTypes::Double
@ Double
DatabaseFieldTypes::UInt32
@ UInt32
DatabaseFieldTypes::Int64
@ Int64
BaseDatabaseResultValueConverter
Definition
FieldValueConverter.h:27
Field
Class used to access individual fields of database query result.
Definition
Field.h:92
Field::_value
char const * _value
Definition
Field.h:134
Field::_meta
QueryResultFieldMetadata const * _meta
Definition
Field.h:139
Field::~Field
~Field()
Field::_length
uint32 _length
Definition
Field.h:135
Field::GetBinary
std::array< uint8, S > GetBinary() const
Definition
Field.h:121
Field::IsNull
bool IsNull() const
Definition
Field.h:128
Field::GetBool
bool GetBool() const
Definition
Field.h:100
PreparedResultSet
Definition
QueryResult.h:56
ResultSet
Definition
QueryResult.h:26
QueryResultFieldMetadata
Definition
Field.h:50
QueryResultFieldMetadata::Converter
BaseDatabaseResultValueConverter const * Converter
Definition
Field.h:58
QueryResultFieldMetadata::Type
DatabaseFieldTypes Type
Definition
Field.h:57
QueryResultFieldMetadata::Alias
char const * Alias
Definition
Field.h:54
QueryResultFieldMetadata::TableAlias
char const * TableAlias
Definition
Field.h:52
QueryResultFieldMetadata::TableName
char const * TableName
Definition
Field.h:51
QueryResultFieldMetadata::TypeName
char const * TypeName
Definition
Field.h:55
QueryResultFieldMetadata::Index
uint32 Index
Definition
Field.h:56
QueryResultFieldMetadata::Name
char const * Name
Definition
Field.h:53
server
database
Database
Field.h
Generated on Sun May 10 2026 02:30:13 for TrinityCore by
1.9.8