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

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

@ -62,6 +62,9 @@ struct LocElementInfo;
struct LocSetInfo;
struct LocAgeInfo;
// Temporary helper (until everything is plString-ized)
typedef std::vector<std::wstring> WStringVector;
class pfLocalizationDataMgr
{
private:
@ -90,9 +93,9 @@ protected:
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
std::vector<std::wstring> 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 getAgeList(); // returns a list of all ages in this map
WStringVector getSetList(const std::wstring & age); // returns a list of all sets in the specified age
WStringVector getNameList(const std::wstring & age, const std::wstring & set);
};
LocalizationDatabase *fDatabase;
@ -107,7 +110,7 @@ protected:
localizedElement ICreateLocalizedElement(); // ease of use function that creates a basic localized element object
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 IConvertSet(LocSetInfo *setInfo, const std::wstring & curPath);
@ -131,10 +134,13 @@ public:
pfLocalizedString GetElement(const std::wstring & name);
pfLocalizedString GetSpecificElement(const std::wstring & name, const std::wstring & languageName);
std::vector<std::wstring> GetAgeList();
std::vector<std::wstring> GetSetList(const std::wstring & ageName);
std::vector<std::wstring> 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);
WStringVector GetAgeList() { return fLocalizedElements.getAgeList(); }
WStringVector GetSetList(const std::wstring & ageName) { return fLocalizedElements.getSetList(ageName); }
WStringVector GetElementList(const std::wstring & ageName, const std::wstring & setName)
{
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 GetElementPlainTextData(const std::wstring & name, const std::wstring & languageName);

Loading…
Cancel
Save