aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/DataStores/DB2Store.cpp20
-rw-r--r--src/server/shared/DataStores/DB2Store.h16
2 files changed, 14 insertions, 22 deletions
diff --git a/src/server/shared/DataStores/DB2Store.cpp b/src/server/shared/DataStores/DB2Store.cpp
index b33e050f644..bfa333ec448 100644
--- a/src/server/shared/DataStores/DB2Store.cpp
+++ b/src/server/shared/DataStores/DB2Store.cpp
@@ -20,6 +20,7 @@
#include "DB2DatabaseLoader.h"
#include "DB2FileSystemSource.h"
#include "DB2Meta.h"
+#include "StringFormat.h"
DB2StorageBase::DB2StorageBase(char const* fileName, DB2LoadInfo const* loadInfo)
: _tableHash(0), _layoutHash(0), _fileName(fileName), _fieldCount(0), _loadInfo(loadInfo), _dataTable(nullptr), _dataTableEx(), _indexTableSize(0)
@@ -83,14 +84,13 @@ void DB2StorageBase::WriteRecordData(char const* entry, LocaleConstant locale, B
}
}
-bool DB2StorageBase::Load(std::string const& path, LocaleConstant locale, char**& indexTable)
+void DB2StorageBase::Load(std::string const& path, LocaleConstant locale, char**& indexTable)
{
indexTable = nullptr;
DB2FileLoader db2;
DB2FileSystemSource source(path + _fileName);
// Check if load was successful, only then continue
- if (!db2.Load(&source, _loadInfo))
- return false;
+ db2.Load(&source, _loadInfo);
_fieldCount = db2.GetCols();
_tableHash = db2.GetTableHash();
@@ -98,37 +98,29 @@ bool DB2StorageBase::Load(std::string const& path, LocaleConstant locale, char**
// load raw non-string data
_dataTable = db2.AutoProduceData(_indexTableSize, indexTable);
- if (!_dataTable)
- return false;
// load strings from db2 data
if (char* stringBlock = db2.AutoProduceStrings(indexTable, _indexTableSize, locale))
_stringPool.push_back(stringBlock);
db2.AutoProduceRecordCopies(_indexTableSize, indexTable, _dataTable);
-
- // error in db2 file at loading if NULL
- return indexTable != nullptr;
}
-bool DB2StorageBase::LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable)
+void DB2StorageBase::LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable)
{
// DB2 must be already loaded using Load
if (!indexTable)
- return false;
+ throw DB2FileLoadException(Trinity::StringFormat("%s was not loaded properly, cannot load strings", path.c_str()));
DB2FileLoader db2;
DB2FileSystemSource source(path + _fileName);
// Check if load was successful, only then continue
- if (!db2.Load(&source, _loadInfo))
- return false;
+ db2.Load(&source, _loadInfo);
// load strings from another locale db2 data
if (_loadInfo->GetStringFieldCount(true))
if (char* stringBlock = db2.AutoProduceStrings(indexTable, _indexTableSize, locale))
_stringPool.push_back(stringBlock);
-
- return true;
}
void DB2StorageBase::LoadFromDB(char**& indexTable)
diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h
index c670d418b13..faf12428251 100644
--- a/src/server/shared/DataStores/DB2Store.h
+++ b/src/server/shared/DataStores/DB2Store.h
@@ -44,15 +44,15 @@ public:
uint32 GetFieldCount() const { return _fieldCount; }
DB2LoadInfo const* GetLoadInfo() const { return _loadInfo; }
- virtual bool Load(std::string const& path, LocaleConstant locale) = 0;
- virtual bool LoadStringsFrom(std::string const& path, LocaleConstant locale) = 0;
+ virtual void Load(std::string const& path, LocaleConstant locale) = 0;
+ virtual void LoadStringsFrom(std::string const& path, LocaleConstant locale) = 0;
virtual void LoadFromDB() = 0;
virtual void LoadStringsFromDB(LocaleConstant locale) = 0;
protected:
void WriteRecordData(char const* entry, LocaleConstant locale, ByteBuffer& buffer) const;
- bool Load(std::string const& path, LocaleConstant locale, char**& indexTable);
- bool LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable);
+ void Load(std::string const& path, LocaleConstant locale, char**& indexTable);
+ void LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable);
void LoadFromDB(char**& indexTable);
void LoadStringsFromDB(LocaleConstant locale, char** indexTable);
@@ -77,12 +77,12 @@ public:
DB2Storage(char const* fileName, DB2LoadInfo const* loadInfo) : DB2StorageBase(fileName, loadInfo)
{
- _indexTable.AsT = nullptr;
+ _indexTable.AsChar = nullptr;
}
~DB2Storage()
{
- delete[] reinterpret_cast<char*>(_indexTable.AsT);
+ delete[] _indexTable.AsChar;
}
bool HasRecord(uint32 id) const override { return id < _indexTableSize && _indexTable.AsT[id] != nullptr; }
@@ -98,12 +98,12 @@ public:
T const* operator[](uint32 id) const { return LookupEntry(id); }
uint32 GetNumRows() const { return _indexTableSize; }
- bool Load(std::string const& path, LocaleConstant locale) override
+ void Load(std::string const& path, LocaleConstant locale) override
{
return DB2StorageBase::Load(path, locale, _indexTable.AsChar);
}
- bool LoadStringsFrom(std::string const& path, LocaleConstant locale) override
+ void LoadStringsFrom(std::string const& path, LocaleConstant locale) override
{
return DB2StorageBase::LoadStringsFrom(path, locale, _indexTable.AsChar);
}