Changed: #1469 TPositionOrEntity from string conversion changed to support previous pos and return pos

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 13 years ago
parent 716a7aedc7
commit 9d592fdc63

@ -25,19 +25,32 @@
#include "mission_manager/mission_parser.h" #include "mission_manager/mission_parser.h"
#include "egs_mirror.h" #include "egs_mirror.h"
#define POS_OR_ENTITY_PREVIOUS_POS_VALUE "_PreviousPos_"
#define POS_OR_ENTITY_RETURN_POS_VALUE "_ReturnPos_"
const TPositionOrEntity CPositionOrEntityHelper::Invalid = TPositionOrEntity(); const TPositionOrEntity CPositionOrEntityHelper::Invalid = TPositionOrEntity();
TPositionOrEntity CPositionOrEntityHelper::fromString(const std::string& s) TPositionOrEntity CPositionOrEntityHelper::fromString(const std::string& s)
{ {
// If the string is empty it's a previous pos
if (s.empty()) if (s.empty())
{ {
nlerror("TPositionOrentityHelper : empty position or entity given to parse"); return TPositionOrEntity(TPositionOrEntity::EPreviousPos);
return TPositionOrEntity();
} }
std::string str = s; std::string str = s;
CMissionParser::removeBlanks(str); CMissionParser::removeBlanks(str);
// We already check if it's a special position or entity object
if (NLMISC::toLower(str) == POS_OR_ENTITY_PREVIOUS_POS_VALUE)
{
return TPositionOrEntity(TPositionOrEntity::EPreviousPos);
}
else if (NLMISC::toLower(str) == POS_OR_ENTITY_RETURN_POS_VALUE)
{
return TPositionOrEntity(TPositionOrEntity::EReturnPos);
}
std::vector<std::string> resS; std::vector<std::string> resS;
NLMISC::splitString(str, ";", resS); NLMISC::splitString(str, ";", resS);
// If we don't have 3 components, it's an entity // If we don't have 3 components, it's an entity

Loading…
Cancel
Save