![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 #ifndef __SRADATA_DBSTREAM_H 00002 #define __SRADATA_DBSTREAM_H 00003 00004 #include "stdafx.h" 00005 00006 #include <stdint.h> 00007 #include <stdio.h> 00008 #include <stdlib.h> 00009 #include <iostream> 00010 #include <map> 00011 #include <memory> 00012 00013 #include <cppconn/driver.h> 00014 #include <cppconn/exception.h> 00015 #include <cppconn/resultset.h> 00016 #include <cppconn/statement.h> 00017 #include <cppconn/prepared_statement.h> 00018 00019 #include "ManagedDictionary.h" 00020 #include "DbConnectionFactory.h" 00021 00022 //http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-stored-routines-statements.html 00023 00024 namespace SraData 00025 { 00041 class DbStream 00042 { 00043 protected: 00044 //instance fields 00045 sql::Connection* _connection; 00046 std::auto_ptr<sql::Statement> _stmt; 00047 std::auto_ptr<sql::ResultSet> _result; 00048 int _id; 00049 bool _firstRowFlag; 00050 00051 //static fields 00052 static ManagedDictionary<int, DbStream> _Streams; 00053 static int _SerialNumber; 00054 00055 //protected static methods 00056 00061 static int GetStreamId(); 00062 00063 //protected instance methods 00064 00068 bool checkHasMoreRows(); 00069 00074 bool execute(const std::string& query); 00075 00076 public: 00081 static const int InitStreamId = 0; 00082 00086 static DbStream* StartStream(const std::string& query); 00087 00092 static DbStream* RetrieveStream(int* id); 00093 00098 static bool CheckHasMoreRows(DbStream* stream, int* newId); 00099 00103 DbStream(); 00104 00109 ~DbStream(); 00110 00114 int getInt(int index); 00115 00119 bool getBool(int index); 00120 }; 00121 } 00122 00123 #endif
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.