本文整理汇总了C++中TiXmlNode::GetDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::GetDocument方法的具体用法?C++ TiXmlNode::GetDocument怎么用?C++ TiXmlNode::GetDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::GetDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tixmlnode_close
int tixmlnode_close(lua_State *L) {
TiXmlNode *xmlnode;
TiXmlNode_ud* xmlnode_userdata = (TiXmlNode_ud *) luaL_checkudata(L, 1, "TiXmlNode");
xmlnode = xmlnode_userdata->xmlnode;
lua_pop(L, 1);
// decrease refcount for corresponding document
if (xmlnode)
decrease_tixmldocument_refcount(L, xmlnode->GetDocument());
xmlnode_userdata->xmlnode = NULL;
return 0;
}
示例2: l_select
int l_select(lua_State *L) {
const char *expr = luaL_checkstring(L, 1);
TiXmlNode *node = (TiXmlNode *) lua_touserdata(L, 2);
TinyXPath::xpath_processor xpp(node, expr);
TinyXPath::expression_result res(xpp.er_compute_xpath());
if (xpp.e_error != TinyXPath::xpath_processor::e_no_error) {
string errmsg("error while computing xpath query `");
errmsg += expr;
errmsg += "'";
return luaL_error(L, errmsg.c_str());
}
switch (res.e_type) {
case TinyXPath::e_string:
lua_pushstring(L, res.cp_get_string());
return 1;
case TinyXPath::e_node_set:
{
TinyXPath::node_set* ns;
const TiXmlNode* node;
ns = res.nsp_get_node_set();
int nns(ns->u_get_nb_node_in_set());
if (nns == 0) {
lua_pushnil(L);
return 1;
}
lua_createtable(L, nns, 0);
for (int i=0; i<nns; i++) {
lua_pushinteger(L, i+1);
if (ns->o_is_attrib(i)) {
std::string attr_value = ns->S_get_value(i);
lua_pushstring(L, attr_value.c_str());
} else {
node = ns->XNp_get_node_in_set(i);
if (node->Type() == TiXmlNode::TEXT) {
lua_pushstring(L, node->Value());
break;
} else {
TiXmlNode_ud* node_userdata = (TiXmlNode_ud *) lua_newuserdata(L, sizeof(TiXmlNode_ud));
node_userdata->xmlnode = const_cast<TiXmlNode *>(node); //->Clone();
luaL_newmetatable(L, "TiXmlNode");
lua_setmetatable(L, -2);
increase_tixmldocument_refcount(L, node->GetDocument());
}
}
lua_settable(L, -3);
}
return 1;
}
case TinyXPath::e_bool:
lua_pushboolean(L, res.o_get_bool());
return 1;
case TinyXPath::e_int:
lua_pushinteger(L, res.i_get_int());
return 1;
case TinyXPath::e_double:
lua_pushnumber(L, res.d_get_double());
return 1;
case TinyXPath::e_invalid:
return luaL_error(L, "invalid xpath expression");
default:
lua_pushnil(L);
return 1;
}
}