本文整理汇总了C++中OTMLNodePtr::writeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ OTMLNodePtr::writeAt方法的具体用法?C++ OTMLNodePtr::writeAt怎么用?C++ OTMLNodePtr::writeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OTMLNodePtr
的用法示例。
在下文中一共展示了OTMLNodePtr::writeAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getStyle
OTMLNodePtr UIManager::getStyle(const std::string& styleName)
{
auto it = m_styles.find(styleName);
if(it != m_styles.end())
return m_styles[styleName];
// styles starting with UI are automatically defined
if(stdext::starts_with(styleName, "UI")) {
OTMLNodePtr node = OTMLNode::create(styleName);
node->writeAt("__class", styleName);
m_styles[styleName] = node;
return node;
}
return nullptr;
}
示例2: importStyleFromOTML
void UIManager::importStyleFromOTML(const OTMLNodePtr& styleNode)
{
std::string tag = styleNode->tag();
std::vector<std::string> split = stdext::split(tag, "<");
if(split.size() != 2)
throw OTMLException(styleNode, "not a valid style declaration");
std::string name = split[0];
std::string base = split[1];
bool unique = false;
stdext::trim(name);
stdext::trim(base);
if(name[0] == '#') {
name = name.substr(1);
unique = true;
styleNode->setTag(name);
styleNode->writeAt("__unique", true);
}
OTMLNodePtr oldStyle = m_styles[name];
// Warn about redefined styles
/*
if(!g_app.isRunning() && (oldStyle && !oldStyle->valueAt("__unique", false))) {
auto it = m_styles.find(name);
if(it != m_styles.end())
g_logger.warning(stdext::format("style '%s' is being redefined", name));
}
*/
if(!oldStyle || !oldStyle->valueAt("__unique", false) || unique) {
OTMLNodePtr originalStyle = getStyle(base);
if(!originalStyle)
stdext::throw_exception(stdext::format("base style '%s', is not defined", base));
OTMLNodePtr style = originalStyle->clone();
style->merge(styleNode);
style->setTag(name);
m_styles[name] = style;
}
}
示例3: luavalue_cast
bool luavalue_cast(int index, OTMLNodePtr& node)
{
node = OTMLNode::create();
node->setUnique(true);
if(g_lua.isTable(index)) {
g_lua.pushNil();
while(g_lua.next(index < 0 ? index-1 : index)) {
std::string cnodeName;
if(!g_lua.isNumber(-2))
cnodeName = g_lua.toString(-2);
if(g_lua.isTable()) {
OTMLNodePtr cnode;
if(luavalue_cast(-1, cnode)) {
if(cnodeName.empty())
node->setUnique(false);
else
cnode->setTag(cnodeName);
node->addChild(cnode);
}
} else {
std::string value;
if(g_lua.isBoolean())
value = stdext::unsafe_cast<std::string>(g_lua.toBoolean());
else
value = g_lua.toString();
if(cnodeName.empty())
node->writeIn(value);
else
node->writeAt(cnodeName, value);
}
g_lua.pop();
}
return true;
}
return false;
}