refactor: unglob std::wstring
This commit is contained in:
@@ -24,7 +24,7 @@ void ArchiveFile::_readHeader(DataInputStream *dis)
|
||||
}
|
||||
else meta->isCompressed = false;
|
||||
|
||||
m_index.insert( pair<wstring,PMetaData>(meta->filename,meta) );
|
||||
m_index.insert( pair<std::wstring,PMetaData>(meta->filename,meta) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ ArchiveFile::~ArchiveFile()
|
||||
delete m_cachedData;
|
||||
}
|
||||
|
||||
vector<wstring> *ArchiveFile::getFileList()
|
||||
vector<std::wstring> *ArchiveFile::getFileList()
|
||||
{
|
||||
vector<wstring> *out = new vector<wstring>();
|
||||
vector<std::wstring> *out = new vector<std::wstring>();
|
||||
|
||||
for ( AUTO_VAR(it, m_index.begin());
|
||||
it != m_index.end();
|
||||
@@ -87,17 +87,17 @@ vector<wstring> *ArchiveFile::getFileList()
|
||||
return out;
|
||||
}
|
||||
|
||||
bool ArchiveFile::hasFile(const wstring &filename)
|
||||
bool ArchiveFile::hasFile(const std::wstring &filename)
|
||||
{
|
||||
return m_index.find(filename) != m_index.end();
|
||||
}
|
||||
|
||||
int ArchiveFile::getFileSize(const wstring &filename)
|
||||
int ArchiveFile::getFileSize(const std::wstring &filename)
|
||||
{
|
||||
return hasFile(filename) ? m_index.at(filename)->filesize : -1;
|
||||
}
|
||||
|
||||
byteArray ArchiveFile::getFile(const wstring &filename)
|
||||
byteArray ArchiveFile::getFile(const std::wstring &filename)
|
||||
{
|
||||
byteArray out;
|
||||
AUTO_VAR(it,m_index.find(filename));
|
||||
|
||||
@@ -16,14 +16,14 @@ protected:
|
||||
|
||||
typedef struct _MetaData
|
||||
{
|
||||
wstring filename;
|
||||
std::wstring filename;
|
||||
int ptr;
|
||||
int filesize;
|
||||
bool isCompressed;
|
||||
|
||||
} MetaData, *PMetaData;
|
||||
|
||||
std::unordered_map<wstring, PMetaData> m_index;
|
||||
std::unordered_map<std::wstring, PMetaData> m_index;
|
||||
|
||||
public:
|
||||
void _readHeader(DataInputStream *dis);
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
ArchiveFile(File file);
|
||||
~ArchiveFile();
|
||||
|
||||
vector<wstring> *getFileList();
|
||||
bool hasFile(const wstring &filename);
|
||||
int getFileSize(const wstring &filename);
|
||||
byteArray getFile(const wstring &filename);
|
||||
vector<std::wstring> *getFileList();
|
||||
bool hasFile(const std::wstring &filename);
|
||||
int getFileSize(const std::wstring &filename);
|
||||
byteArray getFile(const std::wstring &filename);
|
||||
};
|
||||
|
||||
@@ -17,16 +17,16 @@ StringTable::StringTable(PBYTE pbData, DWORD dwSize)
|
||||
int versionNumber = dis.readInt();
|
||||
int languagesCount = dis.readInt();
|
||||
|
||||
vector< pair<wstring, int> > langSizeMap;
|
||||
vector< pair<std::wstring, int> > langSizeMap;
|
||||
for(int i = 0; i < languagesCount; ++i)
|
||||
{
|
||||
wstring langId = dis.readUTF();
|
||||
std::wstring langId = dis.readUTF();
|
||||
int langSize = dis.readInt();
|
||||
|
||||
langSizeMap.push_back( vector< pair<wstring, int> >::value_type(langId, langSize));
|
||||
langSizeMap.push_back( vector< pair<std::wstring, int> >::value_type(langId, langSize));
|
||||
}
|
||||
|
||||
vector<wstring> locales;
|
||||
vector<std::wstring> locales;
|
||||
app.getLocale(locales);
|
||||
|
||||
bool foundLang = false;
|
||||
@@ -74,20 +74,20 @@ StringTable::StringTable(PBYTE pbData, DWORD dwSize)
|
||||
int langVersion = dis2.readInt();
|
||||
|
||||
isStatic = false; // 4J-JEV: Versions 1 and up could use
|
||||
if (langVersion > 0) // integers rather than wstrings as keys.
|
||||
if (langVersion > 0) // integers rather than std::wstrings as keys.
|
||||
isStatic = dis2.readBoolean();
|
||||
|
||||
wstring langId = dis2.readUTF();
|
||||
std::wstring langId = dis2.readUTF();
|
||||
int totalStrings = dis2.readInt();
|
||||
|
||||
if (!isStatic)
|
||||
{
|
||||
for(int i = 0; i < totalStrings; ++i)
|
||||
{
|
||||
wstring stringId = dis2.readUTF();
|
||||
wstring stringValue = dis2.readUTF();
|
||||
std::wstring stringId = dis2.readUTF();
|
||||
std::wstring stringValue = dis2.readUTF();
|
||||
|
||||
m_stringsMap.insert( std::unordered_map<wstring, wstring>::value_type(stringId, stringValue) );
|
||||
m_stringsMap.insert( std::unordered_map<std::wstring, std::wstring>::value_type(stringId, stringValue) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -125,7 +125,7 @@ void StringTable::getData(PBYTE *ppData, UINT *pSize)
|
||||
*pSize = src.length;
|
||||
}
|
||||
|
||||
LPCWSTR StringTable::getString(const wstring &id)
|
||||
LPCWSTR StringTable::getString(const std::wstring &id)
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (isStatic)
|
||||
|
||||
@@ -15,8 +15,8 @@ class StringTable
|
||||
private:
|
||||
bool isStatic;
|
||||
|
||||
std::unordered_map<wstring, wstring> m_stringsMap;
|
||||
vector<wstring> m_stringsVec;
|
||||
std::unordered_map<std::wstring, std::wstring> m_stringsMap;
|
||||
vector<std::wstring> m_stringsVec;
|
||||
|
||||
byteArray src;
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
void getData(PBYTE *ppbData, UINT *pdwSize);
|
||||
|
||||
LPCWSTR getString(const wstring &id);
|
||||
LPCWSTR getString(const std::wstring &id);
|
||||
LPCWSTR getString(int id);
|
||||
|
||||
//static LPCWSTR m_wchLocaleCode[LOCALE_COUNT];
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
//wstring getLangId(DWORD dwLanguage=0);
|
||||
//std::wstring getLangId(DWORD dwLanguage=0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ WstringLookup::WstringLookup()
|
||||
numIDs = 0;
|
||||
}
|
||||
|
||||
wstring WstringLookup::lookup(UINT id)
|
||||
std::wstring WstringLookup::lookup(UINT id)
|
||||
{
|
||||
// TODO
|
||||
//if (id > currentMaxID)
|
||||
@@ -17,12 +17,12 @@ wstring WstringLookup::lookup(UINT id)
|
||||
return int2str.at(id);
|
||||
}
|
||||
|
||||
UINT WstringLookup::lookup(wstring str)
|
||||
UINT WstringLookup::lookup(std::wstring str)
|
||||
{
|
||||
if (str2int.find(str) == str2int.end())
|
||||
{
|
||||
pair<wstring,UINT> p =
|
||||
pair<wstring,UINT>(str, numIDs);
|
||||
pair<std::wstring,UINT> p =
|
||||
pair<std::wstring,UINT>(str, numIDs);
|
||||
|
||||
str2int.insert( p );
|
||||
int2str.push_back( str );
|
||||
@@ -35,13 +35,13 @@ UINT WstringLookup::lookup(wstring str)
|
||||
}
|
||||
}
|
||||
|
||||
VOID WstringLookup::getTable(wstring **lookup, UINT *len)
|
||||
VOID WstringLookup::getTable(std::wstring **lookup, UINT *len)
|
||||
{
|
||||
// Outputs
|
||||
wstring *out_lookup; UINT out_len;
|
||||
std::wstring *out_lookup; UINT out_len;
|
||||
|
||||
// Fill lookup.
|
||||
out_lookup = new wstring[int2str.size()];
|
||||
out_lookup = new std::wstring[int2str.size()];
|
||||
for (UINT i = 0; i < numIDs; i++)
|
||||
out_lookup[i] = int2str.at(i);
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ class WstringLookup
|
||||
{
|
||||
private:
|
||||
UINT numIDs;
|
||||
std::unordered_map<wstring, UINT> str2int;
|
||||
vector<wstring> int2str;
|
||||
std::unordered_map<std::wstring, UINT> str2int;
|
||||
vector<std::wstring> int2str;
|
||||
|
||||
public:
|
||||
WstringLookup();
|
||||
|
||||
wstring lookup(UINT id);
|
||||
std::wstring lookup(UINT id);
|
||||
|
||||
UINT lookup(wstring);
|
||||
UINT lookup(std::wstring);
|
||||
|
||||
VOID getTable(wstring **lookup, UINT *len);
|
||||
VOID getTable(std::wstring **lookup, UINT *len);
|
||||
};
|
||||
Reference in New Issue
Block a user