[libxml++] Remove the --disable-api-exceptions configure option.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml++] Remove the --disable-api-exceptions configure option.
- Date: Tue, 20 Mar 2012 09:58:24 +0000 (UTC)
commit 81fead80bc5d0cc6f6188fd2d0f883def0e9a01e
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Mar 20 10:58:05 2012 +0100
Remove the --disable-api-exceptions configure option.
And remove the #ifdefs and #else blocks from the code.
This is not used by anybody now, as far as I know, so this makes the
code easier to maintain.
ChangeLog | 8 +++
configure.ac | 2 -
examples/dom_build/main.cc | 4 --
examples/dom_parse_entities/main.cc | 4 --
examples/dom_parser/main.cc | 4 --
examples/dom_parser_raw/main.cc | 9 ---
examples/dom_read_write/main.cc | 4 --
examples/dom_xpath/main.cc | 4 --
examples/dtdvalidation/main.cc | 12 ----
examples/import_node/main.cc | 6 +--
examples/sax_exception/main.cc | 4 --
examples/sax_exception/myparser.cc | 4 --
examples/sax_parser/main.cc | 4 --
examples/sax_parser/myparser.cc | 3 +-
examples/sax_parser/myparser.h | 2 -
examples/sax_parser_build_dom/main.cc | 4 --
examples/sax_parser_entities/main.cc | 4 --
examples/schemavalidation/main.cc | 4 +-
examples/textreader/main.cc | 4 --
libxml++/document.cc | 24 ---------
libxml++/exceptions/exception.cc | 2 -
libxml++/exceptions/internal_error.cc | 2 -
libxml++/exceptions/parse_error.cc | 2 -
libxml++/exceptions/validity_error.cc | 2 -
libxml++/io/outputbuffer.cc | 6 --
libxml++/io/parserinputbuffer.cc | 2 -
libxml++/nodes/contentnode.cc | 11 +----
libxml++/nodes/element.cc | 2 -
libxml++/nodes/node.cc | 32 +-----------
libxml++/parsers/domparser.cc | 24 ---------
libxml++/parsers/parser.cc | 5 +--
libxml++/parsers/saxparser.cc | 87 +++-----------------------------
libxml++/parsers/textreader.cc | 6 --
libxml++/schema.cc | 8 ---
libxml++/validators/dtdvalidator.cc | 20 -------
libxml++/validators/schemavalidator.cc | 18 -------
libxml++/validators/validator.cc | 8 ---
macros/reduced.m4 | 20 -------
38 files changed, 22 insertions(+), 349 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6733ca5..d8d7ccb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2012-03-20 Murray Cumming <murrayc murrayc com>
+ Remove the --disable-api-exceptions configure option.
+
+ And remove the #ifdefs and #else blocks from the code.
+ This is not used by anybody now, as far as I know, so this makes the
+ code easier to maintain.
+
+2012-03-20 Murray Cumming <murrayc murrayc com>
+
A fix for the previous commit.
* libxml++/nodes/node.cc: get_first_child() const: Use the name
diff --git a/configure.ac b/configure.ac
index 0bf76a7..d0c5734 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,8 +42,6 @@ AC_ARG_ENABLE([examples],
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = xyes])
-# Offer the ability to omit some API from the library, to reduce the code size:
-LIBXMLCPP_ARG_ENABLE_API_EXCEPTIONS
MM_ARG_ENABLE_DOCUMENTATION
MM_ARG_WITH_TAGFILE_DOC([glibmm-2.4.tag], [glibmm-2.4])
diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc
index 1ed3090..367620e 100644
--- a/examples/dom_build/main.cc
+++ b/examples/dom_build/main.cc
@@ -33,10 +33,8 @@ main(int /* argc */, char** /* argv */)
// so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
std::locale::global(std::locale(""));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::Document document;
document.set_internal_subset("example_xml_doc", "", "example_xml_doc.dtd");
document.set_entity_declaration("example1", xmlpp::XML_INTERNAL_GENERAL_ENTITY,
@@ -71,13 +69,11 @@ main(int /* argc */, char** /* argv */)
Glib::ustring whole = document.write_to_string();
std::cout << "XML built at runtime: " << std::endl << whole << std::endl;
std::cout << "namespace of root node: " << nodeRoot->get_namespace_uri() << std::endl;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/dom_parse_entities/main.cc b/examples/dom_parse_entities/main.cc
index b0c47ff..9f67a59 100644
--- a/examples/dom_parse_entities/main.cc
+++ b/examples/dom_parse_entities/main.cc
@@ -86,10 +86,8 @@ int main(int argc, char* argv[])
else
std::cout << std::endl << "<<< Without entity substitution >>>" << std::endl;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DomParser parser;
parser.set_validate();
parser.set_substitute_entities(substitute_entities);
@@ -100,13 +98,11 @@ int main(int argc, char* argv[])
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode, substitute_entities);
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
if (substitute_entities) break;
diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc
index 5929ce3..54785f3 100644
--- a/examples/dom_parser/main.cc
+++ b/examples/dom_parser/main.cc
@@ -152,10 +152,8 @@ int main(int argc, char* argv[])
else
filepath = "example.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DomParser parser;
if (validate)
parser.set_validate();
@@ -170,13 +168,11 @@ int main(int argc, char* argv[])
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode);
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc
index 8353f60..0db852f 100644
--- a/examples/dom_parser_raw/main.cc
+++ b/examples/dom_parser_raw/main.cc
@@ -70,10 +70,8 @@ int main(int argc, char* argv[])
else
filepath = "example.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DomParser parser;
parser.set_validate();
parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically.
@@ -82,7 +80,6 @@ int main(int argc, char* argv[])
std::string contents = read_from_disk(filepath);
std::string contents_ucs2;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
contents_ucs2 = Glib::convert(contents, "UCS-2", "UTF-8");
@@ -91,10 +88,6 @@ int main(int argc, char* argv[])
{
std::cerr << "Glib::convert failed: " << ex.what() << std::endl;
}
- #else
- std::auto_ptr<Glib::Error> error;
- contents_ucs2 = Glib::convert(contents, "UCS-2", "UTF-8", error);
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser.parse_memory_raw((const unsigned char*)contents_ucs2.c_str(), contents_ucs2.size());
@@ -113,13 +106,11 @@ int main(int argc, char* argv[])
const xmlpp::Node* pNode = parser.get_document()->get_root_node(); //deleted by DomParser.
print_node(pNode);
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/dom_read_write/main.cc b/examples/dom_read_write/main.cc
index cc298ea..0ac5628 100644
--- a/examples/dom_read_write/main.cc
+++ b/examples/dom_read_write/main.cc
@@ -47,10 +47,8 @@ main(int argc, char* argv[])
else
filepath_out = "example_output.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DomParser parser;
parser.set_validate();
parser.parse_file(filepath_in);
@@ -61,13 +59,11 @@ main(int argc, char* argv[])
if(document)
document->write_to_file(filepath_out);
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc
index e38fa99..f8722e0 100644
--- a/examples/dom_xpath/main.cc
+++ b/examples/dom_xpath/main.cc
@@ -56,10 +56,8 @@ int main(int argc, char* argv[])
else
filepath = "example.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DomParser parser(filepath);
if(parser)
{
@@ -87,13 +85,11 @@ int main(int argc, char* argv[])
xpath_test(root, "//xref/@linkend");
}
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc
index 74b3ec1..84b0511 100644
--- a/examples/dtdvalidation/main.cc
+++ b/examples/dtdvalidation/main.cc
@@ -43,51 +43,39 @@ int main(int argc, char* argv[])
xmlpp::Document document;
/* xmlpp::Element* nodeRoot = */document.create_root_node("incorrect");
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DtdValidator validator( dtdfilepath );
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
validator.validate( &document );
std::cout << "Validation successful" << std::endl;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch( const xmlpp::validity_error& )
{
std::cout << "Error validating the document" << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
/* xmlpp::Element* nodeRoot2 = */document.create_root_node("example");
xmlpp::Element * child = document.get_root_node()->add_child("examplechild");
child->set_attribute("id", "an_id");
child->add_child("child_of_child");
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::DtdValidator validator2( dtdfilepath );
validator2.validate( &document );
std::cout << "Validation successful" << std::endl;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch( const xmlpp::validity_error& )
{
std::cout << "Error validating the document" << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch( const xmlpp::parse_error& )
{
std::cerr << "Error parsing the dtd" << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
diff --git a/examples/import_node/main.cc b/examples/import_node/main.cc
index 8a0b44a..22abfb4 100644
--- a/examples/import_node/main.cc
+++ b/examples/import_node/main.cc
@@ -13,10 +13,8 @@ int main (int /* argc */, char** /* argv */)
// so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
std::locale::global(std::locale(""));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
- {
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
+ {
DomParser example1("example1.xml");
DomParser example2("example2.xml");
@@ -37,12 +35,10 @@ int main (int /* argc */, char** /* argv */)
string doc1_string = doc1->write_to_string_formatted();
cout << doc1_string;
return EXIT_SUCCESS;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch (std::exception& ex)
{
cerr << "Caught exception " << ex.what() << endl;
return EXIT_FAILURE;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
diff --git a/examples/sax_exception/main.cc b/examples/sax_exception/main.cc
index b316ea7..e64610a 100644
--- a/examples/sax_exception/main.cc
+++ b/examples/sax_exception/main.cc
@@ -38,18 +38,14 @@ int main(int /* argc */, char** /* argv */)
MySaxParser parser;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser.parse_file("example.xml");
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& ex)
{
std::cout << "Exception caught: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc
index b66b928..11356c6 100644
--- a/examples/sax_exception/myparser.cc
+++ b/examples/sax_exception/myparser.cc
@@ -38,9 +38,7 @@ MyException::~MyException() throw ()
void MyException::Raise() const
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw *this;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
xmlpp::exception * MyException::Clone() const
@@ -83,9 +81,7 @@ void MySaxParser::on_start_element(const Glib::ustring& name,
std::cout << " Attribute " << iter->name << " = " << iter->value << std::endl;
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw MyException();
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void MySaxParser::on_end_element(const Glib::ustring& /* name */)
diff --git a/examples/sax_parser/main.cc b/examples/sax_parser/main.cc
index cb4ad22..bf1c088 100644
--- a/examples/sax_parser/main.cc
+++ b/examples/sax_parser/main.cc
@@ -42,20 +42,16 @@ main(int argc, char* argv[])
filepath = "example.xml";
// Parse the entire document in one go:
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
MySaxParser parser;
parser.set_substitute_entities(true); //
parser.parse_file(filepath);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const xmlpp::exception& ex)
{
std::cout << "libxml++ exception: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
// Demonstrate incremental parsing, sometimes useful for network connections:
diff --git a/examples/sax_parser/myparser.cc b/examples/sax_parser/myparser.cc
index b12591a..ce023d4 100644
--- a/examples/sax_parser/myparser.cc
+++ b/examples/sax_parser/myparser.cc
@@ -33,7 +33,6 @@ MySaxParser::~MySaxParser()
{
}
-#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
void MySaxParser::on_start_document()
{
std::cout << "on_start_document()" << std::endl;
@@ -136,4 +135,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 d500af1..7774a80 100644
--- a/examples/sax_parser/myparser.h
+++ b/examples/sax_parser/myparser.h
@@ -32,7 +32,6 @@ 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,
@@ -43,7 +42,6 @@ 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/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc
index 8292cc9..c2f019d 100644
--- a/examples/sax_parser_build_dom/main.cc
+++ b/examples/sax_parser_build_dom/main.cc
@@ -47,10 +47,8 @@ main(int argc, char* argv[])
else
filepath = "example.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
SVG::Document doc;
SVG::Parser parser(doc);
@@ -69,13 +67,11 @@ main(int argc, char* argv[])
SVG::Path* path = dynamic_cast<SVG::Path*>(nl[0]);
std::cout << "style of first path node with a style = \"" << path->get_style() << "\"" << std::endl;
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const xmlpp::exception& ex)
{
std::cout << "libxml++ exception: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/sax_parser_entities/main.cc b/examples/sax_parser_entities/main.cc
index e0e8df2..7075fce 100644
--- a/examples/sax_parser_entities/main.cc
+++ b/examples/sax_parser_entities/main.cc
@@ -41,20 +41,16 @@ main(int argc, char* argv[])
else
filepath = "example.xml";
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
MySaxParser parser;
parser.set_substitute_entities(false); //We want to know about the entities, not have them substituted automatically.
parser.parse_file(filepath);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const xmlpp::exception& ex)
{
std::cout << "libxml++ exception: " << ex.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return 0;
}
diff --git a/examples/schemavalidation/main.cc b/examples/schemavalidation/main.cc
index 6b6fb63..2206660 100644
--- a/examples/schemavalidation/main.cc
+++ b/examples/schemavalidation/main.cc
@@ -60,10 +60,8 @@ 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
+ std::cout << error.what();
}
}
catch( const xmlpp::parse_error& )
diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc
index 0016d73..a6957e7 100644
--- a/examples/textreader/main.cc
+++ b/examples/textreader/main.cc
@@ -48,10 +48,8 @@ int main(int /* argc */, char** /* argv */)
// so we can use std::cout with UTF-8, via Glib::ustring, without exceptions.
std::locale::global(std::locale(""));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
xmlpp::TextReader reader("example.xml");
while(reader.read())
@@ -82,12 +80,10 @@ int main(int /* argc */, char** /* argv */)
std::cout << indent(depth) << "novalue" << std::endl;
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const std::exception& e)
{
std::cout << "Exception caught: " << e.what() << std::endl;
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
diff --git a/libxml++/document.cc b/libxml++/document.cc
index 03e6996..06cf137 100644
--- a/libxml++/document.cc
+++ b/libxml++/document.cc
@@ -145,11 +145,7 @@ Element* Document::create_root_node_by_import(const Node* node,
xmlNode* imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_, recursive);
if (!imported_node)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("Unable to import node");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
xmlDocSetRootElement(impl_, imported_node);
@@ -162,11 +158,7 @@ CommentNode* Document::add_comment(const Glib::ustring& content)
xmlNode* node = xmlNewComment((const xmlChar*)content.c_str());
if(!node)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot create comment node");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
// Use the result, because node can be freed when merging text nodes:
@@ -181,11 +173,7 @@ ProcessingInstructionNode* Document::add_processing_instruction(
xmlNode* node = xmlNewDocPI(impl_, (const xmlChar*)name.c_str(), (const xmlChar*)content.c_str());
if(!node)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot create processing instruction node");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
node = xmlAddChild((xmlNode*)impl_, node);
Node::create_wrapper(node);
@@ -234,11 +222,7 @@ void Document::do_write_to_file(
if(result == -1)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("do_write_to_file() failed.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
@@ -256,11 +240,7 @@ Glib::ustring Document::do_write_to_string(
if(!buffer)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("do_write_to_string() failed.");
- #else
- return Glib::ustring();
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
// Create a Glib::ustring copy of the buffer
@@ -285,11 +265,7 @@ void Document::do_write_to_stream(std::ostream& output, const Glib::ustring& enc
if(result == -1)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("do_write_to_stream() failed.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc
index da36c64..40c71a9 100644
--- a/libxml++/exceptions/exception.cc
+++ b/libxml++/exceptions/exception.cc
@@ -19,9 +19,7 @@ const char* exception::what() const throw()
void exception::Raise() const
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw *this;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
exception * exception::Clone() const
diff --git a/libxml++/exceptions/internal_error.cc b/libxml++/exceptions/internal_error.cc
index fbff40c..1cea292 100644
--- a/libxml++/exceptions/internal_error.cc
+++ b/libxml++/exceptions/internal_error.cc
@@ -13,9 +13,7 @@ internal_error::~internal_error() throw()
void internal_error::Raise() const
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw *this;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
exception * internal_error::Clone() const
diff --git a/libxml++/exceptions/parse_error.cc b/libxml++/exceptions/parse_error.cc
index 7e37993..2ad8ccd 100644
--- a/libxml++/exceptions/parse_error.cc
+++ b/libxml++/exceptions/parse_error.cc
@@ -12,9 +12,7 @@ parse_error::~parse_error() throw()
void parse_error::Raise() const
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw *this;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
exception* parse_error::Clone() const
diff --git a/libxml++/exceptions/validity_error.cc b/libxml++/exceptions/validity_error.cc
index f10d890..5376d3a 100644
--- a/libxml++/exceptions/validity_error.cc
+++ b/libxml++/exceptions/validity_error.cc
@@ -12,9 +12,7 @@ validity_error::~validity_error() throw()
void validity_error::Raise() const
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw *this;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
exception* validity_error::Clone() const
diff --git a/libxml++/io/outputbuffer.cc b/libxml++/io/outputbuffer.cc
index fb7b3bc..7f0beee 100644
--- a/libxml++/io/outputbuffer.cc
+++ b/libxml++/io/outputbuffer.cc
@@ -51,11 +51,7 @@ namespace xmlpp
handler = xmlFindCharEncodingHandler(encoding.c_str());
if(handler == 0)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot initialise an encoder to " + encoding);
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
}
@@ -67,9 +63,7 @@ namespace xmlpp
handler);
if(impl_ == 0)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot initialise underlying xmlOutputBuffer");
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
diff --git a/libxml++/io/parserinputbuffer.cc b/libxml++/io/parserinputbuffer.cc
index d033d74..223c08a 100644
--- a/libxml++/io/parserinputbuffer.cc
+++ b/libxml++/io/parserinputbuffer.cc
@@ -41,9 +41,7 @@ namespace xmlpp
XML_CHAR_ENCODING_NONE);
if(impl_ == 0)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot initialise underlying xmlParserInputBuffer");
- #endif
}
}
diff --git a/libxml++/nodes/contentnode.cc b/libxml++/nodes/contentnode.cc
index 6f8d680..7153c3c 100644
--- a/libxml++/nodes/contentnode.cc
+++ b/libxml++/nodes/contentnode.cc
@@ -23,11 +23,7 @@ Glib::ustring ContentNode::get_content() const
{
if(cobj()->type == XML_ELEMENT_NODE)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("this node type doesn't have content");
- #else
- return Glib::ustring();
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
return cobj()->content ? (char*)cobj()->content : "";
@@ -37,13 +33,8 @@ void ContentNode::set_content(const Glib::ustring& content)
{
if(cobj()->type == XML_ELEMENT_NODE)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("can't set content for this node type");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
- }
-
+ }
xmlNodeSetContent(cobj(), (xmlChar*)content.c_str());
}
diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc
index 365d5ac..2e3f786 100644
--- a/libxml++/nodes/element.cc
+++ b/libxml++/nodes/element.cc
@@ -92,9 +92,7 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring
}
else
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("The namespace prefix (" + ns_prefix + ") has not been declared.");
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index 0c2cea9..9555e9d 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -189,11 +189,7 @@ _xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ust
if(impl_->type != XML_ELEMENT_NODE)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
- throw internal_error("You can only add child nodes to element nodes");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
+ throw internal_error("You can only add child nodes to element nodes");
}
if(ns_prefix.empty())
@@ -207,11 +203,7 @@ _xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ust
ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str());
if (!ns)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("The namespace prefix (" + ns_prefix + ") has not been declared.");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
@@ -236,11 +228,7 @@ Node* Node::import_node(const Node* node, bool recursive)
xmlNode* imported_node = xmlDocCopyNode(const_cast<xmlNode*>(node->cobj()), impl_->doc, recursive);
if (!imported_node)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("Unable to import node");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
//Add the node:
@@ -250,11 +238,7 @@ Node* Node::import_node(const Node* node, bool recursive)
Node::free_wrappers(imported_node);
xmlFreeNode(imported_node);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("Unable to add imported node to current node");
- #else
- return 0;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
Node::create_wrapper(imported_node);
@@ -303,11 +287,7 @@ static NodeSet find_impl(xmlXPathContext* ctxt, const Glib::ustring& xpath)
{
xmlXPathFreeContext(ctxt);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("Invalid XPath: " + xpath);
- #else
- return NodeSet();
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
if(result->type != XPATH_NODESET)
@@ -315,11 +295,7 @@ static NodeSet find_impl(xmlXPathContext* ctxt, const Glib::ustring& xpath)
xmlXPathFreeObject(result);
xmlXPathFreeContext(ctxt);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Only nodeset result types are supported.");
- #else
- return NodeSet();
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
xmlNodeSet* nodeset = result->nodesetval;
@@ -432,11 +408,7 @@ void Node::set_namespace(const Glib::ustring& ns_prefix)
{
if (impl_->type == XML_ATTRIBUTE_DECL)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("Can't set the namespace of an attribute declaration");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
//Look for the existing namespace to use:
@@ -448,9 +420,7 @@ void Node::set_namespace(const Glib::ustring& ns_prefix)
}
else
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw exception("The namespace (" + ns_prefix + ") has not been declared.");
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc
index 0bd249c..52fb8d2 100644
--- a/libxml++/parsers/domparser.cc
+++ b/libxml++/parsers/domparser.cc
@@ -50,11 +50,7 @@ void DomParser::parse_file(const Glib::ustring& filename)
if(!context_)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Couldn't create parsing context\n" + format_xml_error());
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
if(context_->directory == 0)
@@ -78,11 +74,7 @@ void DomParser::parse_memory_raw(const unsigned char* contents, size_type bytes_
if(!context_)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Couldn't create parsing context\n" + format_xml_error());
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
parse_context();
@@ -104,11 +96,7 @@ void DomParser::parse_context()
if(!context_)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Context not initialized\n" + format_xml_error());
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
xmlParseDocument(context_);
@@ -121,11 +109,7 @@ void DomParser::parse_context()
{
release_underlying(); //Free doc_ and context_
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error(error_str);
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
doc_ = new Document(context_->myDoc);
@@ -157,11 +141,7 @@ void DomParser::parse_stream(std::istream& in)
if(!context_)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Couldn't create parsing context\n" + format_xml_error());
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
initialize_context();
@@ -187,11 +167,7 @@ void DomParser::parse_stream(std::istream& in)
{
release_underlying(); //Free doc_ and context_
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error(error_str);
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
doc_ = new Document(context_->myDoc);
diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc
index f458ed4..b1055b7 100644
--- a/libxml++/parsers/parser.cc
+++ b/libxml++/parsers/parser.cc
@@ -259,10 +259,9 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx,
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, var_args);
ubuff = buff;
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+
try
{
- #endif
switch (msg_type)
{
case MsgParserError:
@@ -278,13 +277,11 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx,
parser->on_validity_warning(ubuff);
break;
}
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif
}
}
}
diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc
index 7c5d240..d937cbf 100644
--- a/libxml++/parsers/saxparser.cc
+++ b/libxml++/parsers/saxparser.cc
@@ -127,17 +127,10 @@ void SaxParser::on_error(const Glib::ustring& /* text */)
}
-#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
void SaxParser::on_fatal_error(const Glib::ustring& text)
{
throw parse_error("Fatal error: " + text);
}
-#else
-void SaxParser::on_fatal_error(const Glib::ustring&)
-{
- //throw parse_error("Fatal error: " + text);
-}
-#endif //LIBXMLCPP_EXCEPTIONS_ENABLED
void SaxParser::on_cdata_block(const Glib::ustring& /* text */)
{
@@ -155,12 +148,9 @@ void SaxParser::on_internal_subset(const Glib::ustring& name,
void SaxParser::parse()
{
- if(!context_) {
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ if(!context_)
+ {
throw internal_error("Parse context not created.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
xmlSAXHandlerPtr old_sax = context_->sax;
@@ -183,12 +173,9 @@ void SaxParser::parse()
void SaxParser::parse_file(const Glib::ustring& filename)
{
- if(context_) {
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ if(context_)
+ {
throw parse_error("Attempt to start a second parse while a parse is in progress.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
KeepBlanks k(KeepBlanks::Default);
@@ -199,12 +186,9 @@ void SaxParser::parse_file(const Glib::ustring& filename)
void SaxParser::parse_memory_raw(const unsigned char* contents, size_type bytes_count)
{
- if(context_) {
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ if(context_)
+ {
throw parse_error("Attempt to start a second parse while a parse is in progress.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
KeepBlanks k(KeepBlanks::Default);
@@ -220,12 +204,9 @@ void SaxParser::parse_memory(const Glib::ustring& contents)
void SaxParser::parse_stream(std::istream& in)
{
- if(context_) {
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
+ if(context_)
+ {
throw parse_error("Attempt to start a second parse while a parse is in progress.");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
KeepBlanks k(KeepBlanks::Default);
@@ -318,18 +299,14 @@ xmlEntityPtr SaxParserCallback::get_entity(void* context, const xmlChar* name)
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
xmlEntityPtr result = 0;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
result = parser->on_get_entity((const char*)name);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
return result;
}
@@ -339,23 +316,19 @@ void SaxParserCallback::entity_decl(void* context, const xmlChar* name, int type
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_entity_declaration(
( name ? Glib::ustring((const char*)name) : ""),
static_cast<XmlEntityType>(type),
( publicId ? Glib::ustring((const char*)publicId) : ""),
( systemId ? Glib::ustring((const char*)systemId) : ""),
( content ? Glib::ustring((const char*)content) : "") );
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::start_document(void* context)
@@ -363,18 +336,14 @@ void SaxParserCallback::start_document(void* context)
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_start_document();
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::end_document(void* context)
@@ -385,18 +354,14 @@ void SaxParserCallback::end_document(void* context)
if(parser->exception_)
return;
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_end_document();
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::start_element(void* context,
@@ -413,18 +378,14 @@ void SaxParserCallback::start_element(void* context,
attributes.push_back(
SaxParser::Attribute( (char*)*cur, (char*)*(cur + 1) ));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_start_element(Glib::ustring((const char*) name), attributes);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::end_element(void* context, const xmlChar* name)
@@ -432,18 +393,14 @@ void SaxParserCallback::end_element(void* context, const xmlChar* name)
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_end_element(Glib::ustring((const char*) name));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::characters(void * context, const xmlChar* ch, int len)
@@ -451,10 +408,8 @@ void SaxParserCallback::characters(void * context, const xmlChar* ch, int len)
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
// Here we force the use of Glib::ustring::ustring( InputIterator begin, InputIterator end )
// instead of Glib::ustring::ustring( const char*, size_type ) because it
// expects the length of the string in characters, not in bytes.
@@ -462,13 +417,11 @@ void SaxParserCallback::characters(void * context, const xmlChar* ch, int len)
Glib::ustring(
reinterpret_cast<const char *>(ch),
reinterpret_cast<const char *>(ch + len) ) );
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::comment(void* context, const xmlChar* value)
@@ -476,18 +429,14 @@ void SaxParserCallback::comment(void* context, const xmlChar* value)
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_comment(Glib::ustring((const char*) value));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::warning(void* context, const char* fmt, ...)
@@ -502,18 +451,14 @@ void SaxParserCallback::warning(void* context, const char* fmt, ...)
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg);
va_end(arg);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_warning(Glib::ustring(buff));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::error(void* context, const char* fmt, ...)
@@ -531,18 +476,14 @@ void SaxParserCallback::error(void* context, const char* fmt, ...)
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg);
va_end(arg);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_error(Glib::ustring(buff));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::fatal_error(void* context, const char* fmt, ...)
@@ -557,18 +498,14 @@ void SaxParserCallback::fatal_error(void* context, const char* fmt, ...)
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg);
va_end(arg);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
parser->on_fatal_error(Glib::ustring(buff));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::cdata_block(void* context, const xmlChar* value, int len)
@@ -576,23 +513,19 @@ void SaxParserCallback::cdata_block(void* context, const xmlChar* value, int len
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
// Here we force the use of Glib::ustring::ustring( InputIterator begin, InputIterator end )
// see comments in SaxParserCallback::characters
parser->on_cdata_block(
Glib::ustring(
reinterpret_cast<const char *>(value),
reinterpret_cast<const char *>(value + len) ) );
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
void SaxParserCallback::internal_subset(void* context, const xmlChar* name,
@@ -601,21 +534,17 @@ void SaxParserCallback::internal_subset(void* context, const xmlChar* name,
_xmlParserCtxt* the_context = static_cast<_xmlParserCtxt*>(context);
SaxParser* parser = static_cast<SaxParser*>(the_context->_private);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
const Glib::ustring pid = publicId ? Glib::ustring((const char*) publicId) : "";
const Glib::ustring sid = systemId ? Glib::ustring((const char*) systemId) : "";
parser->on_internal_subset( Glib::ustring((const char*) name), pid, sid);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
parser->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
} // namespace xmlpp
diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc
index c196d57..4a258dc 100644
--- a/libxml++/parsers/textreader.cc
+++ b/libxml++/parsers/textreader.cc
@@ -43,9 +43,7 @@ TextReader::TextReader(
{
if( ! impl_ )
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot instantiate underlying libxml2 structure");
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
setup_exceptions();
@@ -58,9 +56,7 @@ TextReader::TextReader(
{
if( ! impl_ )
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Cannot instantiate underlying libxml2 structure");
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
setup_exceptions();
@@ -389,12 +385,10 @@ void TextReader::check_for_exceptions() const
ths->severity_ = 0;
//TODO: Offer an alternative when not using exceptions?
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
if( severity == XML_PARSER_SEVERITY_ERROR )
throw parse_error(error_);
else if( severity == XML_PARSER_SEVERITY_VALIDITY_ERROR )
throw validity_error(error_);
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
int TextReader::PropertyReader::Int(int value)
diff --git a/libxml++/schema.cc b/libxml++/schema.cc
index a589083..581bb55 100644
--- a/libxml++/schema.cc
+++ b/libxml++/schema.cc
@@ -40,22 +40,14 @@ void Schema::set_document(Document* document, bool embed)
if(!context)
{
-#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error("Schema could not be parsed");
-#else
- return;
-#endif
}
impl_ = xmlSchemaParse(context);
if(!impl_)
{
xmlSchemaFreeParserCtxt(context);
-#ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error("Schema could not be parsed");
-#else
- return;
-#endif
}
impl_->_private = this;
diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc
index 5517720..f000214 100644
--- a/libxml++/validators/dtdvalidator.cc
+++ b/libxml++/validators/dtdvalidator.cc
@@ -61,11 +61,7 @@ void DtdValidator::parse_subset(const Glib::ustring& external,const Glib::ustrin
if (!dtd)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error("Dtd could not be parsed");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
Node::create_wrapper(reinterpret_cast<xmlNode*>(dtd));
@@ -90,11 +86,7 @@ void DtdValidator::parse_stream(std::istream& in)
if (!dtd)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw parse_error("Dtd could not be parsed");
- #else
- return;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
Node::create_wrapper(reinterpret_cast<xmlNode*>(dtd));
@@ -137,20 +129,12 @@ bool DtdValidator::validate(const Document* doc)
if(!valid_)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Couldn't create parsing context");
- #else
- return false;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
if (!doc)
{
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw internal_error("Document pointer cannot be 0");
- #else
- return false;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
initialize_valid();
@@ -161,11 +145,7 @@ bool DtdValidator::validate(const Document* doc)
{
check_for_exception();
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
throw validity_error("Document failed Dtd validation");
- #else
- return false;
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
return res;
diff --git a/libxml++/validators/schemavalidator.cc b/libxml++/validators/schemavalidator.cc
index 4f82313..2a73640 100644
--- a/libxml++/validators/schemavalidator.cc
+++ b/libxml++/validators/schemavalidator.cc
@@ -74,10 +74,8 @@ 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);
@@ -155,26 +153,20 @@ 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();
@@ -183,9 +175,7 @@ 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;
@@ -193,25 +183,19 @@ 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 );
@@ -219,9 +203,7 @@ 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;
diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc
index e5e9d8f..119ba61 100644
--- a/libxml++/validators/validator.cc
+++ b/libxml++/validators/validator.cc
@@ -95,18 +95,14 @@ void Validator::callback_validity_error(void* valid_, const char* msg, ...)
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, arg);
va_end(arg);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
validator->on_validity_error(Glib::ustring(buff));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
validator->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
@@ -124,18 +120,14 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...)
vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, arg);
va_end(arg);
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
try
{
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
validator->on_validity_warning(Glib::ustring(buff));
- #ifdef LIBXMLCPP_EXCEPTIONS_ENABLED
}
catch(const exception& e)
{
validator->handleException(e);
}
- #endif //LIBXMLCPP_EXCEPTIONS_ENABLED
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]