Browse Source

Fixup tree dumping

Remove unnesecary conversions and string concats in the tree->log dumping
code.
Adam Johnson 12 years ago
parent
commit
1bada0dfa2
  1. 89
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  2. 22
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h

89
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp

@ -554,7 +554,7 @@ void LocalizationDatabase::IMergeData()
void LocalizationDatabase::IVerifyElement(const std::wstring &ageName, const std::wstring &setName, LocalizationXMLFile::set::iterator& curElement) void LocalizationDatabase::IVerifyElement(const std::wstring &ageName, const std::wstring &setName, LocalizationXMLFile::set::iterator& curElement)
{ {
std::vector<std::wstring> languageNames; WStringVector languageNames;
std::wstring defaultLanguage; std::wstring defaultLanguage;
int numLocales = plLocalization::GetNumLocales(); int numLocales = plLocalization::GetNumLocales();
@ -788,9 +788,9 @@ mapT &pfLocalizationDataMgr::pf3PartMap<mapT>::operator[](const std::wstring &ke
//// getAgeList() //////////////////////////////////////////////////// //// getAgeList() ////////////////////////////////////////////////////
template<class mapT> template<class mapT>
std::vector<std::wstring> pfLocalizationDataMgr::pf3PartMap<mapT>::getAgeList() WStringVector pfLocalizationDataMgr::pf3PartMap<mapT>::getAgeList()
{ {
std::vector<std::wstring> retVal; WStringVector retVal;
typename ThreePartMap::iterator curAge; typename ThreePartMap::iterator curAge;
for (curAge = fData.begin(); curAge != fData.end(); curAge++) for (curAge = fData.begin(); curAge != fData.end(); curAge++)
@ -802,9 +802,9 @@ std::vector<std::wstring> pfLocalizationDataMgr::pf3PartMap<mapT>::getAgeList()
//// getSetList() //////////////////////////////////////////////////// //// getSetList() ////////////////////////////////////////////////////
template<class mapT> template<class mapT>
std::vector<std::wstring> pfLocalizationDataMgr::pf3PartMap<mapT>::getSetList(const std::wstring & age) WStringVector pfLocalizationDataMgr::pf3PartMap<mapT>::getSetList(const std::wstring & age)
{ {
std::vector<std::wstring> retVal; WStringVector retVal;
typename std::map<std::wstring, std::map<std::wstring, mapT> >::iterator curSet; typename std::map<std::wstring, std::map<std::wstring, mapT> >::iterator curSet;
if (fData.find(age) == fData.end()) if (fData.find(age) == fData.end())
@ -819,9 +819,9 @@ std::vector<std::wstring> pfLocalizationDataMgr::pf3PartMap<mapT>::getSetList(co
//// getNameList() /////////////////////////////////////////////////// //// getNameList() ///////////////////////////////////////////////////
template<class mapT> template<class mapT>
std::vector<std::wstring> pfLocalizationDataMgr::pf3PartMap<mapT>::getNameList(const std::wstring & age, const std::wstring & set) WStringVector pfLocalizationDataMgr::pf3PartMap<mapT>::getNameList(const std::wstring & age, const std::wstring & set)
{ {
std::vector<std::wstring> retVal; WStringVector retVal;
typename std::map<std::wstring, mapT>::iterator curName; typename std::map<std::wstring, mapT>::iterator curName;
if (fData.find(age) == fData.end()) if (fData.find(age) == fData.end())
@ -898,10 +898,10 @@ std::wstring pfLocalizationDataMgr::IGetCurrentLanguageName()
//// IGetAllLanguageNames //////////////////////////////////////////// //// IGetAllLanguageNames ////////////////////////////////////////////
std::vector<std::wstring> pfLocalizationDataMgr::IGetAllLanguageNames() WStringVector pfLocalizationDataMgr::IGetAllLanguageNames()
{ {
int numLocales = plLocalization::GetNumLocales(); int numLocales = plLocalization::GetNumLocales();
std::vector<std::wstring> retVal; WStringVector retVal;
for (int curLocale = 0; curLocale <= numLocales; curLocale++) for (int curLocale = 0; curLocale <= numLocales; curLocale++)
{ {
@ -1005,14 +1005,14 @@ void pfLocalizationDataMgr::IWriteText(const std::string & filename, const std::
fileData += L"<localizations>\n"; fileData += L"<localizations>\n";
fileData += L"\t<age name=\"" + ageName + L"\">\n"; fileData += L"\t<age name=\"" + ageName + L"\">\n";
std::vector<std::wstring> setNames = GetSetList(ageName); WStringVector setNames = GetSetList(ageName);
for (int curSet = 0; curSet < setNames.size(); curSet++) for (int curSet = 0; curSet < setNames.size(); curSet++)
{ {
setEmpty = true; // so far, this set is empty setEmpty = true; // so far, this set is empty
std::wstring setCode = L""; std::wstring setCode = L"";
setCode += L"\t\t<set name=\"" + setNames[curSet] + L"\">\n"; setCode += L"\t\t<set name=\"" + setNames[curSet] + L"\">\n";
std::vector<std::wstring> elementNames = GetElementList(ageName, setNames[curSet]); WStringVector elementNames = GetElementList(ageName, setNames[curSet]);
for (int curElement = 0; curElement < elementNames.size(); curElement++) for (int curElement = 0; curElement < elementNames.size(); curElement++)
{ {
setCode += L"\t\t\t<element name=\"" + elementNames[curElement] + L"\">\n"; setCode += L"\t\t\t<element name=\"" + elementNames[curElement] + L"\">\n";
@ -1151,32 +1151,11 @@ pfLocalizedString pfLocalizationDataMgr::GetSpecificElement(const std::wstring &
return retVal; return retVal;
} }
//// GetAgeList //////////////////////////////////////////////////////
std::vector<std::wstring> pfLocalizationDataMgr::GetAgeList()
{
return fLocalizedElements.getAgeList();
}
//// GetSetList //////////////////////////////////////////////////////
std::vector<std::wstring> pfLocalizationDataMgr::GetSetList(const std::wstring & ageName)
{
return fLocalizedElements.getSetList(ageName);
}
//// GetElementList //////////////////////////////////////////////////
std::vector<std::wstring> pfLocalizationDataMgr::GetElementList(const std::wstring & ageName, const std::wstring & setName)
{
return fLocalizedElements.getNameList(ageName, setName);
}
//// GetLanguages //////////////////////////////////////////////////// //// GetLanguages ////////////////////////////////////////////////////
std::vector<std::wstring> pfLocalizationDataMgr::GetLanguages(const std::wstring & ageName, const std::wstring & setName, const std::wstring & elementName) WStringVector pfLocalizationDataMgr::GetLanguages(const std::wstring & ageName, const std::wstring & setName, const std::wstring & elementName)
{ {
std::vector<std::wstring> retVal; WStringVector retVal;
std::wstring key = ageName + L"." + setName + L"." + elementName; std::wstring key = ageName + L"." + setName + L"." + elementName;
if (fLocalizedElements.exists(key)) if (fLocalizedElements.exists(key))
{ {
@ -1296,8 +1275,8 @@ bool pfLocalizationDataMgr::DeleteElement(const std::wstring & name)
void pfLocalizationDataMgr::WriteDatabaseToDisk(const std::string & path) void pfLocalizationDataMgr::WriteDatabaseToDisk(const std::string & path)
{ {
// first, write the styles and panel settings to styles.sub // first, write the styles and panel settings to styles.sub
std::vector<std::wstring> ageNames = GetAgeList(); WStringVector ageNames = GetAgeList();
std::vector<std::wstring> languageNames = IGetAllLanguageNames(); WStringVector languageNames = IGetAllLanguageNames();
for (int curAge = 0; curAge < ageNames.size(); curAge++) for (int curAge = 0; curAge < ageNames.size(); curAge++)
{ {
for (int curLanguage = 0; curLanguage < languageNames.size(); curLanguage++) for (int curLanguage = 0; curLanguage < languageNames.size(); curLanguage++)
@ -1319,41 +1298,27 @@ void pfLocalizationDataMgr::WriteDatabaseToDisk(const std::string & path)
void pfLocalizationDataMgr::OutputTreeToLog() void pfLocalizationDataMgr::OutputTreeToLog()
{ {
std::vector<std::wstring> ages = GetAgeList(); WStringVector ages = GetAgeList();
fLog->AddLine("\n"); fLog->AddLine("\n");
fLog->AddLine("Localization tree:\n"); fLog->AddLine("Localization tree:\n");
for (int i = 0; i < ages.size(); i++) for (WStringVector::iterator i = ages.begin(); i != ages.end(); ++i)
{ {
char *ageName = hsWStringToString(ages[i].c_str()); std::wstring age = *i;
std::string temp = ageName; fLog->AddLineF("\t%S", age.c_str());
delete [] ageName;
temp = "\t" + temp + "\n";
fLog->AddLine(temp.c_str());
std::vector<std::wstring> sets = GetSetList(ages[i]); WStringVector sets = GetSetList(age);
for (WStringVector::iterator j = sets.begin(); j != sets.end(); ++j)
for (int j = 0; j < sets.size(); j++)
{ {
char *setName = hsWStringToString(sets[j].c_str()); std::wstring set = (*j);
std::string temp = setName; fLog->AddLineF("\t\t%S", set.c_str());
delete [] setName;
temp = "\t\t" + temp + "\n";
fLog->AddLine(temp.c_str());
std::vector<std::wstring> names = GetElementList(ages[i], sets[j]); WStringVector names = GetElementList(age, set);
for (WStringVector::iterator k = names.begin(); k != names.end(); ++k)
for (int k = 0; k < names.size(); k++)
{ {
char *elemName = hsWStringToString(names[k].c_str()); std::wstring name = (*k);
std::string temp = elemName; fLog->AddLineF("\t\t\t%S", name.c_str());
delete [] elemName;
temp = "\t\t\t" + temp + "\n";
fLog->AddLine(temp.c_str());
} }
} }
} }

22
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h

@ -62,6 +62,9 @@ struct LocElementInfo;
struct LocSetInfo; struct LocSetInfo;
struct LocAgeInfo; struct LocAgeInfo;
// Temporary helper (until everything is plString-ized)
typedef std::vector<std::wstring> WStringVector;
class pfLocalizationDataMgr class pfLocalizationDataMgr
{ {
private: private:
@ -90,9 +93,9 @@ protected:
mapT &operator[](const std::wstring &key); // returns the item referenced by the key (and creates if necessary) mapT &operator[](const std::wstring &key); // returns the item referenced by the key (and creates if necessary)
std::vector<std::wstring> getAgeList(); // returns a list of all ages in this map WStringVector getAgeList(); // returns a list of all ages in this map
std::vector<std::wstring> getSetList(const std::wstring & age); // returns a list of all sets in the specified age WStringVector getSetList(const std::wstring & age); // returns a list of all sets in the specified age
std::vector<std::wstring> getNameList(const std::wstring & age, const std::wstring & set); WStringVector getNameList(const std::wstring & age, const std::wstring & set);
}; };
LocalizationDatabase *fDatabase; LocalizationDatabase *fDatabase;
@ -107,7 +110,7 @@ protected:
localizedElement ICreateLocalizedElement(); // ease of use function that creates a basic localized element object localizedElement ICreateLocalizedElement(); // ease of use function that creates a basic localized element object
std::wstring IGetCurrentLanguageName(); // get the name of the current language std::wstring IGetCurrentLanguageName(); // get the name of the current language
std::vector<std::wstring> IGetAllLanguageNames(); WStringVector IGetAllLanguageNames();
void IConvertElement(LocElementInfo *elementInfo, const std::wstring & curPath); void IConvertElement(LocElementInfo *elementInfo, const std::wstring & curPath);
void IConvertSet(LocSetInfo *setInfo, const std::wstring & curPath); void IConvertSet(LocSetInfo *setInfo, const std::wstring & curPath);
@ -131,10 +134,13 @@ public:
pfLocalizedString GetElement(const std::wstring & name); pfLocalizedString GetElement(const std::wstring & name);
pfLocalizedString GetSpecificElement(const std::wstring & name, const std::wstring & languageName); pfLocalizedString GetSpecificElement(const std::wstring & name, const std::wstring & languageName);
std::vector<std::wstring> GetAgeList(); WStringVector GetAgeList() { return fLocalizedElements.getAgeList(); }
std::vector<std::wstring> GetSetList(const std::wstring & ageName); WStringVector GetSetList(const std::wstring & ageName) { return fLocalizedElements.getSetList(ageName); }
std::vector<std::wstring> GetElementList(const std::wstring & ageName, const std::wstring & setName); WStringVector GetElementList(const std::wstring & ageName, const std::wstring & setName)
std::vector<std::wstring> GetLanguages(const std::wstring & ageName, const std::wstring & setName, const std::wstring & elementName); {
return fLocalizedElements.getNameList(ageName, setName);
}
WStringVector GetLanguages(const std::wstring & ageName, const std::wstring & setName, const std::wstring & elementName);
std::wstring GetElementXMLData(const std::wstring & name, const std::wstring & languageName); std::wstring GetElementXMLData(const std::wstring & name, const std::wstring & languageName);
std::wstring GetElementPlainTextData(const std::wstring & name, const std::wstring & languageName); std::wstring GetElementPlainTextData(const std::wstring & name, const std::wstring & languageName);

Loading…
Cancel
Save