Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Field.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include "
Field.h
"
7
#include "
Errors.h
"
8
9
Field::Field
()
10
{
11
data
.value =
nullptr
;
12
data
.type = MYSQL_TYPE_NULL;
13
data
.length = 0;
14
data
.raw =
false
;
15
}
16
17
Field::~Field
()
18
{
19
CleanUp
();
20
}
21
22
void
Field::SetByteValue
(
const
void
* newValue,
const
size_t
newSize, enum_field_types newType,
uint32
length
)
23
{
24
if
(
data
.value)
25
CleanUp
();
26
27
// This value stores raw bytes that have to be explicitly casted later
28
if
(newValue)
29
{
30
data
.value =
new
char
[newSize];
31
memcpy(
data
.value, newValue, newSize);
32
data
.length =
length
;
33
}
34
data
.type = newType;
35
data
.raw =
true
;
36
}
37
38
void
Field::SetStructuredValue
(
char
* newValue, enum_field_types newType,
uint32
length
)
39
{
40
if
(
data
.value)
41
CleanUp
();
42
43
// This value stores somewhat structured data that needs function style casting
44
if
(newValue)
45
{
46
data
.value =
new
char
[
length
+ 1];
47
memcpy(
data
.value, newValue,
length
);
48
*(
reinterpret_cast<
char
*
>
(
data
.value) +
length
) =
'\0'
;
49
data
.length =
length
;
50
}
51
52
data
.type = newType;
53
data
.raw =
false
;
54
}
55
56
std::vector<uint8>
Field::GetBinary
()
const
57
{
58
std::vector<uint8> result;
59
if
(!
data
.value || !
data
.length)
60
return
result;
61
62
result.resize(
data
.length);
63
memcpy(result.data(),
data
.value,
data
.length);
64
return
result;
65
}
66
67
void
Field::GetBinarySizeChecked
(
uint8
* buf,
size_t
length
)
const
68
{
69
ASSERT
(
data
.value && (
data
.length ==
length
));
70
memcpy(buf,
data
.value,
length
);
71
}
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
Errors.h
ASSERT
#define ASSERT
Definition
Errors.h:29
Field.h
Field::CleanUp
void CleanUp()
Definition
Field.h:286
Field::SetByteValue
void SetByteValue(void const *newValue, size_t const newSize, enum_field_types newType, uint32 length)
Definition
Field.cpp:22
Field::length
uint32 length
Definition
Field.h:272
Field::Field
Field()
Definition
Field.cpp:9
Field::~Field
~Field()
Definition
Field.cpp:17
Field::GetBinary
std::vector< uint8 > GetBinary() const
Definition
Field.cpp:56
Field::data
struct Field::@103301115010007122255114047010240314374313114334 data
Field::GetBinarySizeChecked
void GetBinarySizeChecked(uint8 *buf, size_t size) const
Definition
Field.cpp:67
Field::SetStructuredValue
void SetStructuredValue(char *newValue, enum_field_types newType, uint32 length)
Definition
Field.cpp:38
src
server
shared
Database
Field.cpp
Generated on
for Project SkyFire Core by
1.17.0