OregonCore  revision be9e804-git
Your Favourite TBC server
DBCStorage< T > Class Template Reference

#include <DBCStore.h>

Public Member Functions

 DBCStorage (const char *f)
 
 ~DBCStorage ()
 
T const * LookupEntry (uint32 id) const
 
uint32 GetNumRows () const
 
char const * GetFormat () const
 
uint32 GetFieldCount () const
 
bool Load (char const *fn)
 
bool LoadStringsFrom (char const *fn)
 
void Clear ()
 

Private Types

typedef std::list< char * > StringPoolList
 

Private Attributes

char const * fmt
 
uint32 nCount
 
uint32 fieldCount
 
T ** indexTable
 
T * m_dataTable
 
StringPoolList m_stringPoolList
 

Detailed Description

template<class T>
class DBCStorage< T >

Definition at line 24 of file DBCStore.h.

Member Typedef Documentation

template<class T>
typedef std::list<char*> DBCStorage< T >::StringPoolList
private

Definition at line 26 of file DBCStore.h.

Constructor & Destructor Documentation

template<class T>
DBCStorage< T >::DBCStorage ( const char *  f)
inlineexplicit

Definition at line 28 of file DBCStore.h.

28 : fmt(f), nCount(0), fieldCount(0), indexTable(NULL), m_dataTable(NULL) { }
uint32 fieldCount
Definition: DBCStore.h:104
T * m_dataTable
Definition: DBCStore.h:106
char const * fmt
Definition: DBCStore.h:102
T ** indexTable
Definition: DBCStore.h:105
uint32 nCount
Definition: DBCStore.h:103
template<class T>
DBCStorage< T >::~DBCStorage ( )
inline

Definition at line 29 of file DBCStore.h.

References DBCStorage< T >::Clear().

30  {
31  Clear();
32  }
void Clear()
Definition: DBCStore.h:83

Member Function Documentation

template<class T>
void DBCStorage< T >::Clear ( void  )
inline

Definition at line 83 of file DBCStore.h.

References DBCStorage< T >::indexTable, DBCStorage< T >::m_dataTable, DBCStorage< T >::m_stringPoolList, and DBCStorage< T >::nCount.

Referenced by DBCStorage< T >::~DBCStorage().

84  {
85  if (!indexTable)
86  return;
87 
88  delete[] ((char*)indexTable);
89  indexTable = NULL;
90  delete[] ((char*)m_dataTable);
91  m_dataTable = NULL;
92 
93  while (!m_stringPoolList.empty())
94  {
95  delete[] m_stringPoolList.front();
96  m_stringPoolList.pop_front();
97  }
98  nCount = 0;
99  }
T * m_dataTable
Definition: DBCStore.h:106
StringPoolList m_stringPoolList
Definition: DBCStore.h:107
T ** indexTable
Definition: DBCStore.h:105
uint32 nCount
Definition: DBCStore.h:103
template<class T>
uint32 DBCStorage< T >::GetFieldCount ( ) const
inline

Definition at line 46 of file DBCStore.h.

References DBCStorage< T >::fieldCount.

Referenced by LoadDBC().

47  {
48  return fieldCount;
49  }
uint32 fieldCount
Definition: DBCStore.h:104
template<class T>
char const* DBCStorage< T >::GetFormat ( ) const
inline

Definition at line 42 of file DBCStore.h.

References DBCStorage< T >::fmt.

Referenced by LoadDBC().

43  {
44  return fmt;
45  }
char const * fmt
Definition: DBCStore.h:102
template<class T>
uint32 DBCStorage< T >::GetNumRows ( ) const
inline

Definition at line 38 of file DBCStore.h.

References DBCStorage< T >::nCount.

39  {
40  return nCount;
41  }
uint32 nCount
Definition: DBCStore.h:103
template<class T>
bool DBCStorage< T >::Load ( char const *  fn)
inline

Definition at line 51 of file DBCStore.h.

References DBCFileLoader::AutoProduceData(), DBCFileLoader::AutoProduceStrings(), DBCStorage< T >::fieldCount, DBCStorage< T >::fmt, DBCFileLoader::GetCols(), DBCStorage< T >::indexTable, DBCFileLoader::Load(), DBCStorage< T >::m_dataTable, DBCStorage< T >::m_stringPoolList, and DBCStorage< T >::nCount.

Referenced by LoadDBC().

52  {
53  DBCFileLoader dbc;
54  // Check if load was sucessful, only then continue
55  if (!dbc.Load(fn, fmt))
56  return false;
57 
58  fieldCount = dbc.GetCols();
59  m_dataTable = (T*)dbc.AutoProduceData(fmt, nCount, (char**&)indexTable);
60 
61  m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
62 
63  // error in dbc file at loading if NULL
64  return indexTable != NULL;
65  }
uint32 fieldCount
Definition: DBCStore.h:104
char * AutoProduceData(const char *fmt, uint32 &count, char **&indexTable)
T * m_dataTable
Definition: DBCStore.h:106
char const * fmt
Definition: DBCStore.h:102
bool Load(const char *filename, const char *fmt)
char * AutoProduceStrings(const char *fmt, char *dataTable)
StringPoolList m_stringPoolList
Definition: DBCStore.h:107
uint32 GetCols() const
Definition: DBCFileLoader.h:93
T ** indexTable
Definition: DBCStore.h:105
uint32 nCount
Definition: DBCStore.h:103
template<class T>
bool DBCStorage< T >::LoadStringsFrom ( char const *  fn)
inline

Definition at line 67 of file DBCStore.h.

References DBCFileLoader::AutoProduceStrings(), DBCStorage< T >::fmt, DBCStorage< T >::indexTable, DBCFileLoader::Load(), DBCStorage< T >::m_dataTable, and DBCStorage< T >::m_stringPoolList.

Referenced by LoadDBC().

68  {
69  // DBC must be already loaded using Load
70  if (!indexTable)
71  return false;
72 
73  DBCFileLoader dbc;
74  // Check if load was successful, only then continue
75  if (!dbc.Load(fn, fmt))
76  return false;
77 
78  m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable));
79 
80  return true;
81  }
T * m_dataTable
Definition: DBCStore.h:106
char const * fmt
Definition: DBCStore.h:102
bool Load(const char *filename, const char *fmt)
char * AutoProduceStrings(const char *fmt, char *dataTable)
StringPoolList m_stringPoolList
Definition: DBCStore.h:107
T ** indexTable
Definition: DBCStore.h:105
template<class T>
T const* DBCStorage< T >::LookupEntry ( uint32  id) const
inline

Definition at line 34 of file DBCStore.h.

References DBCStorage< T >::indexTable, and DBCStorage< T >::nCount.

35  {
36  return (id >= nCount) ? NULL : indexTable[id];
37  }
T ** indexTable
Definition: DBCStore.h:105
uint32 nCount
Definition: DBCStore.h:103

Member Data Documentation

template<class T>
uint32 DBCStorage< T >::fieldCount
private

Definition at line 104 of file DBCStore.h.

Referenced by DBCStorage< T >::GetFieldCount(), and DBCStorage< T >::Load().

template<class T>
char const* DBCStorage< T >::fmt
private
template<class T>
T** DBCStorage< T >::indexTable
private
template<class T>
T* DBCStorage< T >::m_dataTable
private
template<class T>
StringPoolList DBCStorage< T >::m_stringPoolList
private
template<class T>
uint32 DBCStorage< T >::nCount
private

The documentation for this class was generated from the following file: