AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
DBCStorage< T > Class Template Reference

#include "DBCStore.h"

Inheritance diagram for DBCStorage< T >:
DBCStorageBase

Public Types

typedef DBCStorageIterator< T > iterator
 

Public Member Functions

 DBCStorage (char const *fmt)
 
 ~DBCStorage () override
 
T const * LookupEntry (uint32 id) const
 
T const * AssertEntry (uint32 id) const
 
void SetEntry (uint32 id, T *t)
 
uint32 GetNumRows () const
 
bool Load (char const *path) override
 
bool LoadStringsFrom (char const *path) override
 
void LoadFromDB (char const *table, char const *format) override
 
iterator begin ()
 
iterator end ()
 
- Public Member Functions inherited from DBCStorageBase
 DBCStorageBase (char const *fmt)
 
virtual ~DBCStorageBase ()
 
char const * GetFormat () const
 
uint32 GetFieldCount () const
 
virtual bool Load (char const *path)=0
 
virtual bool LoadStringsFrom (char const *path)=0
 
virtual void LoadFromDB (char const *table, char const *format)=0
 

Private Member Functions

 DBCStorage (DBCStorage const &right)=delete
 
DBCStorageoperator= (DBCStorage const &right)=delete
 

Private Attributes

union {
   T **   AsT
 
   char **   AsChar
 
_indexTable
 

Additional Inherited Members

- Protected Member Functions inherited from DBCStorageBase
bool Load (char const *path, char **&indexTable)
 
bool LoadStringsFrom (char const *path, char **indexTable)
 
void LoadFromDB (char const *table, char const *format, char **&indexTable)
 
- Protected Attributes inherited from DBCStorageBase
uint32 _fieldCount
 
char const * _fileFormat
 
char * _dataTable
 
std::vector< char * > _stringPool
 
uint32 _indexTableSize
 

Detailed Description

template<class T>
class DBCStorage< T >

Member Typedef Documentation

◆ iterator

template<class T >
typedef DBCStorageIterator<T> DBCStorage< T >::iterator

Constructor & Destructor Documentation

◆ DBCStorage() [1/2]

template<class T >
DBCStorage< T >::DBCStorage ( char const *  fmt)
inlineexplicit
59 : DBCStorageBase(fmt)
60 {
61 _indexTable.AsT = nullptr;
62 }
Interface class for common access.
Definition: DBCStore.h:29
union DBCStorage::@309 _indexTable

References DBCStorage< T >::_indexTable.

◆ ~DBCStorage()

template<class T >
DBCStorage< T >::~DBCStorage ( )
inlineoverride
65 {
66 delete[] reinterpret_cast<char*>(_indexTable.AsT);
67 }

References DBCStorage< T >::_indexTable.

◆ DBCStorage() [2/2]

template<class T >
DBCStorage< T >::DBCStorage ( DBCStorage< T > const &  right)
privatedelete

Member Function Documentation

◆ AssertEntry()

template<class T >
T const * DBCStorage< T >::AssertEntry ( uint32  id) const
inline
70{ return ASSERT_NOTNULL(LookupEntry(id)); }
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:85
T const * LookupEntry(uint32 id) const
Definition: DBCStore.h:69

References ASSERT_NOTNULL, and DBCStorage< T >::LookupEntry().

◆ begin()

template<class T >
iterator DBCStorage< T >::begin ( )
inline
108{ return iterator(_indexTable.AsT, _indexTableSize); }
uint32 _indexTableSize
Definition: DBCStore.h:50
DBCStorageIterator< T > iterator
Definition: DBCStore.h:57

References DBCStorage< T >::_indexTable, and DBCStorageBase::_indexTableSize.

◆ end()

template<class T >
iterator DBCStorage< T >::end ( )
inline

◆ GetNumRows()

template<class T >
uint32 DBCStorage< T >::GetNumRows ( ) const
inline
91{ return _indexTableSize; }

References DBCStorageBase::_indexTableSize.

Referenced by LoadDBC().

◆ Load()

template<class T >
bool DBCStorage< T >::Load ( char const *  path)
inlineoverridevirtual

Implements DBCStorageBase.

94 {
95 return DBCStorageBase::Load(path, _indexTable.AsChar);
96 }
virtual bool Load(char const *path)=0

References DBCStorage< T >::_indexTable, and DBCStorageBase::Load().

Referenced by LoadDBC().

◆ LoadFromDB()

template<class T >
void DBCStorage< T >::LoadFromDB ( char const *  table,
char const *  format 
)
inlineoverridevirtual

Implements DBCStorageBase.

104 {
105 DBCStorageBase::LoadFromDB(table, format, _indexTable.AsChar);
106 }
virtual void LoadFromDB(char const *table, char const *format)=0

References DBCStorage< T >::_indexTable, and DBCStorageBase::LoadFromDB().

Referenced by LoadDBC().

◆ LoadStringsFrom()

template<class T >
bool DBCStorage< T >::LoadStringsFrom ( char const *  path)
inlineoverridevirtual

Implements DBCStorageBase.

99 {
100 return DBCStorageBase::LoadStringsFrom(path, _indexTable.AsChar);
101 }
virtual bool LoadStringsFrom(char const *path)=0

References DBCStorage< T >::_indexTable, and DBCStorageBase::LoadStringsFrom().

Referenced by LoadDBC().

◆ LookupEntry()

template<class T >
T const * DBCStorage< T >::LookupEntry ( uint32  id) const
inline
69{ return (id >= _indexTableSize) ? nullptr : _indexTable.AsT[id]; }

References DBCStorage< T >::_indexTable, and DBCStorageBase::_indexTableSize.

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

◆ operator=()

template<class T >
DBCStorage & DBCStorage< T >::operator= ( DBCStorage< T > const &  right)
privatedelete

◆ SetEntry()

template<class T >
void DBCStorage< T >::SetEntry ( uint32  id,
T *  t 
)
inline
73 {
74 if (id >= _indexTableSize)
75 {
76 // Resize
77 typedef char* ptr;
78 std::size_t newSize = id + 1;
79 ptr* newArr = new ptr[newSize];
80 memset(newArr, 0, newSize * sizeof(ptr));
81 memcpy(newArr, _indexTable.AsChar, _indexTableSize * sizeof(ptr));
82 delete[] reinterpret_cast<char*>(_indexTable.AsT);
83 _indexTable.AsChar = newArr;
84 _indexTableSize = newSize;
85 }
86
87 delete _indexTable.AsT[id];
88 _indexTable.AsT[id] = t;
89 }

References DBCStorage< T >::_indexTable, and DBCStorageBase::_indexTableSize.

Member Data Documentation

◆ 

◆ AsChar

template<class T >
char** DBCStorage< T >::AsChar

◆ AsT

template<class T >
T** DBCStorage< T >::AsT