本文整理汇总了C++中configobject::Ptr::SetShortName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::SetShortName方法的具体用法?C++ Ptr::SetShortName怎么用?C++ Ptr::SetShortName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configobject::Ptr
的用法示例。
在下文中一共展示了Ptr::SetShortName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Commit
/**
* Commits the configuration item by creating a ConfigObject
* object.
*
* @returns The ConfigObject that was created/updated.
*/
ConfigObject::Ptr ConfigItem::Commit(bool discard)
{
#ifdef I2_DEBUG
Log(LogDebug, "ConfigItem")
<< "Commit called for ConfigItem Type=" << GetType() << ", Name=" << GetName();
#endif /* I2_DEBUG */
/* Make sure the type is valid. */
Type::Ptr type = Type::GetByName(GetType());
ASSERT(type && ConfigObject::TypeInstance->IsAssignableFrom(type));
if (IsAbstract())
return ConfigObject::Ptr();
ConfigObject::Ptr dobj = static_pointer_cast<ConfigObject>(type->Instantiate());
dobj->SetDebugInfo(m_DebugInfo);
dobj->SetZoneName(m_Zone);
dobj->SetPackage(m_Package);
dobj->SetName(m_Name);
DebugHint debugHints;
ScriptFrame frame(dobj);
if (m_Scope)
m_Scope->CopyTo(frame.Locals);
try {
m_Expression->Evaluate(frame, &debugHints);
} catch (const std::exception& ex) {
if (m_IgnoreOnError) {
Log(LogWarning, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
return ConfigObject::Ptr();
}
throw;
}
if (discard)
m_Expression.reset();
String item_name;
String short_name = dobj->GetShortName();
if (!short_name.IsEmpty()) {
item_name = short_name;
dobj->SetName(short_name);
} else
item_name = m_Name;
String name = item_name;
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
if (nc) {
name = nc->MakeName(name, dobj);
if (name.IsEmpty())
BOOST_THROW_EXCEPTION(std::runtime_error("Could not determine name for object"));
}
if (name != item_name)
dobj->SetShortName(item_name);
dobj->SetName(name);
try {
dobj->OnConfigLoaded();
} catch (const std::exception& ex) {
if (m_IgnoreOnError) {
Log(LogWarning, "ConfigObject")
<< "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
return ConfigObject::Ptr();
}
throw;
}
Dictionary::Ptr persistentItem = new Dictionary();
persistentItem->Set("type", GetType());
persistentItem->Set("name", GetName());
persistentItem->Set("properties", Serialize(dobj, FAConfig));
Dictionary::Ptr dhint = debugHints.ToDictionary();
persistentItem->Set("debug_hints", dhint);
Array::Ptr di = new Array();
di->Add(m_DebugInfo.Path);
di->Add(m_DebugInfo.FirstLine);
di->Add(m_DebugInfo.FirstColumn);
di->Add(m_DebugInfo.LastLine);
//.........这里部分代码省略.........