RapidXML打印头具有未定义的方法 [英] RapidXML print header has undefined methods

查看:258
本文介绍了RapidXML打印头具有未定义的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为自己的项目之一使用RapidXML而感到困惑.一切顺利,直到我决定用它来写xml.我的代码大致如下:

I've been messing with using RapidXML on one of my projects. It was all going so well until I decided to use it for writing out xml. My code is more or less as follows:

//attempt to open the file for writing
std::ofstream file(fileName.c_str());
if (!file.is_open())
    return false; //the file didn't open

xml_document<> doc;
//creates the contents of the document...
//...
//...

//write the document out to the file
file << doc; //if I remove this line it compiles...but I kinda need this line to output to the file
file.close();

在编译时出现以下错误:

At compile time I get the following errors:

In file included from ../Engine/xmlfileloader.cpp:12:0:
../Engine/include/rapidxml_print.hpp: In instantiation of 'OutIt rapidxml::internal::print_node(OutIt, const rapidxml::xml_node<Ch>*, int, int) [with OutIt = std::ostream_iterator<char, char, std::char_traits<char> >; Ch = char]':
../Engine/include/rapidxml_print.hpp:390:57:   required from 'OutIt rapidxml::print(OutIt, const rapidxml::xml_node<Ch>&, int) [with OutIt = std::ostream_iterator<char, char, std::char_traits<char> >; Ch = char]'
../Engine/include/rapidxml_print.hpp:403:9:   required from 'std::basic_ostream<Ch>& rapidxml::print(std::basic_ostream<Ch>&, const rapidxml::xml_node<Ch>&, int) [with Ch = char]'
../Engine/include/rapidxml_print.hpp:414:31:   required from 'std::basic_ostream<Ch>& rapidxml::operator<<(std::basic_ostream<Ch>&, const rapidxml::xml_node<Ch>&) [with Ch = char]'
../Engine/xmlfileloader.cpp:400:13:   required from here
../Engine/include/rapidxml_print.hpp:115:17: error: 'print_children' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:169:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_children(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:120:17: error: 'print_element_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:242:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_element_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:125:17: error: 'print_data_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:208:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_data_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:130:17: error: 'print_cdata_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:219:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_cdata_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:135:17: error: 'print_declaration_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:298:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_declaration_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:140:17: error: 'print_comment_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:321:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_comment_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:145:17: error: 'print_doctype_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:339:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_doctype_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit
../Engine/include/rapidxml_print.hpp:150:17: error: 'print_pi_node' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
../Engine/include/rapidxml_print.hpp:361:22: note: 'template<class OutIt, class Ch> OutIt rapidxml::internal::print_pi_node(OutIt, const rapidxml::xml_node<Ch>*, int, int)' declared here, later in the translation unit

对我来说没有意义的是为什么它会以这种方式破裂.通过rapidxml_print.hpp标头查看,我看到在print_node函数中引用了所有上述所有函数.稍后定义了print_children,print_element_node等函数,乍一看似乎还可以.我在这里做什么错了?

What doesn't make sense to me is why it is breaking in this way. Looking through the rapidxml_print.hpp header I see all of the above noted functions referenced inside a print_node function. Later the print_children, print_element_node, etc functions are defined and it looks ok at a glance. What am I doing wrong here?

推荐答案

对于那些来这里寻找相同问题的解决方案的人,我有一个解决方案.查看 http://gcc.gnu.org/gcc-4.7/porting_to.html 在名称查找更改"下(根据nm的建议),我将rapidxml_print.hpp标头更改为在声明print_node函数之前具有以下权限(在我的文件中,我在第104行之后插入了此名称):/p>

For those who come here looking for a solution to the same problem, I have a solution. After looking at http://gcc.gnu.org/gcc-4.7/porting_to.html under "Name lookup changes" (per n.m.'s suggestion) I changed the rapidxml_print.hpp header to have the following right before the declaration of the print_node function (in my file, I inserted this right after line 104):

template<class OutIt, class Ch>
inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);

template<class OutIt, class Ch>
inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

template<class OutIt, class Ch>
inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);

现在它可以使用GCC很好地编译,并带有单个警告,因为显然int flags在print_attributes函数中未使用.

It now compiles nicely using GCC with a single warning since apparently int flags is unused in the print_attributes function.

这篇关于RapidXML打印头具有未定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆