From 29997999d609892b22d449ffce1ccd3d0608bbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Mon, 6 Apr 2009 14:57:27 +0000 Subject: [PATCH] get list of child nodes --- install-64-and-32-bit-linux.sh | 20 ++++++++++++++++++++ src/xml-cxx/xml.hxx | 9 ++------- src/xml.cxx | 9 ++++++++- 3 files changed, 30 insertions(+), 8 deletions(-) create mode 100755 install-64-and-32-bit-linux.sh diff --git a/install-64-and-32-bit-linux.sh b/install-64-and-32-bit-linux.sh new file mode 100755 index 0000000..276852e --- /dev/null +++ b/install-64-and-32-bit-linux.sh @@ -0,0 +1,20 @@ +./bootstrap.sh && \ +./configure && \ +make && \ +sudo make install && \ +make clean && \ +LDFLAGS="-L/usr/lib32 -m32" CXXFLAGS="-m32" ./configure \ + --libdir=/usr/local/lib32 \ + --build=x86_64 \ + --host=i386 && \ +make && \ +sudo make install && \ +make clean && \ +./configure \ + --prefix=/opt/local/i586-mingw32msvc \ + --build=x86_64 \ + --host=i586-mingw32msvc && \ +make && \ +sudo make install && \ +make clean + diff --git a/src/xml-cxx/xml.hxx b/src/xml-cxx/xml.hxx index b276875..61fc3c0 100644 --- a/src/xml-cxx/xml.hxx +++ b/src/xml-cxx/xml.hxx @@ -47,10 +47,6 @@ there of). - #include <xml-cxx/xml.hxx> - #include <iostream> - #include <<stream> - [...] xml::Factory test(xml::Node("persons") // root node <<(xml::Node("person") // child of persons .attr("id", xml::mandatory) @@ -59,13 +55,11 @@ <<(xml::Node("friends") // friends of person <<(xml::Node("friend") // a friend .attr("id", xml::mandatory))))); - [...] try { std::auto_ptr persons(test.read(std::ifstream("file.xml))); // Here we can be sure, that our structure is valid, // but we must check optional elements before access, otherwise // we get an exception. - [...] for (xml::Node::size_type i(0); i Contents; public: typedef Contents::size_type size_type; + typedef std::vector List; Node(std::string name) throw(); Node(const Node& o) throw(); Node& operator=(const Node& o) throw(); @@ -321,6 +315,7 @@ namespace xml { Node& attr(const std::string& name, bool mandatory) throw(); std::string attr(const std::string& name) const throw(); std::string& attr(const std::string& name) throw(); + List list(const std::string& name) const throw(); bool operator()(const std::string& child) const throw(); Node& operator<<(const Node& o) throw(cannot_have_children); Node& operator<<(const Attributes& o) throw(); diff --git a/src/xml.cxx b/src/xml.cxx index 8e4e963..08c8d6a 100644 --- a/src/xml.cxx +++ b/src/xml.cxx @@ -283,9 +283,16 @@ namespace xml { if (it!=_attributes.end()) return it->second; return std::string(); } - std::string& Node::attr(const std::string&name) throw() { + std::string& Node::attr(const std::string& name) throw() { return _attributes[name]; } + Node::List Node::list(const std::string& name) const throw() { + List res; + for (Contents::const_iterator it(_contents.begin()); + it!=_contents.end(); ++it) + if ((*it)->_name==name) res.push_back(*it); + return res; + } bool Node::operator()(const std::string& child) const throw() { return find(child); }