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;
fileData << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
fileData << "<localizations>\n";
fileData << plFormat("\t<age name=\"{}\">\n", ageName);
fileData << "\t<age name=\"" << ageName << "\">\n";
std::vector<plString> setNames = GetSetList(ageName);
for (int curSet = 0; curSet < setNames.size(); curSet++)
{
setEmpty = true; // so far, this set is empty
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]);
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]);
if (fLocalizedElements[key].find(languageName) != fLocalizedElements[key].end())
{
weWroteData = true;
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 << "</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 logMsg = plFormat("{}SimpleVar, name:{}[{}]", pad, GetName(), GetCount());
plStringStream logMsg;
logMsg << pad << "SimpleVar, name:" << GetName() << '[' << GetCount() << ']';
if (GetCount()>1)
{
dbg->LogMsg(logMsg.c_str()); // it's going to be a long msg, so print it on its own line
logMsg = "";
dbg->LogMsg(logMsg.GetString().c_str()); // it's going to be a long msg, so print it on its own line
logMsg.Truncate();
}
pad += "\t";
for (size_t i=0; i<GetCount(); i++)
{
logMsg << pad;
logMsg << "Var:" << i;
plString s=GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}",
pad, i, s, p, fTimeStamp.Format("%c"));
logMsg << " gameTime:" << s;
logMsg << " pst:" << fT[i].PrintWMillis();
logMsg << " ts:" << fTimeStamp.Format("%c").c_str();
}
else
{
logMsg += plFormat("{}Var:{} value:{} ts:{}",
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c"));
logMsg << " value:" << s;
logMsg << " ts:" << (fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str());
}
if (!dirtyOnly)
logMsg += plFormat(" dirty:{}", IsDirty());
{
logMsg << " dirty:";
logMsg << (IsDirty() ? 0 : 1);
}
dbg->LogMsg(logMsg.c_str());
logMsg = "";
dbg->LogMsg(logMsg.GetString().c_str());
logMsg.Truncate();
}
}
@ -2316,34 +2324,42 @@ void plSimpleStateVariable::DumpToStream(hsStream* stream, bool dirtyOnly, int l
{
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)
{
stream->WriteString(logMsg); // it's going to be a long msg, so print it on its own line
logMsg = "";
stream->WriteString(logMsg.GetString()); // it's going to be a long msg, so print it on its own line
logMsg.Truncate();
}
pad += "\t";
for (size_t i=0; i<GetCount(); i++)
{
logMsg << pad;
logMsg << "Var:" << i;
plString s = GetAsString(i);
if (fVar.GetAtomicType() == plVarDescriptor::kTime)
{
const char* p=fT[i].PrintWMillis();
logMsg += plFormat("{}Var:{} gameTime:{} pst:{} ts:{}",
pad, i, s, p, fTimeStamp.Format("%c"));
logMsg << " gameTime:" << s;
logMsg << " pst:" << fT[i].PrintWMillis();
logMsg << " ts:" << fTimeStamp.Format("%c").c_str();
}
else
{
logMsg += plFormat("{}Var:{} value:{} ts:{}",
pad, i, s, fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c"));
logMsg << " value:" << s;
logMsg << " ts:" << (fTimeStamp.AtEpoch() ? "0" : fTimeStamp.Format("%c").c_str());
}
if (!dirtyOnly)
logMsg += plFormat(" dirty:{}", IsDirty());
{
logMsg << " dirty:";
logMsg << (IsDirty() ? 0 : 1);
}
stream->WriteString(logMsg);
logMsg = "";
stream->WriteString(logMsg.GetString());
logMsg.Truncate();
}
}

Loading…
Cancel
Save