2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "Database/DatabaseEnv.h"
28 friend struct SQLStorageLoaderBase
;
32 SQLStorage(const char* fmt
, const char * _entry_field
, const char * sqlname
)
36 init(_entry_field
, sqlname
);
39 SQLStorage(const char* src_fmt
, const char* dst_fmt
, const char * _entry_field
, const char * sqlname
)
43 init(_entry_field
, sqlname
);
53 T
const* LookupEntry(uint32 id
) const
59 return reinterpret_cast<T
const*>(pIndex
[id
]);
70 void init(const char * _entry_field
, const char * sqlname
)
72 entry_field
= _entry_field
;
76 iNumFields
= strlen(src_format
);
83 const char *src_format
;
84 const char *dst_format
;
86 const char *entry_field
;
91 struct SQLStorageLoaderBase
94 void Load(SQLStorage
&storage
);
96 template<class S
, class D
>
97 void convert(uint32 field_pos
, S src
, D
&dst
);
99 void convert_to_str(uint32 field_pos
, S src
, char * & dst
);
101 void convert_from_str(uint32 field_pos
, char * src
, D
& dst
);
102 void convert_str_to_str(uint32 field_pos
, char *src
, char *&dst
);
106 void storeValue(V value
, SQLStorage
&store
, char *p
, int x
, uint32
&offset
);
107 void storeValue(char * value
, SQLStorage
&store
, char *p
, int x
, uint32
&offset
);
110 struct SQLStorageLoader
: public SQLStorageLoaderBase
<SQLStorageLoader
>