Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
QueryMethods.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010 - 2013 Eluna Lua Engine <http://emudevs.com/>
3
* This program is free software licensed under GPL version 3
4
* Please see the included DOCS/LICENSE.TXT for more information
5
*/
6
7
#include "
ObjectMethods.h
"
8
#include "
Includes.h
"
9
10
namespace
LuaQuery
11
{
12
int
NextRow
(lua_State* L,
QueryResult
* result)
13
{
14
if
(!result)
15
sEluna
->Push(L,
false
);
16
else
17
sEluna
->Push(L, (*result)->NextRow());
18
return
1;
19
}
20
21
int
GetColumnCount
(lua_State* L,
QueryResult
* result)
22
{
23
if
(!result)
24
sEluna
->Push(L, 0);
25
else
26
sEluna
->Push(L, (*result)->GetFieldCount());
27
return
1;
28
}
29
30
int
GetRowCount
(lua_State* L,
QueryResult
* result)
31
{
32
if
(!result)
33
sEluna
->Push(L, 0);
34
else
35
{
36
if
((*result)->GetRowCount() > (
uint32
)-1)
37
sEluna
->Push(L, (
uint32
)-1);
38
else
39
sEluna
->Push(L, (*result)->GetRowCount());
40
}
41
return
1;
42
}
43
44
int
IsNull
(lua_State* L,
QueryResult
* result)
45
{
46
uint32
col = luaL_checkunsigned(L, 1);
47
if
(!result || !*result || col >= (*result)->GetFieldCount())
48
sEluna
->Push(L,
true
);
49
else
50
sEluna
->Push(L, (*result)->Fetch()[col].IsNull());
51
return
1;
52
}
53
54
int
GetBool
(lua_State* L,
QueryResult
* result)
55
{
56
uint32
col = luaL_checkunsigned(L, 1);
57
if
(!result || !*result || col >= (*result)->GetFieldCount())
58
sEluna
->Push(L,
false
);
59
else
60
sEluna
->Push(L, (*result)->Fetch()[col].GetBool());
61
return
1;
62
}
63
64
int
GetUInt8
(lua_State* L,
QueryResult
* result)
65
{
66
uint32
col = luaL_checkunsigned(L, 1);
67
if
(!result || !*result || col >= (*result)->GetFieldCount())
68
sEluna
->Push(L, 0);
69
else
70
sEluna
->Push(L, (*result)->Fetch()[col].GetUInt8());
71
return
1;
72
}
73
74
int
GetUInt16
(lua_State* L,
QueryResult
* result)
75
{
76
uint32
col = luaL_checkunsigned(L, 1);
77
if
(!result || !*result || col >= (*result)->GetFieldCount())
78
sEluna
->Push(L, 0);
79
else
80
sEluna
->Push(L, (*result)->Fetch()[col].GetUInt16());
81
return
1;
82
}
83
84
int
GetUInt32
(lua_State* L,
QueryResult
* result)
85
{
86
uint32
col = luaL_checkunsigned(L, 1);
87
if
(!result || !*result || col >= (*result)->GetFieldCount())
88
sEluna
->Push(L, 0);
89
else
90
sEluna
->Push(L, (*result)->Fetch()[col].GetUInt32());
91
return
1;
92
}
93
94
int
GetUInt64
(lua_State* L,
QueryResult
* result)
95
{
96
uint32
col = luaL_checkunsigned(L, 1);
97
if
(!result || !*result || col >= (*result)->GetFieldCount())
98
sEluna
->Push(L, 0);
99
else
100
sEluna
->Push(L, (*result)->Fetch()[col].GetUInt64());
101
return
1;
102
}
103
104
int
GetInt8
(lua_State* L,
QueryResult
* result)
105
{
106
uint32
col = luaL_checkunsigned(L, 1);
107
if
(!result || !*result || col >= (*result)->GetFieldCount())
108
sEluna
->Push(L, 0);
109
else
110
sEluna
->Push(L, (*result)->Fetch()[col].GetInt8());
111
return
1;
112
}
113
114
int
GetInt16
(lua_State* L,
QueryResult
* result)
115
{
116
uint32
col = luaL_checkunsigned(L, 1);
117
if
(!result || !*result || col >= (*result)->GetFieldCount())
118
sEluna
->Push(L, 0);
119
else
120
sEluna
->Push(L, (*result)->Fetch()[col].GetInt16());
121
return
1;
122
}
123
124
int
GetInt32
(lua_State* L,
QueryResult
* result)
125
{
126
uint32
col = luaL_checkunsigned(L, 1);
127
if
(!result || !*result || col >= (*result)->GetFieldCount())
128
sEluna
->Push(L, 0);
129
else
130
sEluna
->Push(L, (*result)->Fetch()[col].GetInt32());
131
return
1;
132
}
133
134
int
GetInt64
(lua_State* L,
QueryResult
* result)
135
{
136
uint32
col = luaL_checkunsigned(L, 1);
137
if
(!result || !*result || col >= (*result)->GetFieldCount())
138
sEluna
->Push(L, 0);
139
else
140
sEluna
->Push(L, (*result)->Fetch()[col].GetInt64());
141
return
1;
142
}
143
144
int
GetFloat
(lua_State* L,
QueryResult
* result)
145
{
146
uint32
col = luaL_checkunsigned(L, 1);
147
if
(!result || !*result || col >= (*result)->GetFieldCount())
148
sEluna
->Push(L, 0.0f);
149
else
150
sEluna
->Push(L, (*result)->Fetch()[col].GetFloat());
151
return
1;
152
}
153
154
int
GetDouble
(lua_State* L,
QueryResult
* result)
155
{
156
uint32
col = luaL_checkunsigned(L, 1);
157
if
(!result || !*result || col >= (*result)->GetFieldCount())
158
sEluna
->Push(L, 0.0);
159
else
160
sEluna
->Push(L, (*result)->Fetch()[col].GetDouble());
161
return
1;
162
}
163
164
int
GetString
(lua_State* L,
QueryResult
* result)
165
{
166
uint32
col = luaL_checkunsigned(L, 1);
167
if
(!result || !*result || col >= (*result)->GetFieldCount())
168
sEluna
->Push(L,
""
);
169
else
170
sEluna
->Push(L, (*result)->Fetch()[col].GetString());
171
return
1;
172
}
173
};
uint32
std::uint32_t uint32
Definition
Define.h:77
Includes.h
sEluna
#define sEluna
Definition
LuaEngine.h:710
ObjectMethods.h
QueryResult
Skyfire::AutoPtr< ResultSet, Skyfire::Mutex > QueryResult
Definition
QueryResult.h:48
LuaQuery
Definition
QueryMethods.cpp:11
LuaQuery::GetInt16
int GetInt16(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:114
LuaQuery::GetUInt8
int GetUInt8(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:64
LuaQuery::GetUInt16
int GetUInt16(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:74
LuaQuery::NextRow
int NextRow(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:12
LuaQuery::GetRowCount
int GetRowCount(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:30
LuaQuery::GetUInt32
int GetUInt32(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:84
LuaQuery::IsNull
int IsNull(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:44
LuaQuery::GetString
int GetString(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:164
LuaQuery::GetFloat
int GetFloat(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:144
LuaQuery::GetDouble
int GetDouble(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:154
LuaQuery::GetBool
int GetBool(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:54
LuaQuery::GetColumnCount
int GetColumnCount(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:21
LuaQuery::GetInt32
int GetInt32(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:124
LuaQuery::GetUInt64
int GetUInt64(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:94
LuaQuery::GetInt8
int GetInt8(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:104
LuaQuery::GetInt64
int GetInt64(lua_State *L, QueryResult *result)
Definition
QueryMethods.cpp:134
src
server
game
LuaEngine
QueryMethods.cpp
Generated on
for Project SkyFire Core by
1.17.0