本文整理汇总了C++中CSG_MetaData::Get_Parent方法的典型用法代码示例。如果您正苦于以下问题:C++ CSG_MetaData::Get_Parent方法的具体用法?C++ CSG_MetaData::Get_Parent怎么用?C++ CSG_MetaData::Get_Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSG_MetaData
的用法示例。
在下文中一共展示了CSG_MetaData::Get_Parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: from_JSON
//---------------------------------------------------------
bool CSG_MetaData::from_JSON(const CSG_String &JSON)
{
Destroy();
Set_Name("root");
CSG_MetaData *pNode = this;
const SG_Char *pc = JSON.c_str();
while( *pc )
{
CSG_String Element;
for(bool bQuota=false;;)
{
SG_Char c = *pc++;
if( !c || c == '\n' ) { break; } else
{
if( c == '\"' )
{
Element += c; bQuota = !bQuota;
}
else if( bQuota || (c != ' ' && c != '\t' && c != ',') )
{
Element += c;
}
}
}
//-------------------------------------------------
if( Element.is_Empty() )
{
// nop
}
else if( Element.Find('[') >= 0 ) // array begins
{
pNode = pNode->Add_Child(Element.AfterFirst('\"').BeforeFirst('\"'));
pNode->Add_Property("array", 1);
}
else if( Element.Find(']') >= 0 ) // array ends
{
if( pNode != this )
{
pNode = pNode->Get_Parent();
}
}
else if( Element.Find('{') >= 0 ) // object begins
{
Element = Element.AfterFirst('\"').BeforeFirst('\"');
if( !Element.is_Empty() )
{
pNode = pNode->Add_Child(Element);
}
else if( pNode->Get_Property("array") )
{
pNode = pNode->Add_Child(CSG_String::Format("%d", pNode->Get_Children_Count()));
}
}
else if( Element.Find('}') >= 0 ) // object ends
{
if( pNode != this )
{
pNode = pNode->Get_Parent();
}
}
else
{
CSG_String Key (Element.AfterFirst('\"').BeforeFirst('\"'));
CSG_String Value(Element.AfterFirst(':'));
if( Value.Find('\"') > -1 )
{
Value = Value.AfterFirst('\"').BeforeFirst('\"');
}
pNode->Add_Child(Key, Value);
}
}
return( true );
}