From 832fc56d34d06092bd6fc4344ca6fe71399b2205 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 9 Dec 2012 11:10:35 +0100 Subject: [PATCH] changed UniversalId to string conversion --- apps/opencs/model/tools/mandatoryid.cpp | 2 +- apps/opencs/model/world/universalid.cpp | 73 +++++++++++++------------ 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/apps/opencs/model/tools/mandatoryid.cpp b/apps/opencs/model/tools/mandatoryid.cpp index 87ac77e67..f9f2ca378 100644 --- a/apps/opencs/model/tools/mandatoryid.cpp +++ b/apps/opencs/model/tools/mandatoryid.cpp @@ -17,5 +17,5 @@ void CSMTools::MandatoryIdStage::perform (int stage, std::vector& m { if (mIdCollection.searchId (mIds.at (stage))==-1 || mIdCollection.getRecord (mIds.at (stage)).isDeleted()) - messages.push_back (mCollectionId.toString() + " Missing mandatory record: " + mIds.at (stage)); + messages.push_back (mCollectionId.toString() + "|Missing mandatory record: " + mIds.at (stage)); } \ No newline at end of file diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 229779f5a..98fb1d0b9 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -43,39 +43,44 @@ CSMWorld::UniversalId::UniversalId (const std::string& universalId) { std::string type = universalId.substr (0, index); - for (int i=0; sNoArg[i].mName; ++i) - if (type==sNoArg[i].mName) - { - mArgumentType = ArgumentType_None; - mType = sNoArg[i].mType; - mClass = sNoArg[i].mClass; - return; - } - - for (int i=0; sIdArg[i].mName; ++i) - if (type==sIdArg[i].mName) - { - mArgumentType = ArgumentType_Id; - mType = sIdArg[i].mType; - mClass = sIdArg[i].mClass; - mId = universalId.substr (0, index); - return; - } - - for (int i=0; sIndexArg[i].mName; ++i) - if (type==sIndexArg[i].mName) - { - mArgumentType = ArgumentType_Index; - mType = sIndexArg[i].mType; - mClass = sIndexArg[i].mClass; - - std::istringstream stream (universalId.substr (0, index)); - - if (stream >> mIndex) + if (index==std::string::npos) + { + for (int i=0; sNoArg[i].mName; ++i) + if (type==sNoArg[i].mName) + { + mArgumentType = ArgumentType_None; + mType = sNoArg[i].mType; + mClass = sNoArg[i].mClass; return; + } + } + else + { + for (int i=0; sIdArg[i].mName; ++i) + if (type==sIdArg[i].mName) + { + mArgumentType = ArgumentType_Id; + mType = sIdArg[i].mType; + mClass = sIdArg[i].mClass; + mId = universalId.substr (0, index); + return; + } - break; - } + for (int i=0; sIndexArg[i].mName; ++i) + if (type==sIndexArg[i].mName) + { + mArgumentType = ArgumentType_Index; + mType = sIndexArg[i].mType; + mClass = sIndexArg[i].mClass; + + std::istringstream stream (universalId.substr (0, index)); + + if (stream >> mIndex) + return; + + break; + } + } } throw std::runtime_error ("invalid UniversalId: " + universalId); @@ -197,13 +202,13 @@ std::string CSMWorld::UniversalId::toString() const { std::ostringstream stream; - stream << getTypeName() << ":"; + stream << getTypeName(); switch (mArgumentType) { case ArgumentType_None: break; - case ArgumentType_Id: stream << " " << mId; - case ArgumentType_Index: stream << " " << mIndex; + case ArgumentType_Id: stream << ": " << mId; + case ArgumentType_Index: stream << ": " << mIndex; } return stream.str();