Commit 49aa79af authored by Chen Bill's avatar Chen Bill Committed by GitHub

update DataManager (#2629)

parent f2278ae7
...@@ -68,7 +68,8 @@ bool DataManager::ReadDB(sqlite3* pDB) { ...@@ -68,7 +68,8 @@ bool DataManager::ReadDB(sqlite3* pDB) {
BufferIO::DecodeUTF8(text, strBuffer); BufferIO::DecodeUTF8(text, strBuffer);
cs.text = strBuffer; cs.text = strBuffer;
} }
for (int i = 0; i < 16; ++i) { constexpr int desc_count = sizeof cs.desc / sizeof cs.desc[0];
for (int i = 0; i < desc_count; ++i) {
if (const char* text = (const char*)sqlite3_column_text(pStmt, i + 14)) { if (const char* text = (const char*)sqlite3_column_text(pStmt, i + 14)) {
BufferIO::DecodeUTF8(text, strBuffer); BufferIO::DecodeUTF8(text, strBuffer);
cs.desc[i] = strBuffer; cs.desc[i] = strBuffer;
...@@ -177,16 +178,16 @@ code_pointer DataManager::GetCodePointer(unsigned int code) const { ...@@ -177,16 +178,16 @@ code_pointer DataManager::GetCodePointer(unsigned int code) const {
string_pointer DataManager::GetStringPointer(unsigned int code) const { string_pointer DataManager::GetStringPointer(unsigned int code) const {
return _strings.find(code); return _strings.find(code);
} }
code_pointer DataManager::datas_begin() { code_pointer DataManager::datas_begin() const {
return _datas.cbegin(); return _datas.cbegin();
} }
code_pointer DataManager::datas_end() { code_pointer DataManager::datas_end() const {
return _datas.cend(); return _datas.cend();
} }
string_pointer DataManager::strings_begin() { string_pointer DataManager::strings_begin() const {
return _strings.cbegin(); return _strings.cbegin();
} }
string_pointer DataManager::strings_end() { string_pointer DataManager::strings_end() const {
return _strings.cend(); return _strings.cend();
} }
bool DataManager::GetData(unsigned int code, CardData* pData) const { bool DataManager::GetData(unsigned int code, CardData* pData) const {
......
...@@ -22,10 +22,10 @@ public: ...@@ -22,10 +22,10 @@ public:
code_pointer GetCodePointer(unsigned int code) const; code_pointer GetCodePointer(unsigned int code) const;
string_pointer GetStringPointer(unsigned int code) const; string_pointer GetStringPointer(unsigned int code) const;
code_pointer datas_begin(); code_pointer datas_begin() const;
code_pointer datas_end(); code_pointer datas_end() const;
string_pointer strings_begin(); string_pointer strings_begin() const;
string_pointer strings_end(); string_pointer strings_end() const;
bool GetData(unsigned int code, CardData* pData) const; bool GetData(unsigned int code, CardData* pData) const;
bool GetString(unsigned int code, CardString* pStr) const; bool GetString(unsigned int code, CardString* pStr) const;
const wchar_t* GetName(unsigned int code) const; const wchar_t* GetName(unsigned int code) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment