From: <m....@sy...> - 2005-06-09 17:14:09
|
> It will be error if you use (as you did) reference to NodeList. You > wrote the code like this: > > const xmlpp::Node::NodeList& m_nodeList = root->get_children(); > Even if I call the function like so: root->get_children().begin() I get the violation. And no, if I reference to the list, it is not invalid and .begin() should still be callable. It is the deferenceing it that will call the problem. The reference is the same as making a nodelist pointer that points to root->get_children() and calling ->begin() on it. I don't see how that should invalidate anything. |
From: <m....@sy...> - 2005-06-09 17:14:17
|
> It will be error if you use (as you did) reference to NodeList. You > wrote the code like this: > > const xmlpp::Node::NodeList& m_nodeList = root->get_children(); > Even if I call the function like so: root->get_children().begin() I get the violation. And no, if I reference to the list, it is not invalid and .begin() should still be callable. It is the deferenceing it that will call the problem. The reference is the same as making a nodelist pointer that points to root->get_children() and calling ->begin() on it. I don't see how that should invalidate anything. |
From: Darko M. <da...@uv...> - 2005-06-10 00:07:58
|
m....@sy... wrote: > Even if I call the function like so: > > root->get_children().begin() > > I get the violation. And no, if I reference to the list, it is not invalid and .begin() should still be callable. It is the deferenceing it that will call the problem. The reference is the same as making a nodelist pointer that points to root->get_children() and calling ->begin() on it. I don't see how that should invalidate anything. Now that is strange. I tried this micro code and no exception occured. #include <iostream> #include <string> #include <libxml++/libxml++.h> int main(int argc, char* argv[]) { try { if (argc > 1) { xmlpp::DomParser parser(argv[1], false); xmlpp::Element* root = parser.get_document()->get_root_node(); if (NULL != root) { const xmlpp::Node::NodeList& nlist = root->get_children(); xmlpp::Node::NodeList::const_iterator itr = nlist.begin(); } else { std::cout << "No root node!" << std::endl; } } else { std::cout << "Specify filename please" << std::endl; } } catch (const std::exception& e){ std::cerr << e.what() << std::endl; return -1; } return 0; } And using sample xml as input parameter with this content <?xml version="1.0"?> <!DOCTYPE root> <root> <child> <grandchildren> </grandchildren> </child> </root> I tested this with Borland Free Compiler 5.5.1 and with vc 2005 beta 1 compilers. libxml++ version 1.0.4 Compilers where using multithreaded dynamic RTL. Could you please verify that this does or does not work in your case? Darko |
From: Matthew S. <m....@sy...> - 2005-06-10 01:06:05
|
Darko Miletic wrote: > m....@sy... wrote: > >> Even if I call the function like so: >> >> root->get_children().begin() >> I get the violation. And no, if I reference to the list, it is not >> invalid and .begin() should still be callable. It is the deferenceing >> it that will call the problem. The reference is the same as making a >> nodelist pointer that points to root->get_children() and calling >> ->begin() on it. I don't see how that should invalidate anything. > > > Now that is strange. I tried this micro code and no exception occured. > I seem to have fixed (if not figured out the problem. I am using STLPort, and I was compiling with the preprocessor _STLP_DEBUG defined. I stopped defineing it (though I am still compiling in debug mode) and it works. I think this is a problem with either STLPort or Microsofts compiler haveing difficullties with templates. Thanks for your help guys! |
From: Darko M. <da...@uv...> - 2005-06-09 21:44:06
|
m....@sy... wrote: > Even if I call the function like so: > > root->get_children().begin() > > I get the violation. And no, if I reference to the list, it is not invalid and .begin() should still be callable. It is the deferenceing it that will call the problem. The reference is the same as making a nodelist pointer that points to root->get_children() and calling ->begin() on it. I don't see how that should invalidate anything. Now that is strange. I tried this micro code and no exception occured. #include <iostream> #include <string> #include <libxml++/libxml++.h> int main(int argc, char* argv[]) { try { if (argc > 1) { xmlpp::DomParser parser(argv[1], false); xmlpp::Element* root = parser.get_document()->get_root_node(); if (NULL != root) { const xmlpp::Node::NodeList& nlist = root->get_children(); xmlpp::Node::NodeList::const_iterator itr = nlist.begin(); } else { std::cout << "No root node!" << std::endl; } } else { std::cout << "Specify filename please" << std::endl; } } catch (const std::exception& e){ std::cerr << e.what() << std::endl; return -1; } return 0; } And using sample xml as input parameter with this content <?xml version="1.0"?> <!DOCTYPE root> <root> <child> <grandchildren> </grandchildren> </child> </root> I tested this with Borland Free Compiler 5.5.1 and with vc 2005 beta 1 compilers. libxml++ version 1.0.4 Compilers where using multithreaded dynamic RTL. Could you please verify that this does or does not work in your case? Darko |