[libxml++] Fixed various bits to allow building with disabled exceptions



commit 07ed5ace80cc12412d88cce7f114853b9105f1c4
Author: Johannes Schmid <jhs gnome org>
Date:   Mon Jul 27 18:03:55 2009 +0200

    Fixed various bits to allow building with disabled exceptions

 ChangeLog                              |   11 +++++++++++
 examples/sax_parser/myparser.cc        |    3 ++-
 examples/sax_parser/myparser.h         |    2 ++
 examples/schemavalidation/main.cc      |    2 ++
 libxml++/schema.cc                     |    2 ++
 libxml++/validators/schemavalidator.cc |   20 ++++++++++++++++++--
 6 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 58227a5..c1f6111 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+=== 2.26.1 ===
+
+2009-07-27  Johannes Schmid <jschmid openismus com>
+
+	* libxml++/validators/schemavalidator.cc:
+	* libxml++/schema.cc: Fixed exception handling
+	problems in non-exception build
+	* examples/sax_parser/myparser.cc/h: Make example build withouth exceptions,
+	it's useless then though
+	* examples/schemavalidation/main.cc: Fixed build without exceptions
+
 2009-07-27  Johannes Schmid <jschmid openismus com> 
 
 	New tarball release
diff --git a/examples/sax_parser/myparser.cc b/examples/sax_parser/myparser.cc
index 01821e3..060abf8 100644
--- a/examples/sax_parser/myparser.cc
+++ b/examples/sax_parser/myparser.cc
@@ -33,6 +33,7 @@ MySaxParser::~MySaxParser()
 {
 }
 
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
 void MySaxParser::on_start_document()
 {
   std::cout << "on_start_document()" << std::endl;
@@ -135,4 +136,4 @@ void MySaxParser::on_fatal_error(const Glib::ustring& text)
     std::cerr << "MySaxParser::on_characters(): Exception caught while converting value for std::cout: " << ex.what() << std::endl;
   }
 }
-
+#endif
diff --git a/examples/sax_parser/myparser.h b/examples/sax_parser/myparser.h
index 7774a80..d500af1 100644
--- a/examples/sax_parser/myparser.h
+++ b/examples/sax_parser/myparser.h
@@ -32,6 +32,7 @@ public:
 
 protected:
   //overrides:
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   virtual void on_start_document();
   virtual void on_end_document();
   virtual void on_start_element(const Glib::ustring& name,
@@ -42,6 +43,7 @@ protected:
   virtual void on_warning(const Glib::ustring& text);
   virtual void on_error(const Glib::ustring& text);
   virtual void on_fatal_error(const Glib::ustring& text);
+#endif
 };
 
 
diff --git a/examples/schemavalidation/main.cc b/examples/schemavalidation/main.cc
index 88e47e1..1f19586 100644
--- a/examples/schemavalidation/main.cc
+++ b/examples/schemavalidation/main.cc
@@ -56,8 +56,10 @@ int main(int argc, char* argv[])
       }
       catch( const xmlpp::validity_error& error)
       {
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
         std::cout << "Error validating the document" << std::endl;
         std::cout << error.what();
+#endif		
       }
     }
     catch( const xmlpp::parse_error& )
diff --git a/libxml++/schema.cc b/libxml++/schema.cc
index db12a2a..2ca27a1 100644
--- a/libxml++/schema.cc
+++ b/libxml++/schema.cc
@@ -38,8 +38,10 @@ void Schema::set_document(Document* document, bool embed)
 
   xmlSchemaParserCtxtPtr context = xmlSchemaNewDocParserCtxt( document->cobj() );
   impl_ = xmlSchemaParse( context );
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if ( !impl_ )
    throw parse_error("Schema could not be parsed");
+#endif
   impl_->_private = this;
   embedded_doc_ = embed;
   xmlSchemaFreeParserCtxt( context );
diff --git a/libxml++/validators/schemavalidator.cc b/libxml++/validators/schemavalidator.cc
index 12ce1ec..4f82313 100644
--- a/libxml++/validators/schemavalidator.cc
+++ b/libxml++/validators/schemavalidator.cc
@@ -74,8 +74,10 @@ void SchemaValidator::parse_context(_xmlSchemaParserCtxt* context)
   release_underlying(); // Free any existing dtd.
 
   xmlSchema* schema = xmlSchemaParse( context );
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if ( ! schema )
    throw parse_error("Schema could not be parsed");
+#endif
 
   schema->_private = new Schema(schema);
 
@@ -153,20 +155,26 @@ void SchemaValidator::initialize_valid()
 
 bool SchemaValidator::validate(const Document* doc)
 {
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if (!doc)
     throw internal_error("Document pointer cannot be 0");
+#endif
 
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if (!schema_)
     throw internal_error("Must have a schema to validate document");
+#endif
 
   // A context is required at this stage only
   if (!ctxt_)
     ctxt_ = xmlSchemaNewValidCtxt( schema_->cobj() );
 
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if(!ctxt_)
   {
     throw internal_error("Couldn't create validating context");
   }
+#endif
 
   initialize_valid();
 
@@ -175,7 +183,9 @@ bool SchemaValidator::validate(const Document* doc)
   if(res != 0)
   {
     check_for_exception();
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
     throw validity_error("Document failed schema validation");
+#endif
   }
 
   return res;
@@ -183,21 +193,25 @@ bool SchemaValidator::validate(const Document* doc)
 
 bool SchemaValidator::validate(const Glib::ustring& file)
 {
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if (file.empty())
     throw internal_error("File path must not be empty");
+#endif
 
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if (!schema_)
     throw internal_error("Must have a schema to validate document");
-
+#endif
   // A context is required at this stage only
   if (!ctxt_)
     ctxt_ = xmlSchemaNewValidCtxt( schema_->cobj() );
 
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
   if(!ctxt_)
   {
     throw internal_error("Couldn't create validating context");
   }
-
+#endif
   initialize_valid();
 
   int res = xmlSchemaValidateFile( ctxt_, file.c_str(), 0 );
@@ -205,7 +219,9 @@ bool SchemaValidator::validate(const Glib::ustring& file)
   if(res != 0)
   {
     check_for_exception();
+#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
     throw validity_error("Document failed schema validation");
+#endif
   }
 
   return res;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]