Browse Source

Use moar stringstreams (where appropriate)

Michael Hansen 11 years ago
parent
commit
8b43d46ea5
  1. 8
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  2. 60
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

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

@ -948,26 +948,26 @@ void pfLocalizationDataMgr::IWriteText(const plFileName & filename, const plStri
plStringStream fileData; plStringStream fileData;
fileData << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; fileData << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
fileData << "<localizations>\n"; fileData << "<localizations>\n";
fileData << plFormat("\t<age name=\"{}\">\n", ageName); fileData << "\t<age name=\"" << ageName << "\">\n";
std::vector<plString> setNames = GetSetList(ageName); std::vector<plString> 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
plStringStream setCode; plStringStream setCode;
setCode << plFormat("\t\t<set name=\"{}\">\n", setNames[curSet]); setCode << "\t\t<set name=\"" << setNames[curSet] << "\">\n";
std::vector<plString> elementNames = GetElementList(ageName, setNames[curSet]); std::vector<plString> elementNames = GetElementList(ageName, setNames[curSet]);
for (int curElement = 0; curElement < elementNames.size(); curElement++) for (int curElement = 0; curElement < elementNames.size(); curElement++)
{ {
setCode << plFormat("\t\t\t<element name=\"{}\">\n", elementNames[curElement]); setCode << "\t\t\t<element name=\"" << elementNames[curElement] << "\">\n";
plString key = plFormat("{}.{}.{}", ageName, setNames[curSet], elementNames[curElement]); plString key = plFormat("{}.{}.{}", ageName, setNames[curSet], elementNames[curElement]);
if (fLocalizedElements[key].find(languageName) != fLocalizedElements[key].end()) if (fLocalizedElements[key].find(languageName) != fLocalizedElements[key].end())
{ {
weWroteData = true; weWroteData = true;
setEmpty = false; setEmpty = false;
setCode << plFormat("\t\t\t\t<translation language=\"{}\">", languageName); setCode << "\t\t\t\t<translation language=\"" << languageName << "\">";
setCode << fLocalizedElements[key][languageName].ToXML(); setCode << fLocalizedElements[key][languageName].ToXML();
setCode << "</translation>\n"; setCode << "</translation>\n";
} }

60
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -2281,34 +2281,42 @@ void plSimpleStateVariable::DumpToObjectDebugger(bool dirtyOnly, int level) cons
plString pad = plString::Fill(level * 3, ' '); plString pad = plString::Fill(level * 3, ' ');
plString logMsg = plFormat("{}SimpleVar, name:{}[{}]", pad, GetName(), GetCount()); plStringStream logMsg;
logMsg << pad << "SimpleVar, name:" << GetName() << '[' << GetCount() << ']';
if (GetCount()>1) if (GetCount()>1)
{ {
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line dbg->LogMsg(logMsg.GetString().c_str()); // it's going to be a long msg, so print it on its own line
logMsg = ""; logMsg.Truncate();
} }
pad += "\t"; pad += "\t";
for (size_t i=0; i<GetCount(); i++) for (size_t i=0; i<GetCount(); i++)
{ {
logMsg << pad;
logMsg << "Var:" << i;
plString s=GetAsString(i); plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); logMsg << " gameTime:" << s;
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}", logMsg << " pst:" << fT[i].PrintWMillis();
pad, i, s, p, fTimeStamp.Format("%c")); logMsg << " ts:" << fTimeStamp.Format("%c").c_str();
} }
else else
{ {
logMsg += plFormat("{}Var:{} value:{} ts:{}", logMsg << " value:" << s;
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c")); logMsg << " ts:" << (fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str());
} }
if (!dirtyOnly) if (!dirtyOnly)
logMsg += plFormat(" dirty:{}", IsDirty()); {
logMsg << " dirty:";
logMsg << (IsDirty() ? 0 : 1);
}
dbg->LogMsg(logMsg.c_str()); dbg->LogMsg(logMsg.GetString().c_str());
logMsg = ""; logMsg.Truncate();
} }
} }
@ -2316,34 +2324,42 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
{ {
plString pad = plString::Fill(level * 3, ' '); plString pad = plString::Fill(level * 3, ' ');
plString logMsg = plFormat("{}SimpleVar, name:{}[{}]", pad, GetName(), GetCount()); plStringStream logMsg;
logMsg << pad << "SimpleVar, name:" << GetName() << '[' << GetCount() << ']';
if (GetCount()>1) if (GetCount()>1)
{ {
stream->WriteString(logMsg); // it's going to be a long msg, so print it on its own line stream->WriteString(logMsg.GetString()); // it's going to be a long msg, so print it on its own line
logMsg = ""; logMsg.Truncate();
} }
pad += "\t"; pad += "\t";
for (size_t i=0; i<GetCount(); i++) for (size_t i=0; i<GetCount(); i++)
{ {
logMsg << pad;
logMsg << "Var:" << i;
plString s = GetAsString(i); plString s = GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime) if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{ {
const char* p=fT[i].PrintWMillis(); logMsg << " gameTime:" << s;
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}", logMsg << " pst:" << fT[i].PrintWMillis();
pad, i, s, p, fTimeStamp.Format("%c")); logMsg << " ts:" << fTimeStamp.Format("%c").c_str();
} }
else else
{ {
logMsg += plFormat("{}Var:{} value:{} ts:{}", logMsg << " value:" << s;
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c")); logMsg << " ts:" << (fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str());
} }
if (!dirtyOnly) if (!dirtyOnly)
logMsg += plFormat(" dirty:{}", IsDirty()); {
logMsg << " dirty:";
logMsg << (IsDirty() ? 0 : 1);
}
stream->WriteString(logMsg); stream->WriteString(logMsg.GetString());
logMsg = ""; logMsg.Truncate();
} }
} }

Loading…
Cancel
Save