From bc8c46114712480c53d243ff53bd35f4c031c13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 31 Mar 2010 15:13:10 +0000 Subject: [PATCH] new conversions --- INSTALL | 2 +- doc/makefile.am | 4 ++-- src/xml-cxx/xml.hxx | 2 ++ src/xml.cxx | 15 ++++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/INSTALL b/INSTALL index 5bb6e7b..cbd1c80 120000 --- a/INSTALL +++ b/INSTALL @@ -1 +1 @@ -/usr/share/automake-1.10/INSTALL \ No newline at end of file +/usr/share/automake-1.11/INSTALL \ No newline at end of file diff --git a/doc/makefile.am b/doc/makefile.am index 850a115..33cf277 100644 --- a/doc/makefile.am +++ b/doc/makefile.am @@ -27,8 +27,8 @@ ${devel_DATA}: ${ALL_SRC} doxyfile ${deps} if PEDANTIC test \! -s doxygen.errors endif - cd latex && make - mv latex/refman.pdf @PACKAGENAME@-@MAJOR@.@MINOR@.@LEAST@.pdf +# cd latex && make +# mv latex/refman.pdf @PACKAGENAME@-@MAJOR@.@MINOR@.@LEAST@.pdf CLEANFILES = doxygen.errors @PACKAGENAME@-@MAJOR@.@MINOR@.@LEAST@.pdf DISTCLEANFILES = @PACKAGENAME@.doxytag diff --git a/src/xml-cxx/xml.hxx b/src/xml-cxx/xml.hxx index 044e8e2..5a820f0 100644 --- a/src/xml-cxx/xml.hxx +++ b/src/xml-cxx/xml.hxx @@ -736,7 +736,9 @@ namespace xml { const std::string& value() const throw(); std::string& value() throw(); operator bool() const throw(); + bool toBool() const throw(); operator unsigned long() const throw(); + unsigned long toNumber() const throw(); operator List() const throw(); List toList(const std::string& separators=" \t\n\r") const throw(); std::string front(const std::string& separators=" \t\n\r") const diff --git a/src/xml.cxx b/src/xml.cxx index c8de363..b0c15d5 100644 --- a/src/xml.cxx +++ b/src/xml.cxx @@ -150,10 +150,20 @@ namespace xml { /*! @return @c true if the value is set and not equal to one of: @c false @c no @c 0. */ Attributes::Value::operator bool() const throw() { - return !(second.size()||second=="false"||second=="no"||second=="0"); + return bool(); + } + //! Convert the attribute to a boolean. + /*! @return @c true if the value is set and not equal to one of: + @c false @c no @c 0. */ + bool Attributes::Value::toBool() const throw() { + return !(!second.size()||second=="false"||second=="no"||second=="0"); } //! Convert the attribute to a number. Attributes::Value::operator unsigned long() const throw() { + return toNumber(); + } + //! Convert the attribute to a number. + unsigned long Attributes::Value::toNumber() const throw() { std::stringstream ss(second); int i(0); ss>>i; @@ -410,8 +420,7 @@ namespace xml { @endcode If a factory reads from a stream and the specified attribute is not given, it is set to @c deflt. */ - Node& Node::attr(const std::string& name, const std::string& deflt) - throw() { + Node& Node::attr(const std::string& name, const std::string& deflt) throw() { _attributes[name] = deflt; return *this; }