本文整理汇总了C++中pugi::xml_node::print方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::print方法的具体用法?C++ xml_node::print怎么用?C++ xml_node::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::print方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitFromXml
BOOL SObject::InitFromXml( pugi::xml_node xmlNode )
{
if(!xmlNode) return FALSE;
#ifdef _DEBUG
{
pugi::xml_writer_buff writer;
xmlNode.print(writer,L"\t",pugi::format_default,pugi::encoding_utf16);
m_strXml=SStringW(writer.buffer(),writer.size());
}
#endif
//设置当前对象的属性
//优先处理"class"属性
pugi::xml_attribute attrClass=xmlNode.attribute(L"class");
if(attrClass)
{
attrClass.set_userdata(1); //预处理过的属性,给属性增加一个userdata
SetAttribute(attrClass.name(), attrClass.value(), TRUE);
}
for (pugi::xml_attribute attr = xmlNode.first_attribute(); attr; attr = attr.next_attribute())
{
if(attr.get_userdata()) continue; //忽略已经被预处理的属性
SetAttribute(attr.name(), attr.value(), TRUE);
}
if(attrClass)
{
attrClass.set_userdata(0);
}
//调用初始化完成接口
OnInitFinished(xmlNode);
return TRUE;
}
示例2: node_to_string
std::string node_to_string(pugi::xml_node node)
{
xml_string_writer writer;
node.print(writer);
return writer.result;
}
示例3: StartElementInString
std::string PugiHelper::StartElementInString( const pugi::xml_node& node )
{
std::stringstream ss;
node.print(ss);
std::string line;
std::getline(ss, line);
return line;
}
示例4: ElementInString
LM_NAMESPACE_BEGIN
std::string PugiHelper::ElementInString( const pugi::xml_node& node )
{
std::stringstream ss;
node.print(ss);
return ss.str();
}
示例5: test_node
bool test_node(const pugi::xml_node& node, const pugi::char_t* contents, const pugi::char_t* indent, unsigned int flags)
{
xml_writer_string writer;
node.print(writer, indent, flags, get_native_encoding());
return writer.as_string() == contents;
}
示例6: STR
std::basic_string<wchar_t> write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
{
xml_writer_string writer;
node.print(writer, STR("\t"), flags, encoding);
return writer.as_wide();
}
示例7: write_narrow
std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding)
{
xml_writer_string writer;
node.print(writer, STR("\t"), flags, encoding);
return writer.as_narrow();
}
示例8: toString_priv
tiny_string XMLNode::toString_priv(pugi::xml_node outputNode)
{
if(outputNode.type() == pugi::node_null)
return "";
ostringstream buf;
outputNode.print(buf);
tiny_string ret = tiny_string(buf.str());
return ret;
}
示例9: route
ProcessResult PresenceRouter::route(mtalk::talk::SessionPtr sessionPtr, const pugi::xml_node& node){
std::string toStr = node.attribute("to").value();
std::string fromStr = node.attribute("from").value();
JID to(toStr);
JID from(fromStr);
if(to.getEndpoint() == "muc.m.renren.com"){
long fromid = from.getUserId();
string sessionid = sessionPtr->getSessionId();
stringstream ss;
node.print(ss,"\t",pugi::format_raw);
string message=ss.str();
bool forward =MY_INSTANCE(ProxyRegister).getProxy<MucServiceProxy>("mucProxy")->forwardPresence(fromid,sessionid,message); //推给muc服务器
// 如果forward成功,返回ok,否则返回error
if(forward){
ProcessResult result(ProcessResult::OK, "<success/>");
return result;
}else {
ProcessResult result(ProcessResult::ERROR, "forward muc fail");
return result;
}
}
//单聊信息
if(to.getEndpoint() == "talk.sixin.com" || to.getEndpoint() == "renren.sixin.com" || to.getEndpoint() == "talk.m.renren.com" ||to.getEndpoint() ==""){
LOG_DEBUG("PresenceRoute::route presence message");
if(strcmp(node.attribute("type").value(), "unavailable") == 0 ||
strcmp(node.attribute("type").value(), "background") == 0||
strcmp(node.attribute("type").value(), "foreground") == 0){
return offlineHandlerPtr_->handler(sessionPtr, node);
}
stringstream os;
node.print(os,"\t",pugi::format_raw);
MY_INSTANCE(TalkServer).remotePush(from.getUserId(), to.getUserId(), os.str(), MessageType::ENTITY);
ProcessResult result;
return result;
} else{
long fromid = from.getUserId();
long toid = to.getUserId();
stringstream ss;
node.print(ss,"\t",pugi::format_raw);
string message=ss.str();
string router=to.getRouter();
LOG_DEBUG("PrsenceRoute::route forward "<< to.getEndpoint()<<"presence msg = "<<message);
router.append("ServiceProxy");
ProcessResult result;
bool forward = 0;
LOG_DEBUG("PresenceRoute::route forward "<< router<<"presence msg = "<<message);
if(MY_INSTANCE(ProxyRegister).getProxy<RouterServiceProxy>(router).get()!=0){
LOG_DEBUG("PresenceRoute::get RouterServiceProxy and forward "<< router<<"presence msg = "<<message);
forward = MY_INSTANCE(ProxyRegister).getProxy<RouterServiceProxy>(router)->forwardPresence(fromid,toid,message);
}
// 如果forward成功,返回ok,否则返回error
string id = node.attribute("id").value();
string type=node.attribute("type").value();
if(forward){
result.setCode(ProcessResult::OK);
stringstream ss;
ss<<"<success id='";
ss<<id;
ss << "' from='";
ss << from.toString();
ss << "' to='";
ss << to.toString();
ss<<"' type='";
ss<<type;
ss<<"'/>";
result.setMsg(ss.str());
return result;
}else {
result.setCode(ProcessResult::ERROR);
stringstream s;
s<<"<error id='";
s<<id;
s<<"'>fail to ";
s<<to.getEndpoint();
s<<" error</error>";
result.setMsg(s.str());
result.setMsg("<error>talk internal error</error>");
return result;
}
}
}