AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
DBCStorageBase Class Referenceabstract

Interface class for common access. More...

#include "DBCStore.h"

Inheritance diagram for DBCStorageBase:
DBCStorage< T >

Public Member Functions

 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
 

Protected Member Functions

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

uint32 _fieldCount
 
char const * _fileFormat
 
char * _dataTable
 
std::vector< char * > _stringPool
 
uint32 _indexTableSize
 

Detailed Description

Interface class for common access.

Constructor & Destructor Documentation

◆ DBCStorageBase()

DBCStorageBase::DBCStorageBase ( char const *  fmt)
21 : _fieldCount(0), _fileFormat(fmt), _dataTable(nullptr), _indexTableSize(0)
22{
23}
char const * _fileFormat
Definition: DBCStore.h:47
uint32 _indexTableSize
Definition: DBCStore.h:50
uint32 _fieldCount
Definition: DBCStore.h:46
char * _dataTable
Definition: DBCStore.h:48

◆ ~DBCStorageBase()

DBCStorageBase::~DBCStorageBase ( )
virtual
26{
27 delete[] _dataTable;
28 for (char* strings : _stringPool)
29 delete[] strings;
30}
std::vector< char * > _stringPool
Definition: DBCStore.h:49

References _dataTable, and _stringPool.

Member Function Documentation

◆ GetFieldCount()

uint32 DBCStorageBase::GetFieldCount ( ) const
inline
35{ return _fieldCount; }

References _fieldCount.

Referenced by LoadDBC().

◆ GetFormat()

char const * DBCStorageBase::GetFormat ( ) const
inline
34{ return _fileFormat; }

References _fileFormat.

Referenced by LoadDBC().

◆ Load() [1/2]

virtual bool DBCStorageBase::Load ( char const *  path)
pure virtual

Implemented in DBCStorage< T >.

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

◆ Load() [2/2]

bool DBCStorageBase::Load ( char const *  path,
char **&  indexTable 
)
protected
33{
34 indexTable = nullptr;
35
36 DBCFileLoader dbc;
37
38 // Check if load was sucessful, only then continue
39 if (!dbc.Load(path, _fileFormat))
40 return false;
41
42 _fieldCount = dbc.GetCols();
43
44 // load raw non-string data
46
47 // load strings from dbc data
48 if (char* stringBlock = dbc.AutoProduceStrings(_fileFormat, _dataTable))
49 _stringPool.push_back(stringBlock);
50
51 // error in dbc file at loading if nullptr
52 return indexTable != nullptr;
53}
Definition: DBCFileLoader.h:39
char * AutoProduceStrings(char const *fmt, char *dataTable)
Definition: DBCFileLoader.cpp:277
bool Load(const char *filename, const char *fmt)
Definition: DBCFileLoader.cpp:25
uint32 GetCols() const
Definition: DBCFileLoader.h:92
char * AutoProduceData(char const *fmt, uint32 &count, char **&indexTable)
Definition: DBCFileLoader.cpp:177

References _dataTable, _fieldCount, _fileFormat, _indexTableSize, _stringPool, DBCFileLoader::AutoProduceData(), DBCFileLoader::AutoProduceStrings(), DBCFileLoader::GetCols(), and DBCFileLoader::Load().

◆ LoadFromDB() [1/2]

virtual void DBCStorageBase::LoadFromDB ( char const *  table,
char const *  format 
)
pure virtual

Implemented in DBCStorage< T >.

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

◆ LoadFromDB() [2/2]

void DBCStorageBase::LoadFromDB ( char const *  table,
char const *  format,
char **&  indexTable 
)
protected
75{
76 _stringPool.push_back(DBCDatabaseLoader(table, format, _stringPool).Load(_indexTableSize, indexTable));
77}
Definition: DBCDatabaseLoader.h:26
virtual bool Load(char const *path)=0

References _indexTableSize, _stringPool, and Load().

◆ LoadStringsFrom() [1/2]

virtual bool DBCStorageBase::LoadStringsFrom ( char const *  path)
pure virtual

Implemented in DBCStorage< T >.

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

◆ LoadStringsFrom() [2/2]

bool DBCStorageBase::LoadStringsFrom ( char const *  path,
char **  indexTable 
)
protected
56{
57 // DBC must be already loaded using Load
58 if (!indexTable)
59 return false;
60
61 DBCFileLoader dbc;
62
63 // Check if load was successful, only then continue
64 if (!dbc.Load(path, _fileFormat))
65 return false;
66
67 // load strings from another locale dbc data
68 if (char* stringBlock = dbc.AutoProduceStrings(_fileFormat, _dataTable))
69 _stringPool.push_back(stringBlock);
70
71 return true;
72}

References _dataTable, _fileFormat, _stringPool, DBCFileLoader::AutoProduceStrings(), and DBCFileLoader::Load().

Member Data Documentation

◆ _dataTable

char* DBCStorageBase::_dataTable
protected

◆ _fieldCount

uint32 DBCStorageBase::_fieldCount
protected

Referenced by GetFieldCount(), and Load().

◆ _fileFormat

char const* DBCStorageBase::_fileFormat
protected

Referenced by GetFormat(), Load(), and LoadStringsFrom().

◆ _indexTableSize

◆ _stringPool

std::vector<char*> DBCStorageBase::_stringPool
protected