From ce298ad2e8dbc3601d180c178bee9d606b8edab2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Mar 2013 10:45:12 +0200 Subject: Add convenience constructors to XML parsing and serialization exceptions --- cutl/xml/parser.hxx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'cutl/xml/parser.hxx') diff --git a/cutl/xml/parser.hxx b/cutl/xml/parser.hxx index 5dc2a83..d7011af 100644 --- a/cutl/xml/parser.hxx +++ b/cutl/xml/parser.hxx @@ -33,6 +33,8 @@ namespace cutl { namespace xml { + class parser; + struct LIBCUTL_EXPORT parsing: exception { virtual @@ -43,6 +45,8 @@ namespace cutl unsigned long long column, const std::string& description); + parsing (const parser&, const std::string& description); + const std::string& name () const {return name_;} @@ -59,6 +63,10 @@ namespace cutl what () const throw (); private: + void + init (); + + private: std::string name_; unsigned long long line_; unsigned long long column_; @@ -83,14 +91,20 @@ namespace cutl receive_characters | receive_attributes; - // Parse std::istream. Name is used in diagnostics to identify the - // document being parsed. std::ios_base::failure exception is used - // to report io errors (badbit and failbit). + // Parse std::istream. Input name is used in diagnostics to identify + // the document being parsed. std::ios_base::failure exception is + // used to report io errors (badbit and failbit). // parser (std::istream&, - const std::string& name, + const std::string& input_name, feature_type = receive_default); + const std::string& + input_name () const {return iname_;} + + // Parsing events. + // + public: enum event_type { // If adding new events, also update the stream insertion operator. @@ -135,6 +149,9 @@ namespace cutl event_type event () {return event_;} + // Event data. + // + public: const qname_type& qname () const {return *pqname_;} const std::string& namespace_ () const {return pqname_->namespace_ ();} @@ -202,7 +219,7 @@ namespace cutl private: std::istream& is_; - const std::string name_; + const std::string iname_; feature_type feature_; XML_Parser p_; -- cgit v1.1