本文整理汇总了C++中Universe::findPath方法的典型用法代码示例。如果您正苦于以下问题:C++ Universe::findPath方法的具体用法?C++ Universe::findPath怎么用?C++ Universe::findPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe
的用法示例。
在下文中一共展示了Universe::findPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSolarSystemObjects
bool LoadSolarSystemObjects(istream& in,
Universe& universe,
const std::string& directory)
{
Tokenizer tokenizer(&in);
Parser parser(&tokenizer);
while (tokenizer.nextToken() != Tokenizer::TokenEnd)
{
// Read the disposition; if none is specified, the default is Add.
Disposition disposition = AddObject;
if (tokenizer.getTokenType() == Tokenizer::TokenName)
{
if (tokenizer.getNameValue() == "Add")
{
disposition = AddObject;
tokenizer.nextToken();
}
else if (tokenizer.getNameValue() == "Replace")
{
disposition = ReplaceObject;
tokenizer.nextToken();
}
else if (tokenizer.getNameValue() == "Modify")
{
disposition = ModifyObject;
tokenizer.nextToken();
}
}
// Read the item type; if none is specified the default is Body
string itemType("Body");
if (tokenizer.getTokenType() == Tokenizer::TokenName)
{
itemType = tokenizer.getNameValue();
tokenizer.nextToken();
}
if (tokenizer.getTokenType() != Tokenizer::TokenString)
{
sscError(tokenizer, "object name expected");
return false;
}
// The name list is a string with zero more names. Multiple names are
// delimited by colons.
string nameList = tokenizer.getStringValue().c_str();
if (tokenizer.nextToken() != Tokenizer::TokenString)
{
sscError(tokenizer, "bad parent object name");
return false;
}
string parentName = tokenizer.getStringValue().c_str();
Value* objectDataValue = parser.readValue();
if (objectDataValue == NULL)
{
sscError(tokenizer, "bad object definition");
return false;
}
if (objectDataValue->getType() != Value::HashType)
{
sscError(tokenizer, "{ expected");
delete objectDataValue;
return false;
}
Hash* objectData = objectDataValue->getHash();
Selection parent = universe.findPath(parentName, NULL, 0);
PlanetarySystem* parentSystem = NULL;
vector<string> names;
// Iterate through the string for names delimited
// by ':', and insert them into the name list.
if (nameList.empty())
{
names.push_back("");
}
else
{
string::size_type startPos = 0;
while (startPos != string::npos)
{
string::size_type next = nameList.find(':', startPos);
string::size_type length = string::npos;
if (next != string::npos)
{
length = next - startPos;
++next;
}
names.push_back(nameList.substr(startPos, length));
startPos = next;
}
}
string primaryName = names.front();
BodyType bodyType = UnknownBodyType;
if (itemType == "Body")
//.........这里部分代码省略.........