From e585187b248f48b3c6e9247b49fa07c6565d65e5 Mon Sep 17 00:00:00 2001 From: maximius Date: Sat, 17 Oct 2009 15:51:44 -0700 Subject: *Backed out changeset 3be01fb200a5 --HG-- branch : trunk --- src/shared/Database/SQLStorage.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/shared/Database/SQLStorage.h') diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 96f817c64e7..cc165af532e 100644 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -17,21 +17,27 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef SQLSTORAGE_H #define SQLSTORAGE_H + #include "Common.h" #include "Database/DatabaseEnv.h" + class SQLStorage { template friend struct SQLStorageLoaderBase; + public: + SQLStorage(const char* fmt, const char * _entry_field, const char * sqlname) { src_format = fmt; dst_format = fmt; init(_entry_field, sqlname); } + SQLStorage(const char* src_fmt, const char* dst_fmt, const char * _entry_field, const char * sqlname) { src_format = src_fmt; @@ -39,10 +45,12 @@ class SQLStorage init(_entry_field, sqlname); } + ~SQLStorage() { Free(); } + template T const* LookupEntry(uint32 id) const { @@ -52,12 +60,16 @@ class SQLStorage return NULL; return reinterpret_cast(pIndex[id]); } + uint32 RecordCount; uint32 MaxEntry; uint32 iNumFields; + char const* GetTableName() const { return table; } + void Load(); void Free(); + private: void init(const char * _entry_field, const char * sqlname) { @@ -68,7 +80,9 @@ class SQLStorage iNumFields = strlen(src_format); MaxEntry = 0; } + char** pIndex; + char *data; const char *src_format; const char *dst_format; @@ -76,11 +90,13 @@ class SQLStorage const char *entry_field; //bool HasString; }; + template struct SQLStorageLoaderBase { public: void Load(SQLStorage &storage); + template void convert(uint32 field_pos, S src, D &dst); template @@ -88,13 +104,16 @@ struct SQLStorageLoaderBase template void convert_from_str(uint32 field_pos, char * src, D& dst); void convert_str_to_str(uint32 field_pos, char *src, char *&dst); + private: template void storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset); void storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset); }; + struct SQLStorageLoader : public SQLStorageLoaderBase { }; + #endif -- cgit v1.2.3