mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[12023] Enable SQL-Storage to work with entries of value zero
This commit is contained in:
parent
a309de2e6d
commit
314c448a3d
2 changed files with 24 additions and 26 deletions
|
|
@ -28,22 +28,20 @@ class SQLStorage
|
|||
friend struct SQLStorageLoaderBase;
|
||||
|
||||
public:
|
||||
|
||||
SQLStorage(const char* fmt, const char * _entry_field, const char * sqlname)
|
||||
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)
|
||||
SQLStorage(const char* src_fmt, const char* dst_fmt, const char* _entry_field, const char* sqlname)
|
||||
{
|
||||
src_format = src_fmt;
|
||||
dst_format = dst_fmt;
|
||||
init(_entry_field, sqlname);
|
||||
}
|
||||
|
||||
|
||||
~SQLStorage()
|
||||
{
|
||||
Free();
|
||||
|
|
@ -52,9 +50,7 @@ class SQLStorage
|
|||
template<class T>
|
||||
T const* LookupEntry(uint32 id) const
|
||||
{
|
||||
if( id == 0 )
|
||||
return NULL;
|
||||
if(id >= MaxEntry)
|
||||
if (id >= MaxEntry)
|
||||
return NULL;
|
||||
return reinterpret_cast<T const*>(pIndex[id]);
|
||||
}
|
||||
|
|
@ -70,13 +66,14 @@ class SQLStorage
|
|||
void Free();
|
||||
|
||||
void EraseEntry(uint32 id);
|
||||
|
||||
private:
|
||||
void init(const char * _entry_field, const char * sqlname)
|
||||
void init(const char* _entry_field, const char* sqlname)
|
||||
{
|
||||
entry_field = _entry_field;
|
||||
table=sqlname;
|
||||
data=NULL;
|
||||
pIndex=NULL;
|
||||
data = NULL;
|
||||
pIndex = NULL;
|
||||
iNumFields = strlen(src_format);
|
||||
oNumFields = strlen(dst_format);
|
||||
MaxEntry = 0;
|
||||
|
|
@ -84,11 +81,11 @@ class SQLStorage
|
|||
|
||||
char** pIndex;
|
||||
|
||||
char *data;
|
||||
const char *src_format;
|
||||
const char *dst_format;
|
||||
const char *table;
|
||||
const char *entry_field;
|
||||
char* data;
|
||||
const char* src_format;
|
||||
const char* dst_format;
|
||||
const char* table;
|
||||
const char* entry_field;
|
||||
//bool HasString;
|
||||
};
|
||||
|
||||
|
|
@ -96,30 +93,31 @@ template <class T>
|
|||
struct SQLStorageLoaderBase
|
||||
{
|
||||
public:
|
||||
void Load(SQLStorage &storage, bool error_at_empty = true);
|
||||
void Load(SQLStorage& storage, bool error_at_empty = true);
|
||||
|
||||
template<class S, class D>
|
||||
void convert(uint32 field_pos, S src, D &dst);
|
||||
void convert(uint32 field_pos, S src, D& dst);
|
||||
template<class S>
|
||||
void convert_to_str(uint32 field_pos, S src, char * & dst);
|
||||
void convert_to_str(uint32 field_pos, S src, char*& dst);
|
||||
template<class D>
|
||||
void convert_from_str(uint32 field_pos, char const* src, D& dst);
|
||||
void convert_str_to_str(uint32 field_pos, char const* src, char *&dst);
|
||||
void convert_str_to_str(uint32 field_pos, char const* src, char*& dst);
|
||||
template<class S, class D>
|
||||
void default_fill(uint32 field_pos, S src, D &dst);
|
||||
void default_fill_to_str(uint32 field_pos, char const* src, char * & dst);
|
||||
void default_fill(uint32 field_pos, S src, D& dst);
|
||||
void default_fill_to_str(uint32 field_pos, char const* src, char*& dst);
|
||||
|
||||
// trap, no body
|
||||
template<class D>
|
||||
void convert_from_str(uint32 field_pos, char* src, D& dst);
|
||||
void convert_str_to_str(uint32 field_pos, char* src, char *&dst);
|
||||
void convert_str_to_str(uint32 field_pos, char* src, char*& dst);
|
||||
|
||||
private:
|
||||
template<class V>
|
||||
void storeValue(V value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
|
||||
void storeValue(char const* value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
|
||||
void storeValue(V value, SQLStorage& store, char* p, uint32 x, uint32& offset);
|
||||
void storeValue(char const* value, SQLStorage& store, char* p, uint32 x, uint32& offset);
|
||||
|
||||
// trap, no body
|
||||
void storeValue(char * value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
|
||||
void storeValue(char* value, SQLStorage& store, char* p, uint32 x, uint32& offset);
|
||||
};
|
||||
|
||||
struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12022"
|
||||
#define REVISION_NR "12023"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue