Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / nelns / login_service / mysql_helper.h
blob0de11088af00bf4cd920b1a8e5750cf50970c767
1 // NeLNS - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef NL_MYSQL_HELPER_H
21 #define NL_MYSQL_HELPER_H
25 // Includes
28 // we have to include windows.h because mysql.h uses it but not include it
29 #ifdef NL_OS_WINDOWS
30 # ifndef NL_COMP_MINGW
31 # define NOMINMAX
32 # endif
33 # include <winsock2.h>
34 # include <windows.h>
35 typedef unsigned long ulong;
36 #endif
38 #include <mysql.h>
40 #include "nel/misc/types_nl.h"
44 // Variables
47 extern MYSQL *DatabaseConnection;
51 // Classes
54 class CMysqlResult
56 public:
57 CMysqlResult() : Result(0) { }
58 CMysqlResult(MYSQL_RES *result)
60 if(Result) mysql_free_result(Result);
61 Result = result;
64 ~CMysqlResult()
66 if(Result) mysql_free_result(Result);
69 CMysqlResult& operator=(MYSQL_RES *result)
71 if(Result) mysql_free_result(Result);
72 Result = result;
73 return *this;
76 operator MYSQL_RES*() { return Result; }
78 private:
79 //we don't want user to do a copy
80 CMysqlResult(const CMysqlResult &mysqlResult){}
81 MYSQL_RES *Result;
86 // Functions
89 void sqlInit();
90 std::string sqlQuery(const std::string &query);
91 std::string sqlQuery(const std::string &query, sint32 &nbRow, MYSQL_ROW &firstRow, CMysqlResult &result);
93 #endif // NL_MYSQL_HELPER_H
95 /* End of mysql_helper.h */