From: <vac...@us...> - 2008-11-16 01:40:19
|
Revision: 89 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=89&view=rev Author: vaclavslavik Date: 2008-11-16 01:40:16 +0000 (Sun, 16 Nov 2008) Log Message: ----------- fix ISO C++ compilation -- include missing C++ standard headers (patch by Greg Chicares) Modified Paths: -------------- trunk/AUTHORS trunk/include/xmlwrapp/event_parser.h trunk/src/libxml/node.cxx Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2008-11-16 01:32:26 UTC (rev 88) +++ trunk/AUTHORS 2008-11-16 01:40:16 UTC (rev 89) @@ -8,3 +8,4 @@ Patches: Tiziano Mueller <ti...@us...> + Greg Chicares <gch...@sb...> Modified: trunk/include/xmlwrapp/event_parser.h =================================================================== --- trunk/include/xmlwrapp/event_parser.h 2008-11-16 01:32:26 UTC (rev 88) +++ trunk/include/xmlwrapp/event_parser.h 2008-11-16 01:40:16 UTC (rev 89) @@ -38,6 +38,7 @@ #define _xmlwrapp_event_parser_h_ // standard includes +#include <cstddef> #include <string> #include <iosfwd> #include <map> Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-11-16 01:32:26 UTC (rev 88) +++ trunk/src/libxml/node.cxx 2008-11-16 01:40:16 UTC (rev 89) @@ -42,6 +42,7 @@ #include "node_manip.h" // standard includes +#include <cstring> #include <new> #include <memory> #include <string> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-11-16 02:22:07
|
Revision: 88 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=88&view=rev Author: vaclavslavik Date: 2008-11-16 01:32:26 +0000 (Sun, 16 Nov 2008) Log Message: ----------- removed text/tree_reader.* files, they were never finished and didn't contain working (or compilable) code Removed Paths: ------------- trunk/include/xmlwrapp/text_reader.h trunk/src/libxml/text_reader.cxx Deleted: trunk/include/xmlwrapp/text_reader.h =================================================================== --- trunk/include/xmlwrapp/text_reader.h 2008-11-16 01:30:21 UTC (rev 87) +++ trunk/include/xmlwrapp/text_reader.h 2008-11-16 01:32:26 UTC (rev 88) @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2005 Thomas M. Browder, Jr. - * <tbr...@us...> - * All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** @file - * This file contains the definition of the xml::tree_reader class. -**/ - -#ifndef _xmlwrapp_tree_reader_h_ -#define _xmlwrapp_tree_reader_h_ - -// standard includes -#include <cstddef> -#include <string> - -namespace xml { - - // forward declarations - struct tree_impl; - class document; - - /** - * The xml::tree_reader class is used to parse an XML document and generate - * a tree like structure of xml::node objects. After constructing a - * tree_reader, with either a file to parse or some in memory data to parse, - * you can walk the tree using the xml::node interface. - **/ - class tree_reader { - public: - typedef std::size_t size_type; - - //#################################################################### - /** - * xml::tree_reader class constructor. Given the name of a file, this - * constructor will parse that file. - * - * There are two options for dealing with XML parsing errors. The - * default it to throw an exception (std::runtime_error). The other - * option is to pass false for the allow_exceptions flag. This will - * prevent an exception from being thrown, instead, a flag will be set - * that you can test with the operator! member function. - * - * No matter what option you choose, this constructor may still throw - * exceptions for memory failure or other non-parsing related failures. - * - * @param filename The name of the file to parse. - * @param allow_exceptions Whether or not you want an exception for parsing errors. - * @author Peter Jones - **/ - //#################################################################### - tree_reader (const char *filename, bool allow_exceptions=true); - - //#################################################################### - /** - * xml::tree_reader class constructor. Given some data and the size of - * that data, parse that data as XML. To see if the data was parsed - * successfully use operator!. - * - * @param data The XML data to parse. - * @param size The size of the XML data to parse. - * @param allow_exceptions Whether or not you want an exception for parsing errors. - * @author Peter Jones - **/ - //#################################################################### - tree_reader (const char *data, size_type size, bool allow_exceptions=true); - - //#################################################################### - /** - * xml::tree_reader class destructor. - * - * @author Peter Jones - **/ - //#################################################################### - ~tree_reader (void); - - //#################################################################### - /** - * Check to see if a xml::tree_reader class is vaild. That is, check to - * see if parsing XML data was successful and the tree_reader holds a - * good XML node tree. - * - * @return True if the tree_reader is NOT VAILD; false if it is vaild. - * @author Peter Jones - **/ - //#################################################################### - bool operator! (void) const; - - //#################################################################### - /** - * If operator! indicates that there was an error parsing your XML data, - * you can use this member function to get the error message that was - * generated durring parsing. - * - * @return The error message generated durring XML parsing. - * @author Peter Jones - **/ - //#################################################################### - const std::string& get_error_message (void) const; - - //#################################################################### - /** - * Check to see if there were any warnings from the parser while - * processing the given XML data. If there were, you may want to send - * the same document through xmllint or the event_parser to catch and - * review the warning messages. - * - * @return True if there were any warnings. - * @return False if there were no warnings. - * @author Peter Jones - **/ - //#################################################################### - bool had_warnings (void) const; - - //#################################################################### - /** - * Get a reference to the xml::document that was generated during the - * XML parsing. You should make sure to only use a reference to the - * document to avoid a deep copy. - * - * @return A reference to the xml::document. - * @author Peter Jones - **/ - //#################################################################### - xml::document& get_document (void); - - //#################################################################### - /** - * Get a const reference to the xml::document that was generated during - * the XML parsing. You should make sure to only use a reference to the - * document to avoid a deep copy. - * - * @return A const reference to the xml::document. - * @author Peter Jones - **/ - //#################################################################### - const xml::document& get_document (void) const; - private: - tree_impl *pimpl_; // private implementation - - /* - * Don't allow anyone to copy construct a xml::tree_reader or allow the - * assignment operator to be called. It is not very useful to copy a - * parser that has already parsed half a document. - */ - tree_reader (const tree_reader&); - tree_reader& operator= (const tree_reader&); - }; // end xml::tree_reader class - -} // end xml namespace -#endif Deleted: trunk/src/libxml/text_reader.cxx =================================================================== --- trunk/src/libxml/text_reader.cxx 2008-11-16 01:30:21 UTC (rev 87) +++ trunk/src/libxml/text_reader.cxx 2008-11-16 01:32:26 UTC (rev 88) @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2005 Thomas M. Browder, Jr. - * <tbr...@us...> - * All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/** @file - * This file contains the implementation of the xml::tree_reader class for - * the libxml2 XML parser. -**/ - -// xmlwrapp includes -#include "xmlwrapp/tree_reader.h" -#include "xmlwrapp/document.h" -#include "utility.h" - -// libxml includes -#include <libxml/parser.h> -#include <libxml/parserInternals.h> -#include <libxml/SAX.h> -#include <libxml/xmlversion.h> - -// standard includes -#include <stdexcept> -#include <cstring> -#include <string> -#include <memory> - -//#################################################################### -namespace { - const char const_default_error[] = "unknown XML parsing error"; - - extern "C" void cb_tree_error (void *v, const char *message, ...); - extern "C" void cb_tree_warning (void *v, const char *, ...); - extern "C" void cb_tree_ignore (void*, const xmlChar*, int); -} -//#################################################################### -struct xml::tree_impl { - tree_impl (void) : last_error_(const_default_error), warnings_(false), okay_(false) { - std::memset(&sax_, 0, sizeof(sax_)); - initxmlDefaultSAXHandler(&sax_, 0); - - sax_.warning = cb_tree_warning; - sax_.error = cb_tree_error; - sax_.fatalError = cb_tree_error; - - if (xmlKeepBlanksDefaultValue == 0) sax_.ignorableWhitespace = cb_tree_ignore; - } - - document doc_; - xmlSAXHandler sax_; - std::string last_error_; - bool warnings_; - bool okay_; -}; - -//#################################################################### -xml::tree_reader::tree_reader (const char *name, bool allow_exceptions) { - std::auto_ptr<tree_impl> ap(pimpl_ = new tree_impl); - - xmlDocPtr tmpdoc = xmlSAXParseFileWithData(&(pimpl_->sax_), name, 0, pimpl_); - if (allow_exceptions && !tmpdoc) throw std::runtime_error(pimpl_->last_error_); - - if (tmpdoc) { - pimpl_->doc_.set_doc_data(tmpdoc); - pimpl_->okay_ = true; - } - - ap.release(); -} -//#################################################################### -xml::tree_reader::tree_reader (const char *data, size_type size, bool allow_exceptions) { - std::auto_ptr<tree_impl> ap(pimpl_ = new tree_impl); - xmlParserCtxtPtr ctxt; - - if ( (ctxt = xmlCreateMemoryParserCtxt(data, size)) == 0) { - throw std::bad_alloc(); - } - - if (ctxt->sax) xmlFree(ctxt->sax); - ctxt->sax = &(pimpl_->sax_); - - ctxt->_private = pimpl_; - - xmlParseDocument(ctxt); - - if (!ctxt->wellFormed) { - xmlFreeDoc(ctxt->myDoc); - ctxt->myDoc = 0; - ctxt->sax = 0; - xmlFreeParserCtxt(ctxt); - - if (allow_exceptions) throw std::runtime_error(pimpl_->last_error_); - ap.release(); return; // handle non-exception case - } - - pimpl_->doc_.set_doc_data(ctxt->myDoc); - pimpl_->okay_ = true; - ctxt->sax = 0; - - xmlFreeParserCtxt(ctxt); - ap.release(); -} - -//#################################################################### -xml::tree_reader::~tree_reader (void) { - delete pimpl_; -} - -//#################################################################### -bool xml::tree_reader::operator! (void) const { - return !pimpl_->okay_; -} - -//#################################################################### -const std::string& xml::tree_reader::get_error_message (void) const { - return pimpl_->last_error_; -} - -//#################################################################### -bool xml::tree_reader::had_warnings (void) const { - return pimpl_->warnings_; -} - -//#################################################################### -xml::document& xml::tree_reader::get_document (void) { - return pimpl_->doc_; -} - -//#################################################################### -const xml::document& xml::tree_reader::get_document (void) const { - return pimpl_->doc_; -} - -//#################################################################### -namespace { - //#################################################################### - extern "C" void cb_tree_error (void *v, const char *message, ...) { - try { - - xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(v); - xml::tree_impl *p = static_cast<xml::tree_impl*>(ctxt->_private); - if (!p) return; // handle bug in older versions of libxml - - va_list ap; - va_start(ap, message); - xml::printf2string(p->last_error_, message, ap); - va_end(ap); - - xmlStopParser(ctxt); - } catch (...) { } - } - //#################################################################### - extern "C" void cb_tree_warning (void *v, const char *, ...) { - try { - - xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(v); - xml::tree_impl *p = static_cast<xml::tree_impl*>(ctxt->_private); - if (!p) return; // handle bug in older versions of libxml - - p->warnings_ = true; - - } catch (...) { } - } - //#################################################################### - extern "C" void cb_tree_ignore (void*, const xmlChar*, int) { - return; - } - //#################################################################### -} -//#################################################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-11-24 02:37:52
|
Revision: 97 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=97&view=rev Author: vaclavslavik Date: 2008-11-24 02:37:42 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Fixed libxmlwrapp to not depend on libxslt if XSLT support is enabled (patch #1927398 by Vadim Zeitlin) Modified Paths: -------------- trunk/AUTHORS trunk/ChangeLog trunk/include/xmlwrapp/document.h trunk/src/libxml/document.cxx trunk/src/libxslt/stylesheet.cxx Added Paths: ----------- trunk/src/libxslt/result.h Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2008-11-24 02:27:10 UTC (rev 96) +++ trunk/AUTHORS 2008-11-24 02:37:42 UTC (rev 97) @@ -7,6 +7,7 @@ Tom Browder <tbr...@us...> Other contributors: + Vadim Zeitlin <va...@tt...> Tiziano Mueller <ti...@us...> Greg Chicares <gch...@sb...> Daniel Evison Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-11-24 02:27:10 UTC (rev 96) +++ trunk/ChangeLog 2008-11-24 02:37:42 UTC (rev 97) @@ -1,3 +1,8 @@ +Version 0.6.0 + + Fixed libxmlwrapp to not depend on libxslt if XSLT support + is enabled (Vadim Zeitlin, #1927398). + Version 0.5.1 Various compilation fixes. Modified: trunk/include/xmlwrapp/document.h =================================================================== --- trunk/include/xmlwrapp/document.h 2008-11-24 02:27:10 UTC (rev 96) +++ trunk/include/xmlwrapp/document.h 2008-11-24 02:37:42 UTC (rev 97) @@ -46,7 +46,10 @@ #include <cstddef> // forward declaration -namespace xslt { class stylesheet; } +namespace xslt { + class result; + class stylesheet; +} // end xslt namespace namespace xml { @@ -532,7 +535,7 @@ private: doc_impl *pimpl_; void set_doc_data (void *data); - void set_doc_data_from_xslt (void *data, void *ss); + void set_doc_data_from_xslt (void *data, xslt::result *xr); void* get_doc_data (void); void* release_doc_data (void); Modified: trunk/src/libxml/document.cxx =================================================================== --- trunk/src/libxml/document.cxx 2008-11-24 02:27:10 UTC (rev 96) +++ trunk/src/libxml/document.cxx 2008-11-24 02:37:42 UTC (rev 97) @@ -58,13 +58,8 @@ #include <libxml/tree.h> #include <libxml/xinclude.h> -// bring in libxslt stuff if we need it. -#if defined(XMLWRAPP_WITH_XSLT) -# include <libxslt/xslt.h> -# include <libxslt/xsltInternals.h> -# include <libxslt/transform.h> -# include <libxslt/xsltutils.h> -#endif +// bring in private libxslt stuff (see bug #1927398) +#include "../libxslt/result.h" //#################################################################### namespace { @@ -73,19 +68,19 @@ //#################################################################### struct xml::doc_impl { //#################################################################### - doc_impl (void) : doc_(0), from_xslt_(0) { + doc_impl (void) : doc_(0), xslt_result_(0) { xmlDocPtr tmpdoc; if ( (tmpdoc = xmlNewDoc(0)) == 0) throw std::bad_alloc(); set_doc_data(tmpdoc, true); } //#################################################################### - doc_impl (const char *root_name) : doc_(0), from_xslt_(0), root_(root_name) { + doc_impl (const char *root_name) : doc_(0), xslt_result_(0), root_(root_name) { xmlDocPtr tmpdoc; if ( (tmpdoc = xmlNewDoc(0)) == 0) throw std::bad_alloc(); set_doc_data(tmpdoc, true); } //#################################################################### - doc_impl (const doc_impl &other) : doc_(0), from_xslt_(0) { + doc_impl (const doc_impl &other) : doc_(0), xslt_result_(0) { xmlDocPtr tmpdoc; if ( (tmpdoc = xmlCopyDoc(other.doc_, 1)) == 0) throw std::bad_alloc(); set_doc_data(tmpdoc, false); @@ -123,16 +118,17 @@ root_.set_node_data(new_root_node); if (old_root_node) xmlFreeNode(old_root_node); - from_xslt_ = 0; + xslt_result_ = 0; } //#################################################################### ~doc_impl (void) { if (doc_) xmlFreeDoc(doc_); + delete xslt_result_; } //#################################################################### xmlDocPtr doc_; - void *from_xslt_; + xslt::result *xslt_result_; node root_; std::string version_; mutable std::string encoding_; @@ -303,18 +299,11 @@ xmlChar *xml_string; int xml_string_length; -#if defined(XMLWRAPP_WITH_XSLT) - if (pimpl_->from_xslt_ != 0) { - if (xsltSaveResultToString(&xml_string, &xml_string_length, pimpl_->doc_, - static_cast<xsltStylesheetPtr>(pimpl_->from_xslt_)) >= 0) - { - xmlchar_helper helper(xml_string); - if (xml_string_length) s.assign(helper.get(), xml_string_length); - } + if (pimpl_->xslt_result_ != 0) { + pimpl_->xslt_result_->save_to_string(s); return; } -#endif const char *enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str(); xmlDocDumpFormatMemoryEnc(pimpl_->doc_, &xml_string, &xml_string_length, enc, 1); @@ -326,14 +315,12 @@ bool xml::document::save_to_file (const char *filename, int compression_level) const { std::swap(pimpl_->doc_->compression, compression_level); -#if defined(XMLWRAPP_WITH_XSLT) - if (pimpl_->from_xslt_ != 0) { - bool rc = xsltSaveResultToFilename(filename, pimpl_->doc_, static_cast<xsltStylesheetPtr>(pimpl_->from_xslt_), 0) >= 0; + if (pimpl_->xslt_result_ != 0) { + bool rc = pimpl_->xslt_result_->save_to_file(filename, compression_level); std::swap(pimpl_->doc_->compression, compression_level); return rc; } -#endif const char *enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str(); bool rc = xmlSaveFormatFileEnc(filename, pimpl_->doc_, enc, 1) > 0; @@ -345,13 +332,13 @@ void xml::document::set_doc_data (void *data) { // we own the doc now, don't free it! pimpl_->set_doc_data(static_cast<xmlDocPtr>(data), false); - pimpl_->from_xslt_ = 0; + pimpl_->xslt_result_ = 0; } //#################################################################### -void xml::document::set_doc_data_from_xslt (void *data, void *ss) { +void xml::document::set_doc_data_from_xslt (void *data, xslt::result *xr) { // this document came from a XSLT transformation pimpl_->set_doc_data(static_cast<xmlDocPtr>(data), false); - pimpl_->from_xslt_ = ss; + pimpl_->xslt_result_ = xr; } //#################################################################### void* xml::document::get_doc_data (void) { Added: trunk/src/libxslt/result.h =================================================================== --- trunk/src/libxslt/result.h (rev 0) +++ trunk/src/libxslt/result.h 2008-11-24 02:37:42 UTC (rev 97) @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2008 Vadim Zeitlin (va...@ze...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/** @file + * This file contains the declaration of the xslt::result class. +**/ + +#ifndef _xsltwrapp_result_h_ +#define _xsltwrapp_result_h_ + +// standard includes +#include <string> + +// forward declarations +typedef struct _xmlDoc *xmlDocPtr; + +namespace xslt { + +/** + * The xslt::result class is used as a callback by xml::document to allow + * special treatment of XML documents which were created by XSLT. + * + * This class is only meant to be used internally by the library and is + * necessary to avoid the dependency of xml::document, which is part of + * libxmlwrapp, on libxslt which should be only a dependency of libxsltwrapp + * as this precludes calling the XSLT functions which must be used with such + * "result" documents directly from xml::document code. + * + * @author Vadim Zeitlin + * @internal +**/ +class result { +public: + //#################################################################### + /** + * Save the contents of the given XML document in the provided string. + * + * @param s The string to place the XML text data. + **/ + //#################################################################### + virtual void save_to_string(std::string &s) const = 0; + + //#################################################################### + /** + * Save the contents of the given XML document in the provided filename. + * + * @param filename The name of the file to place the XML text data into. + * @param compression_level 0 is no compression, 1-9 allowed, where 1 is for better speed, and 9 is for smaller size + * @return True if the data was saved successfully. + * @return False otherwise. + **/ + //#################################################################### + virtual bool save_to_file (const char *filename, + int compression_level) const = 0; + + //#################################################################### + /** + * Trivial but virtual base class destructor. + **/ + //#################################################################### + virtual ~result (void) { } +}; + +} // end xslt namespace + +#endif Property changes on: trunk/src/libxslt/result.h ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: trunk/src/libxslt/stylesheet.cxx =================================================================== --- trunk/src/libxslt/stylesheet.cxx 2008-11-24 02:27:10 UTC (rev 96) +++ trunk/src/libxslt/stylesheet.cxx 2008-11-24 02:37:42 UTC (rev 97) @@ -39,6 +39,9 @@ #include "xmlwrapp/document.h" #include "xmlwrapp/tree_parser.h" +#include "result.h" +#include "../libxml/utility.h" + // libxslt includes #include <libxslt/xslt.h> #include <libxslt/xsltInternals.h> @@ -52,6 +55,42 @@ #include <vector> #include <map> +namespace { + +// implementation of xslt::result using xslt::stylesheet: we pass this object +// to xml::document for the documents obtained via XSLT so that some operations +// (currently only saving) could be done differently for them +class result_impl : public xslt::result { +public: + // We don't own the pointers given to us, their lifetime must be greater + // than the lifetime of this object. + result_impl(xmlDocPtr doc, xsltStylesheetPtr ss) : doc_(doc), ss_(ss) { } + + virtual void save_to_string(std::string &s) const + { + xmlChar *xml_string; + int xml_string_length; + + if (xsltSaveResultToString(&xml_string, &xml_string_length, doc_, ss_) >= 0) + { + xml::xmlchar_helper helper(xml_string); + if (xml_string_length) s.assign(helper.get(), xml_string_length); + } + } + + virtual bool + save_to_file (const char *filename, int /* compression_level */) const + { + return xsltSaveResultToFilename(filename, doc_, ss_, 0) >= 0; + } + +private: + xmlDocPtr doc_; + xsltStylesheetPtr ss_; +}; + +} // end of anonymous namespace + //#################################################################### namespace { void make_vector_param (std::vector<const char*> &v, const xslt::stylesheet::param_type &p); @@ -114,7 +153,7 @@ xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); if (xmldoc) { - result.set_doc_data_from_xslt(xmldoc, pimpl_->ss_); + result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return true; } @@ -126,7 +165,7 @@ xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); if (xmldoc) { - result.set_doc_data_from_xslt(xmldoc, pimpl_->ss_); + result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return true; } @@ -142,7 +181,7 @@ throw std::runtime_error(pimpl_->error_); } - pimpl_->doc_.set_doc_data_from_xslt(xmldoc, pimpl_->ss_); + pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; } //#################################################################### @@ -155,7 +194,7 @@ throw std::runtime_error(pimpl_->error_); } - pimpl_->doc_.set_doc_data_from_xslt(xmldoc, pimpl_->ss_); + pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; } //#################################################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-11-25 15:50:57
|
Revision: 98 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=98&view=rev Author: vaclavslavik Date: 2008-11-25 15:50:51 +0000 (Tue, 25 Nov 2008) Log Message: ----------- ported Unix build system to Autotools Modified Paths: -------------- trunk/ChangeLog trunk/src/libxml/document.cxx Added Paths: ----------- trunk/Makefile.am trunk/admin/ trunk/bootstrap trunk/configure.ac trunk/examples/01-tree_parsing/Makefile.am trunk/examples/02-event_parsing/Makefile.am trunk/examples/03-xml_generation/Makefile.am trunk/examples/04-xslt/Makefile.am trunk/examples/Makefile.am trunk/include/Makefile.am trunk/src/Makefile.am trunk/tests/Makefile.am trunk/tests/attributes/Makefile.am trunk/tests/document/Makefile.am trunk/tests/event/Makefile.am trunk/tests/node/Makefile.am trunk/tests/tree/Makefile.am trunk/tests/xslt/Makefile.am trunk/xmlwrapp-config.in trunk/xmlwrapp.pc.in Removed Paths: ------------- trunk/configure.pl trunk/tools/cxxflags trunk/tools/genconfig trunk/tools/mkmf Property Changed: ---------------- trunk/ trunk/examples/ trunk/examples/01-tree_parsing/ trunk/examples/02-event_parsing/ trunk/examples/03-xml_generation/ trunk/examples/04-xslt/ trunk/include/ trunk/src/ trunk/tests/ trunk/tests/attributes/ trunk/tests/document/ trunk/tests/event/ trunk/tests/node/ trunk/tests/tree/ trunk/tests/xslt/ Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore - Makefile README.xmlwrapp_sourceforge *.pdf *.ps xmlwrapp-config xmlwrapp.pc docbookmk-0.0.11.tar.gz download t t.pdf t.ps t.txt packxmlwrapp.pl xmlwrapp.carry xmlwrapp_exclude.pm tmp + Makefile Makefile.in xmlwrapp-config xmlwrapp.pc config.log config.status stamp-h1 libtool Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-11-24 02:37:42 UTC (rev 97) +++ trunk/ChangeLog 2008-11-25 15:50:51 UTC (rev 98) @@ -3,6 +3,8 @@ Fixed libxmlwrapp to not depend on libxslt if XSLT support is enabled (Vadim Zeitlin, #1927398). + Ported Unix build system to Autotools. + Version 0.5.1 Various compilation fixes. Added: trunk/Makefile.am =================================================================== --- trunk/Makefile.am (rev 0) +++ trunk/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,7 @@ + +SUBDIRS = include src examples tests + +pkgconfigdir=$(libdir)/pkgconfig +pkgconfig_DATA = xmlwrapp.pc + +bin_SCRIPTS = xmlwrapp-config Property changes on: trunk/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/admin ___________________________________________________________________ Added: svn:ignore + depcomp missing config.guess ltmain.sh config.sub install-sh Added: trunk/bootstrap =================================================================== --- trunk/bootstrap (rev 0) +++ trunk/bootstrap 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,60 @@ +#!/bin/sh + +# Script to execute to initialize xmlwrapp build system after checking out +# pristine sources from a version control system: this script creates all +# generated files which are needed for the build but not stored under version +# control. + +# Copyright (C) 2005, 2006, 2007, 2008 Vadim Zeitlin +# All Rights Reserved +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of the Author nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +# $Id$ + +if [ ! -f configure.ac -o ! -f Makefile.am -o ! -f xmlwrapp.pc.in ]; then + echo "Please run this script from the xmlwrapp source directory." + exit 2 +fi + +# use --foreign with automake because we lack standard GNU NEWS and AUTHOR +# files, if they're added we can "upgrade" to (default) GNU strictness. Use +# --copy to allow simultaneous use on windows under mingw and cygwin platforms. +# Symlinking of files under mingw does not work out for cygwin and vice-versa. +echo "Setting up build system for xmlwrapp:" +echo " - aclocal " && aclocal ${wx+-I} $wx && \ +echo " - libtoolize " && libtoolize --copy --automake && \ +echo " - autoconf " && autoconf && \ +echo " - autoheader " && autoheader && \ +echo " - automake " && automake --add-missing --copy --foreign && \ +echo "Build setup successful, type \"configure\" to configure xmlwrapp now." && \ +exit 0 + +echo "Automatic build files setup failed!" + +exit 1 Property changes on: trunk/bootstrap ___________________________________________________________________ Added: svn:executable + * Added: trunk/configure.ac =================================================================== --- trunk/configure.ac (rev 0) +++ trunk/configure.ac 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,125 @@ +dnl configure.ac script for xmlwrapp, process with autoconf to create configure +dnl +dnl Copyright (C) 2008 Vaclav Slavik <vs...@fa...>, +dnl 2008 Vadim Zeitlin <va...@tt...> +dnl All Rights Reserved +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that the following conditions +dnl are met: +dnl +dnl 1. Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl 2. Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in +dnl the documentation and/or other materials provided with the +dnl distribution. +dnl 3. Neither the name of the Author nor the names of its contributors +dnl may be used to endorse or promote products derived from this software +dnl without specific prior written permission. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' +dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +dnl USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +dnl AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +dnl OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +dnl SUCH DAMAGE. + +dnl === Prologue === + +AC_REVISION($Id$)dnl + +AC_PREREQ(2.56) +AC_INIT(xmlwrapp, 0.6.0, [xml...@li...]) + +AC_CONFIG_SRCDIR([xmlwrapp.pc.in]) +AC_CONFIG_AUX_DIR([admin]) + +AM_INIT_AUTOMAKE +AM_MAINTAINER_MODE + +dnl remember, "build" is where we compile, "host" is where the resulting +dnl program runs (which may be different from "build" for cross-compilation) +AC_CANONICAL_HOST + + +dnl === Command line options === + +AC_ARG_ENABLE(xslt, + [AC_HELP_STRING([--disable-xslt], + [don't build libxsltwrapp library])], + [case "x${enableval}" in + x) build_xslt=no ;; + xyes) build_xslt=yes ;; + xno) build_xslt=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-xslt) ;; + esac], + [build_xslt=yes]) + + +dnl === Program checks === + +AC_PROG_CXX +AC_PROG_LD +AC_PROG_LIBTOOL + + +dnl === Library checks === + +dnl use C++ compiler as we're checking for C++ libraries/headers from now on +dnl (we couldn't do it before as libtool tests must be done with C compiler) +AC_LANG(C++) + +PKG_CHECK_MODULES(LIBXML, [libxml-2.0 >= 2.4.28]) + +if test "x$build_xslt" = "xyes" ; then + PKG_CHECK_MODULES(LIBXSLT, [libxslt >= 1.0.23]) + PKG_CHECK_MODULES(LIBEXSLT, [libexslt]) +fi + + +dnl === Compiler-specific stuff === + +if test "x$GCC" == "xyes"; then + dnl Enable some useful warnings that GCC supports: + CXXFLAGS="$CXXFLAGS -W -Wall -Wcast-align -Wwrite-strings" +fi + + +dnl === Generate output files === + +XMLWRAPP_LINK_FLAGS="-lxmlwrapp $LIBXML_LIBS" +if test "x$build_xslt" = "xyes" ; then + XMLWRAPP_LINK_FLAGS="-lxsltwrapp $LIBEXSLT_LIBS $LIBXSLT_LIBS $XMLWRAPP_LINK_FLAGS" +fi + +AM_CONDITIONAL(WITH_XSLT, [ test "x$build_xslt" = "xyes" ]) + +AC_SUBST(XMLWRAPP_LINK_FLAGS) + +AC_CONFIG_FILES([ + xmlwrapp.pc + xmlwrapp-config + Makefile + include/Makefile + src/Makefile + examples/Makefile + examples/01-tree_parsing/Makefile + examples/02-event_parsing/Makefile + examples/03-xml_generation/Makefile + examples/04-xslt/Makefile + tests/Makefile + tests/attributes/Makefile + tests/document/Makefile + tests/event/Makefile + tests/node/Makefile + tests/tree/Makefile + tests/xslt/Makefile +]) +AC_OUTPUT Deleted: trunk/configure.pl =================================================================== --- trunk/configure.pl 2008-11-24 02:37:42 UTC (rev 97) +++ trunk/configure.pl 2008-11-25 15:50:51 UTC (rev 98) @@ -1,600 +0,0 @@ -#! /usr/bin/perl -###################################################################### -# Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) -# All Rights Reserved -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name of the Author nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR -# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -################################################################################ -# -# configure.pl (bootstrap xmlwrapp) -# Peter J Jones (pj...@pm...) -# -################################################################################ -# -# Includes -# -################################################################################ -use strict; -use Getopt::Long; -use Cwd qw(cwd chdir); -################################################################################ -# -# Constants -# -################################################################################ -use constant DATE => 'Tue Jan 15 08:56:06 2002'; -use constant ID => '$Id: configure.pl,v 1.6 2005-11-15 21:30:43 tbrowder2 Exp $'; -################################################################################ -# -# Global Variables -# -################################################################################ -$Getopt::Long::bundling = 1; - -my $cwd = cwd(); -my %clo; -my $dirsep = "/"; - -my $mkmf = "${cwd}${dirsep}tools${dirsep}mkmf"; -my $cxxflags = "${cwd}${dirsep}tools${dirsep}cxxflags"; -my $genconfig = "${cwd}${dirsep}tools${dirsep}genconfig"; -my $master_inc = "${cwd}${dirsep}include"; - -my $mkmf_flags; -my $libname = "xmlwrapp"; -my $install_spec= "docs${dirsep}install.spec"; -my $src_sub_dir = 'libxml'; -my @test_dirs = qw(tree event node document attributes); -my $xmlwrapp_ver; -my $xmlwrapp_mjr; - -my $xslt_libname = "xsltwrapp"; -my $xslt_sub_dir = 'libxslt'; -my $xsltwrapp_okay = 0; -my $xsltwrapp_mjr; - -my $have_pkg_config = 0; -my @external_libs; -my @external_incs; -################################################################################ -# -# Code Start -# -################################################################################ -$|++; - -if (not defined $ENV{'CXX'}) { - print STDERR "**** Your CXX environment variable is not set. ****\n"; - print STDERR "**** xmlwrapp needs this variable to find your C++ compiler. ****\n"; - exit; -} - -GetOptions( - \%clo, - - 'help|h', - - 'developer|d', - 'contrib', - - 'xml2-config=s', - 'xslt-config=s', - - 'disable-shared', - 'disable-examples', - 'enable-tests|t', - 'disable-xslt', - - 'prefix=s', - 'bindir=s', - 'libdir=s', - 'incdir=s', -) or usage(); -$clo{'help'} && usage(); - -sub usage { - print "Usage: $0 [options]\n", <<EOT; - -h, --help This message - --developer Turn on features for a xmlwrapp developer - --contrib Configure for being bundled inside another project - --disable-shared Don't build a shared library - --disable-examples Don't build the example programs - --enable-tests Enable the building of test programs - - --xml2-config file Run file to get info about libxml2 [xml2-config] - - --prefix path Set install prefix to path [/usr/local] - --bindir path Set bin install location to path [PREFIX/bin] - --libdir path Set lib install location to path [PREFIX/lib] - --incdir path Set include install location to path [PREFIX/include] -EOT - exit 1; -} - -# set some defaults -$clo{'prefix'} ||= "/usr/local"; -$clo{'bindir'} ||= "$clo{'prefix'}${dirsep}bin"; -$clo{'libdir'} ||= "$clo{'prefix'}${dirsep}lib"; -$clo{'incdir'} ||= "$clo{'prefix'}${dirsep}include"; -$clo{'disable-shared'} = 1 if $clo{'contrib'}; - -if ($clo{'contrib'}) { - $clo{'disable-shared'} = 1; - $clo{'disable-examples'} = 1; -} - -# setup defaults for mkmf -$mkmf_flags = "--include $master_inc --cxxflags $cxxflags --quiet "; -if ($clo{'developer'}) {$mkmf_flags .= " --developer";} - -# look for libxml2 -if ($clo{'disable-xslt'} or check_libxslt() != 1) { - check_libxml2(); -} - -# find out the current version -parse_version_file(); - -# generate the config script -generate_config_script(); - -# generate the xmlwrapp_config.h header -generate_config_header(); - -# start generating makefiles -generate_top_makefile(); -generate_test_makefiles(); -generate_example_makefiles(); -generate_src_makefiles(); - -if (!$clo{'contrib'}) { - print "+---------------------------------------------------------------+\n"; - print "| Join the users mailing list for help with xmlwrapp. |\n"; - print "| Visit 'http://sourceforge.net/projects/xmlwrapp'. |\n"; - print "| Click on 'Lists'. |\n"; - print "+---------------------------------------------------------------+\n"; -} -################################################################################ -sub parse_version_file { - unless (open(VERSION, "docs${dirsep}VERSION")) { - print STDERR "$0: can't open VERSION file 'docs${dirsep}VERSION': $!\n"; - exit 1; - } - - my $first_line = <VERSION>; - close VERSION; - - ($xmlwrapp_ver, $xmlwrapp_mjr, $xsltwrapp_mjr, undef) = split(/\s+/, $first_line, 4); -} -################################################################################ -sub check_libxslt { - my $output; - - print "Checking for libxslt version ... "; - $clo{'xslt-config'} ||= 'xslt-config'; - chomp($output = `$clo{'xslt-config'} --version 2>&1`); - - if ($? != 0 or not defined $output or not length($output)) { - print "no\n"; - return 0; - } - - if ($output =~ /^(\d+\.\d+)\.(\d+)$/) { - if (($1 > 1.0) or ($1 == 1.0 and $2 >= 23)) { - print "$output >= 1.0.23\n"; - } else { - print "$output < 1.0.23\n"; - print STDERR "**** your version of libxslt is too old.\n"; - print STDERR "**** you can configure with --disable-xslt to drop XSLT support.\n"; - exit 1; - } - } else { - print "xmlwrapp bug\n"; - print STDERR "**** I can't parse the version string, this is a bug!\n"; - exit 1; - } - - load_flags_from_xml_config("xslt"); - $xsltwrapp_okay = 1; - push(@test_dirs, "xslt"); - - return 1; -} -################################################################################ -sub check_libxml2 { - my $output; - - print "Checking for libxml2 version ... "; - $clo{'xml2-config'} ||= 'xml2-config'; - chomp($output = `$clo{'xml2-config'} --version 2>&1`); - - unless ($output) { - print "[fail]\n"; - print STDERR "**** can't find xml2-config, try using --xml2-config\n"; - exit 1; - } - - if ($output =~ /^(\d+\.\d+)\.(\d+)$/) { - if (($1 >= 2.5) || $1 == 2.4 && $2 >= 28) { - print "$output >= 2.4.28\n"; - } else { - print "$output < 2.4.28\n"; - print STDERR "**** your version of libxml2 is too old, please upgrade\n"; - exit 1; - } - } else { - print "what is that?\n"; - print STDERR "**** I can't seem to parse the libxml2 version, please submit a bug\n"; - exit 1; - } - - load_flags_from_xml_config("xml2"); -} -################################################################################ -sub load_flags_from_xml_config { - my $xmllib = shift; - my $config = "$xmllib-config"; - my $output; - - print "Finding XML '$xmllib' include directory ... "; - chomp($output = `$clo{$config} --cflags 2>&1`); - - if ($xmllib eq 'xslt' && 1) { - # hack - $output = $output . ' -I/usr/local/include/libxml2'; - if (0) { - my $cmd = $clo{$config}; - print "DEBUG: cmd = '$cmd'...\n"; - print "DEBUG: xml2 flags = '$output'...\n"; - exit; - } - } - if ($? != 0 or not defined $output or not length($output)) { - print "fail\n"; - print "**** error running $clo{$config} --cflags, sorry\n"; - exit 1; - } - - $output =~ s/-I//g; - my @include_dirs = split(/\s+/, $output); - my $main_include_dir = undef; - my $xslt_include_dir = undef; - - # add a few standard directories just in case - push(@include_dirs, '/usr/include'); - - foreach my $dir (@include_dirs) { - if (-d "$dir${dirsep}libxml" and not defined $main_include_dir) { - $main_include_dir = $dir; - } - - if (-e "$dir${dirsep}libxslt${dirsep}transform.h" and not defined $xslt_include_dir) { - $xslt_include_dir = $dir; - } - - if (-e "$dir${dirsep}giconv.h") { - push(@external_incs, $dir); - } - - if (-e "$dir${dirsep}iconv.h") { - push(@external_incs, $dir); - } - } - - if ($xmllib eq 'xslt' and not defined $xslt_include_dir) { - print STDERR "**** can't find include dir for libxslt, what does $clo{'$xmllib-config'} --cflags say?\n"; - exit 1; - } - elsif($xmllib eq 'xslt') { - push(@external_incs, $xslt_include_dir); - } - - if (not defined $main_include_dir) { - print "fail\n"; - print STDERR "**** can't find include dir for libxml2, what does $clo{'$xmllib-config'} --cflags say?\n"; - exit 1; - } - else { - print "$main_include_dir\n"; - push(@external_incs, $main_include_dir); - } - - print "Finding XML libraries ... "; - chomp($output = `$clo{$config} --libs 2>&1`); - - if ($? != 0 or not defined $output or not length($output)) { - print "fail\n"; - print "**** error running $clo{$config} --libs, sorry\n"; - exit 1; - } - else { - print "done\n"; - } - - $output =~ s/^\s+//; $output =~ s/\s+$//; - my $last_L; - - if ($xmllib eq 'xslt' and $output !~ /-lexslt/) { - $output =~ s/-lxslt/-lxslt -lexslt/; - } - - while ($output =~ /-([Ll])(\S+)/cg) { - if ($1 eq 'L') { - $last_L = $2; - next; - } - - if ($last_L) { - push(@external_libs, [$last_L, $2]); - } else { - push(@external_libs, $2); - } - } -} -################################################################################ -sub generate_top_makefile { - my $extra_dirs = "tests" if $clo{'enable-tests'}; - $extra_dirs .= " examples" if not $clo{'disable-examples'}; - - my $extra_flags = ''; - $extra_flags .= ' --with-test tests' if $clo{'enable-tests'}; - - unless (open(SPEC, ">$install_spec")) { - print STDERR "\n$0: can't open $install_spec: $!\n"; - exit 1; - } - - # set some install paths - print SPEC "bindir=$clo{'bindir'}\n"; - print SPEC "libdir=$clo{'libdir'}\n"; - print SPEC "includedir=$clo{'incdir'}\n"; - - # add files - print SPEC "binary $libname-config\n"; - print SPEC "pkgconfig $libname.pc\n" if $have_pkg_config == 1; - print SPEC "include-dir include/$libname $libname\n"; - print SPEC "static-lib src/$src_sub_dir $libname\n"; - print SPEC "shared-lib src/$src_sub_dir $libname $xmlwrapp_mjr\n" unless $clo{'disable-shared'}; - - if ($xsltwrapp_okay == 1) { - print SPEC "include-dir include/$xslt_libname $xslt_libname\n"; - print SPEC "static-lib src/$xslt_sub_dir $xslt_libname\n"; - print SPEC "shared-lib src/$xslt_sub_dir $xslt_libname $xsltwrapp_mjr\n" unless $clo{'disable-shared'}; - } - - close SPEC; - - print "Creating Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --install $install_spec $extra_flags --wrapper src $extra_dirs"); - unlink($install_spec); -} -################################################################################ -sub generate_src_makefiles { - ## - # src/Makefile - if (! chdir("$cwd${dirsep}src")) { - print STDERR "\n**** hey, I can't cd into my src directory: $!\n"; - exit 1; - } - - my $src_dirs = "$src_sub_dir"; - $src_dirs .= " $xslt_sub_dir" if $xsltwrapp_okay == 1; - - print "Creating src/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --wrapper $src_dirs"); - chdir($cwd); - - ## - # src/libxml2/Makefile - if (! chdir("$cwd${dirsep}src${dirsep}$src_sub_dir")) { - print STDERR "\n**** hey, I can't cd into my src/$src_sub_dir directory: $!\n"; - exit 1; - } - - my $extra_flags = "--shared-lib $libname --major $xmlwrapp_mjr" unless $clo{'disable-shared'}; - foreach my $dir (@external_incs) { $extra_flags .= " --include $dir"; } - - print "Creating src/$src_sub_dir/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --static-lib $libname $extra_flags *.cxx"); - chdir($cwd); - - ## - # src/libxslt/Makefile - if (! chdir("$cwd${dirsep}src${dirsep}$xslt_sub_dir")) { - print STDERR "\n**** hey, I can't cd into my src/$xslt_sub_dir directory: $!\n"; - exit 1; - } - - my $extra_flags = "--shared-lib $xslt_libname --major $xsltwrapp_mjr" unless $clo{'disable-shared'}; - foreach my $dir (@external_incs) { $extra_flags .= " --include $dir"; } - - print "Creating src/$xslt_sub_dir/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --static-lib $xslt_libname $extra_flags *.cxx"); - chdir($cwd); -} -################################################################################ -sub generate_test_makefiles { - return unless $clo{'enable-tests'}; - - if (! chdir("$cwd${dirsep}tests")) { - print STDERR "\n$0: can't cd to tests: $!\n"; - exit 1; - } - - my $with_test = join(',', @test_dirs); - print "Creating tests/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --with-test '$with_test' --wrapper @test_dirs"); - chdir($cwd); - - # static link with xmlwrapp so that it does not need to be installed - my $extra_flags = ""; - $extra_flags .= "--slinkwith $cwd${dirsep}src/$xslt_sub_dir,$xslt_libname " if $xsltwrapp_okay == 1; - $extra_flags .= "--slinkwith $cwd${dirsep}src/$src_sub_dir,$libname "; - - # link with all external libs - foreach my $lib (@external_libs) { - if (ref $lib) { - $extra_flags .= " --linkwith $lib->[0],$lib->[1]"; - } else { - $extra_flags .= " --linkwith $lib"; - } - } - - $extra_flags .= " --test-cmds '$^X runtest.pl'"; - - foreach my $test (@test_dirs) { - if (! chdir("$cwd${dirsep}tests${dirsep}$test")) { - print STDERR "\n$0: can't cd to $cwd${dirsep}tests${dirsep}$test: $!\n"; - exit 1; - } - - print "Creating tests/$test/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --many-exec $extra_flags *.cxx"); - chdir($cwd); - } -} -################################################################################ -sub generate_example_makefiles { - return if $clo{'disable-examples'}; - - if (! chdir("$cwd${dirsep}examples")) { - print STDERR "\n$0: can't cd to examples: $!\n"; - exit 1; - } - - my @raw_example_dirs = grep {!/^(CVS|Makefile)$/} glob("*"); - my @example_dirs; - - foreach (@raw_example_dirs) { - if (/xslt/i and $xsltwrapp_okay != 1) { next; } - push(@example_dirs, $_); - } - - print "Creating examples/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --wrapper @example_dirs"); - chdir($cwd); - - # static link with xmlwrapp so that it does not need to be installed - my $extra_flags; - $extra_flags .= "--slinkwith $cwd${dirsep}src/$xslt_sub_dir,$xslt_libname " if $xsltwrapp_okay == 1; - $extra_flags .= "--slinkwith $cwd${dirsep}src${dirsep}$src_sub_dir,$libname "; - - # link with all external libs - foreach my $lib (@external_libs) { - if (ref $lib) { - $extra_flags .= " --linkwith $lib->[0],$lib->[1]"; - } else { - $extra_flags .= " --linkwith $lib"; - } - } - - foreach my $example (@example_dirs) { - if (! chdir("$cwd${dirsep}examples${dirsep}$example")) { - print STDERR "\n$0: can't cd to $cwd${dirsep}examples${dirsep}$example: $!\n"; - exit 1; - } - - print "Creating examples/$example/Makefile ...\n"; - system("$^X $mkmf $mkmf_flags --one-exec example $extra_flags *.cxx"); - chdir($cwd); - } -} -################################################################################ -sub generate_config_script { - my ($all_incs, $all_libs); - - if ($clo{'contrib'}) { - $all_incs = "-I$cwd${dirsep}include "; - $all_libs = ""; - - my @lib_names; - push(@lib_names, $xslt_libname) if $xsltwrapp_okay == 1; - push(@lib_names, $libname); - - foreach my $lib_name (@lib_names) { - my $full_libname = `$^X $cxxflags --static-lib-prefix`; - $full_libname =~ s/^\s+//; $full_libname =~ s/\s+$//; - $full_libname .= $lib_name; - $full_libname .= `$^X $cxxflags --static-lib-extension`; - $full_libname =~ s/^\s+//; $full_libname =~ s/\s+$//; - - my $subdir = $lib_name eq $xslt_libname ? $xslt_sub_dir : $src_sub_dir; - $all_libs .= "$cwd${dirsep}src${dirsep}$subdir${dirsep}$full_libname "; - } - } else { - $all_incs = "-I$clo{'incdir'} "; - $all_libs .= `$^X $cxxflags --linkwith $clo{'libdir'},$xslt_libname` if $xsltwrapp_okay == 1; - $all_libs .= `$^X $cxxflags --linkwith $clo{'libdir'},$libname`; - } - - # add external libraries - foreach my $lib (@external_libs) { - if (ref $lib) { - $all_libs .= `$^X $cxxflags --linkwith $lib->[0],$lib->[1]`; - } else { - $all_libs .= `$^X $cxxflags --linkwith $lib`; - } - } - - # clean and encode - foreach ($all_incs, $all_libs) { - s/^\s+//; s/\s+$//; s/\s+/ /g; s/-/^/g; - } - - my $command = "$^X $genconfig --version $xmlwrapp_ver --name $libname"; - $command .= " --libs \"$all_libs\" --cxxflags \"$all_incs\""; - $command .= " --desc 'A C++ wrapper around libxml2 and libxslt' "; - $command .= " -o $libname-config"; - - # check for pkg-config - if (system("pkg-config --version > /dev/null 2>&1") == 0 || system("$clo{'bindir'}/pkg-config --version > /dev/null 2>&1") == 0) { - $have_pkg_config = 1; - $command .= " --prefix='$clo{prefix}' --bindir='$clo{bindir}' --libdir='$clo{libdir}' --incdir='$clo{incdir}' --pkgconfig='$libname.pc'"; - } - - print "Creating xmlwrapp-config script ... \n"; - system("$command"); -} -################################################################################ -sub generate_config_header { - if (not open(CH, ">src${dirsep}xmlwrapp_config.h")) { - print STDERR "$0: error creating src/xmlwrapp_config.h: $!\n"; - exit 1; - } - - print CH "#ifndef _xmlwrapp_config_h_\n"; - print CH "#define _xmlwrapp_config_h_\n"; - - if ($xsltwrapp_okay == 1) { - print CH "#define XMLWRAPP_WITH_XSLT\n"; - } - - print CH "#endif\n"; - close CH; -} -################################################################################ Property changes on: trunk/examples ___________________________________________________________________ Modified: svn:ignore - Makefile + Makefile Makefile.in Property changes on: trunk/examples/01-tree_parsing ___________________________________________________________________ Modified: svn:ignore - Makefile example + example Makefile Makefile.in .deps .libs Added: trunk/examples/01-tree_parsing/Makefile.am =================================================================== --- trunk/examples/01-tree_parsing/Makefile.am (rev 0) +++ trunk/examples/01-tree_parsing/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,6 @@ + +noinst_PROGRAMS = example + +example_SOURCES = example.cxx +example_CPPFLAGS = -I$(top_srcdir)/include +example_LDADD = ../../src/libxmlwrapp.la Property changes on: trunk/examples/01-tree_parsing/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/examples/02-event_parsing ___________________________________________________________________ Modified: svn:ignore - Makefile example + example Makefile Makefile.in .deps .libs Added: trunk/examples/02-event_parsing/Makefile.am =================================================================== --- trunk/examples/02-event_parsing/Makefile.am (rev 0) +++ trunk/examples/02-event_parsing/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,6 @@ + +noinst_PROGRAMS = example + +example_SOURCES = example.cxx +example_CPPFLAGS = -I$(top_srcdir)/include +example_LDADD = ../../src/libxmlwrapp.la Property changes on: trunk/examples/02-event_parsing/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/examples/03-xml_generation ___________________________________________________________________ Modified: svn:ignore - Makefile example + example Makefile Makefile.in .deps .libs Added: trunk/examples/03-xml_generation/Makefile.am =================================================================== --- trunk/examples/03-xml_generation/Makefile.am (rev 0) +++ trunk/examples/03-xml_generation/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,6 @@ + +noinst_PROGRAMS = example + +example_SOURCES = example.cxx +example_CPPFLAGS = -I$(top_srcdir)/include +example_LDADD = ../../src/libxmlwrapp.la Property changes on: trunk/examples/03-xml_generation/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/examples/04-xslt ___________________________________________________________________ Modified: svn:ignore - Makefile example + example Makefile Makefile.in .deps .libs Added: trunk/examples/04-xslt/Makefile.am =================================================================== --- trunk/examples/04-xslt/Makefile.am (rev 0) +++ trunk/examples/04-xslt/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,10 @@ + +if WITH_XSLT + +noinst_PROGRAMS = example + +example_SOURCES = example.cxx +example_CPPFLAGS = -I$(top_srcdir)/include +example_LDADD = ../../src/libxsltwrapp.la ../../src/libxmlwrapp.la + +endif Property changes on: trunk/examples/04-xslt/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: trunk/examples/Makefile.am =================================================================== --- trunk/examples/Makefile.am (rev 0) +++ trunk/examples/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,6 @@ + +SUBDIRS = \ + 01-tree_parsing \ + 02-event_parsing \ + 03-xml_generation \ + 04-xslt Property changes on: trunk/examples/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/include ___________________________________________________________________ Added: svn:ignore + Makefile Makefile.in Added: trunk/include/Makefile.am =================================================================== --- trunk/include/Makefile.am (rev 0) +++ trunk/include/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,19 @@ + +xmlwrapp_includedir= $(includedir)/xmlwrapp +xmlwrapp_include_HEADERS = \ + xmlwrapp/attributes.h \ + xmlwrapp/_cbfo.h \ + xmlwrapp/document.h \ + xmlwrapp/event_parser.h \ + xmlwrapp/init.h \ + xmlwrapp/node.h \ + xmlwrapp/tree_parser.h \ + xmlwrapp/xmlwrapp.h + +if WITH_XSLT +xsltwrapp_includedir= $(includedir)/xsltwrapp +xsltwrapp_include_HEADERS = \ + xsltwrapp/init.h \ + xsltwrapp/stylesheet.h \ + xsltwrapp/xsltwrapp.h +endif Property changes on: trunk/include/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/src ___________________________________________________________________ Modified: svn:ignore - Makefile xmlwrapp_config.h + Makefile Makefile.in .libs .deps Added: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am (rev 0) +++ trunk/src/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,44 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include + +if WITH_XSLT +lib_LTLIBRARIES = libxmlwrapp.la libxsltwrapp.la +else +lib_LTLIBRARIES = libxmlwrapp.la +endif + +libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS) +libxmlwrapp_la_LIBADD = $(LIBXML_LIBS) +libxmlwrapp_la_LDFLAGS = -version-info 5:1:0 + +libxmlwrapp_la_SOURCES = \ + libxml/ait_impl.cxx \ + libxml/ait_impl.h \ + libxml/attributes.cxx \ + libxml/document.cxx \ + libxml/dtd_impl.cxx \ + libxml/dtd_impl.h \ + libxml/event_parser.cxx \ + libxml/init.cxx \ + libxml/node.cxx \ + libxml/node_iterator.cxx \ + libxml/node_iterator.h \ + libxml/node_manip.cxx \ + libxml/node_manip.h \ + libxml/tree_parser.cxx \ + libxml/utility.cxx \ + libxml/utility.h + + +if WITH_XSLT + +libxsltwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBEXSLT_CFLAGS) $(LIBXSLT_CFLAGS) +libxsltwrapp_la_LIBADD = libxmlwrapp.la $(LIBEXSLT_LIBS) $(LIBXSLT_LIBS) +libxsltwrapp_la_LDFLAGS = -version-info 2:1:0 + +libxsltwrapp_la_SOURCES = \ + libxslt/init.cxx \ + libxslt/result.h \ + libxslt/stylesheet.cxx + +endif Property changes on: trunk/src/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: trunk/src/libxml/document.cxx =================================================================== --- trunk/src/libxml/document.cxx 2008-11-24 02:37:42 UTC (rev 97) +++ trunk/src/libxml/document.cxx 2008-11-25 15:50:51 UTC (rev 98) @@ -41,11 +41,6 @@ #include "dtd_impl.h" #include "node_manip.h" -// configure.pl generated file -#ifndef WIN32 -# include "../xmlwrapp_config.h" -#endif - // standard includes #include <new> #include <memory> Property changes on: trunk/tests ___________________________________________________________________ Modified: svn:ignore - Makefile + Makefile Makefile.in Added: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am (rev 0) +++ trunk/tests/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,8 @@ + +SUBDIRS = \ + attributes \ + document \ + event \ + node \ + tree \ + xslt Property changes on: trunk/tests/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/attributes ___________________________________________________________________ Modified: svn:ignore - Makefile test_attr-01 test_attr-02 test_attr-03 test_attr-04 test_attr-05 test_attr-06 test_attr-07 test_attr-08 test_attr-09 test_attr-10 + Makefile Makefile.in .deps .libs test_attr-01 test_attr-02 test_attr-03 test_attr-04 test_attr-05 test_attr-06 test_attr-07 test_attr-08 test_attr-09 test_attr-10 Added: trunk/tests/attributes/Makefile.am =================================================================== --- trunk/tests/attributes/Makefile.am (rev 0) +++ trunk/tests/attributes/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,28 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_attr-01 \ + test_attr-02 \ + test_attr-03 \ + test_attr-04 \ + test_attr-05 \ + test_attr-06 \ + test_attr-07 \ + test_attr-08 \ + test_attr-09 \ + test_attr-10 + +test_attr_01_SOURCES = test_attr-01.cxx +test_attr_02_SOURCES = test_attr-02.cxx +test_attr_03_SOURCES = test_attr-03.cxx +test_attr_04_SOURCES = test_attr-04.cxx +test_attr_05_SOURCES = test_attr-05.cxx +test_attr_06_SOURCES = test_attr-06.cxx +test_attr_07_SOURCES = test_attr-07.cxx +test_attr_08_SOURCES = test_attr-08.cxx +test_attr_09_SOURCES = test_attr-09.cxx +test_attr_10_SOURCES = test_attr-10.cxx Property changes on: trunk/tests/attributes/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/document ___________________________________________________________________ Modified: svn:ignore - Makefile test_document-01 test_document-02 test_document-03 test_document-04 test_document-05 test_document-06 test_document-07 test_document-08 test_document-09 test_document-10 test_document-11 test_document-12 test_document-13 test_document-14 test_document-15 test_document-16 test_document-17 test_document-18 test_document-19 test_document-20 test_document-21 test_document-22 + Makefile Makefile.in .deps .libs test_document-01 test_document-02 test_document-03 test_document-04 test_document-05 test_document-06 test_document-07 test_document-08 test_document-09 test_document-10 test_document-11 test_document-12 test_document-13 test_document-14 test_document-15 test_document-16 test_document-17 test_document-18 test_document-19 test_document-20 test_document-21 test_document-22 Added: trunk/tests/document/Makefile.am =================================================================== --- trunk/tests/document/Makefile.am (rev 0) +++ trunk/tests/document/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,52 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_document-01 \ + test_document-02 \ + test_document-03 \ + test_document-04 \ + test_document-05 \ + test_document-06 \ + test_document-07 \ + test_document-08 \ + test_document-09 \ + test_document-10 \ + test_document-11 \ + test_document-12 \ + test_document-13 \ + test_document-14 \ + test_document-15 \ + test_document-16 \ + test_document-17 \ + test_document-18 \ + test_document-19 \ + test_document-20 \ + test_document-21 \ + test_document-22 + +test_document_01_SOURCES = test_document-01.cxx +test_document_02_SOURCES = test_document-02.cxx +test_document_03_SOURCES = test_document-03.cxx +test_document_04_SOURCES = test_document-04.cxx +test_document_05_SOURCES = test_document-05.cxx +test_document_06_SOURCES = test_document-06.cxx +test_document_07_SOURCES = test_document-07.cxx +test_document_08_SOURCES = test_document-08.cxx +test_document_09_SOURCES = test_document-09.cxx +test_document_10_SOURCES = test_document-10.cxx +test_document_11_SOURCES = test_document-11.cxx +test_document_12_SOURCES = test_document-12.cxx +test_document_13_SOURCES = test_document-13.cxx +test_document_14_SOURCES = test_document-14.cxx +test_document_15_SOURCES = test_document-15.cxx +test_document_16_SOURCES = test_document-16.cxx +test_document_17_SOURCES = test_document-17.cxx +test_document_18_SOURCES = test_document-18.cxx +test_document_19_SOURCES = test_document-19.cxx +test_document_20_SOURCES = test_document-20.cxx +test_document_21_SOURCES = test_document-21.cxx +test_document_22_SOURCES = test_document-22.cxx Property changes on: trunk/tests/document/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/event ___________________________________________________________________ Modified: svn:ignore - Makefile test_event-01 test_event-02 test_event-03 + Makefile Makefile.in .deps .libs test_event-01 test_event-02 test_event-03 Added: trunk/tests/event/Makefile.am =================================================================== --- trunk/tests/event/Makefile.am (rev 0) +++ trunk/tests/event/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,14 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_event-01 \ + test_event-02 \ + test_event-03 + +test_event_01_SOURCES = test_event-01.cxx +test_event_02_SOURCES = test_event-02.cxx +test_event_03_SOURCES = test_event-03.cxx Property changes on: trunk/tests/event/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/node ___________________________________________________________________ Modified: svn:ignore - Makefile test_node-01 test_node-02a test_node-02b test_node-02c test_node-02d test_node-03a test_node-03b test_node-04a test_node-04b test_node-05a test_node-05b test_node-05c test_node-05d test_node-06 test_node-07 test_node-08 test_node-09 test_node-10 test_node-11 test_node-12 test_node-13 + Makefile Makefile.in .deps .libs test_node-01 test_node-02a test_node-02b test_node-02c test_node-02d test_node-03a test_node-03b test_node-04a test_node-04b test_node-05a test_node-05b test_node-05c test_node-05d test_node-06 test_node-07 test_node-08 test_node-09 test_node-10 test_node-11 test_node-12 test_node-13 Added: trunk/tests/node/Makefile.am =================================================================== --- trunk/tests/node/Makefile.am (rev 0) +++ trunk/tests/node/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,50 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_node-01 \ + test_node-02a \ + test_node-02b \ + test_node-02c \ + test_node-02d \ + test_node-03a \ + test_node-03b \ + test_node-04a \ + test_node-04b \ + test_node-05a \ + test_node-05b \ + test_node-05c \ + test_node-05d \ + test_node-06 \ + test_node-07 \ + test_node-08 \ + test_node-09 \ + test_node-10 \ + test_node-11 \ + test_node-12 \ + test_node-13 + +test_node_01_SOURCES = test_node-01.cxx +test_node_02a_SOURCES = test_node-02a.cxx +test_node_02b_SOURCES = test_node-02b.cxx +test_node_02c_SOURCES = test_node-02c.cxx +test_node_02d_SOURCES = test_node-02d.cxx +test_node_03a_SOURCES = test_node-03a.cxx +test_node_03b_SOURCES = test_node-03b.cxx +test_node_04a_SOURCES = test_node-04a.cxx +test_node_04b_SOURCES = test_node-04b.cxx +test_node_05a_SOURCES = test_node-05a.cxx +test_node_05b_SOURCES = test_node-05b.cxx +test_node_05c_SOURCES = test_node-05c.cxx +test_node_05d_SOURCES = test_node-05d.cxx +test_node_06_SOURCES = test_node-06.cxx +test_node_07_SOURCES = test_node-07.cxx +test_node_08_SOURCES = test_node-08.cxx +test_node_09_SOURCES = test_node-09.cxx +test_node_10_SOURCES = test_node-10.cxx +test_node_11_SOURCES = test_node-11.cxx +test_node_12_SOURCES = test_node-12.cxx +test_node_13_SOURCES = test_node-13.cxx Property changes on: trunk/tests/node/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/tree ___________________________________________________________________ Modified: svn:ignore - Makefile test_tree-01 test_tree-02 test_tree-03 test_tree-04 test_tree-05 test_tree-06 + Makefile Makefile.in .deps .libs test_tree-01 test_tree-02 test_tree-03 test_tree-04 test_tree-05 test_tree-06 Added: trunk/tests/tree/Makefile.am =================================================================== --- trunk/tests/tree/Makefile.am (rev 0) +++ trunk/tests/tree/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,20 @@ + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_tree-01 \ + test_tree-02 \ + test_tree-03 \ + test_tree-04 \ + test_tree-05 \ + test_tree-06 + +test_tree_01_SOURCES = test_tree-01.cxx +test_tree_02_SOURCES = test_tree-02.cxx +test_tree_03_SOURCES = test_tree-03.cxx +test_tree_04_SOURCES = test_tree-04.cxx +test_tree_05_SOURCES = test_tree-05.cxx +test_tree_06_SOURCES = test_tree-06.cxx Property changes on: trunk/tests/tree/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Property changes on: trunk/tests/xslt ___________________________________________________________________ Modified: svn:ignore - Makefile test_xslt-01 test_xslt-02 test_xslt-03 test_xslt-04 test_xslt-05 + Makefile Makefile.in .deps .libs test_xslt-01 test_xslt-02 test_xslt-03 test_xslt-04 test_xslt-05 Added: trunk/tests/xslt/Makefile.am =================================================================== --- trunk/tests/xslt/Makefile.am (rev 0) +++ trunk/tests/xslt/Makefile.am 2008-11-25 15:50:51 UTC (rev 98) @@ -0,0 +1,22 @@ + +if WITH_XSLT + +AM_CPPFLAGS = -I$(top_srcdir)/include +LIBS = ../../src/libxsltwrapp.la ../../src/libxmlwrapp.la + +TESTS = runtest.pl + +noinst_PROGRAMS = \ + test_xslt-01 \ + test_xslt-02 \ + test_xslt-03 \ + test_xslt-04 \ + test_xslt-05 + +test_xslt_01_SOURCES = test_xslt-01.cxx +test_xslt_02_SOURCES = test_xslt-02.cxx +test_xslt_03_SOURCES = test_xslt-03.cxx +test_xslt_04_SOURCES = test_xslt-04.cxx +test_xslt_05_SOURCES = test_xslt-05.cxx + +endif Property changes on: trunk/tests/xslt/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Deleted: trunk/tools/cxxflags =================================================================== --- trunk/tools/cxxflags 2008-11-24 02:37:42 UTC (rev 97) +++ trunk/tools/cxxflags 2008-11-25 15:50:51 UTC (rev 98) @@ -1,396 +0,0 @@ -#! /usr/bin/perl -###################################################################### -# Copyright (C) 2001-2002 Peter J Jones (pj...@pm...) -# All Rights Reserved -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name of the Author nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR -# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -################################################################################ -# -# cxxflags (Helper script to get compiler flags) -# Peter J Jones (pj...@pm...) -# -# This file is part of cxxtools (http://pmade.org/pjones/software/cxxtools/) -# -################################################################################ -# -# Includes -# -################################################################################ -use strict; -use Getopt::Long; -################################################################################ -# -# Constants -# -################################################################################ -use constant DATE => 'Sat Aug 18 12:09:00 2001'; -use constant ID => '$Id: cxxflags,v 1.1.1.1 2003-08-04 04:57:28 pjones Exp $'; -################################################################################ -# -# Global Variables -# -################################################################################ -use vars qw($VERSION); -$VERSION = '0.0.1'; - -my %clo; - -my %flags = ( - 'getid' => '', - 'debug' => '', - 'depend' => '', - 'pic' => '', - 'optimize' => '', - 'ar' => '', - 'arflags' => '', - 'arextra' => '', - 'sar' => '', - 'sarflags' => '', - 'warn' => '', - 'general' => '', - 'object-ext' => '', - 'static-ext' => '', - 'shared-ext' => '', - 'static-pre' => '', - 'shared-pre' => '', - 'shared-mjr' => '', - 'exec-ext' => '', - 'mkexec' => '', - 'mkstatic' => '', - 'mkshared' => '', - 'linker' => '', - 'linkwith' => '', - 'mtcompile' => '', - 'mtlink' => '', -); -################################################################################ -# -# Code Start -# -################################################################################ -GetOptions( - \%clo, - 'help|h!', - 'cxx=s', - 'getid!', - 'setid=s', - - 'arflags|A!', - 'ar|a!', - 'arextra', - 'sar!', - 'sarflags!', - 'debug!', - 'depend|d!', - 'exec-extension!', - 'general!', - 'linker!', - 'linkwith=s@', - 'mkexec=s', - 'mkstatic=s', - 'mkshared=s', - 'mkshared-name=s', - 'major=i', - 'object-extension!', - 'optimize|O!', - 'pic|p!', - 'static-lib-extension!', - 'shared-lib-extension!', - 'static-lib-prefix!', - 'shared-lib-prefix!', - 'warn!', - 'mtcompile!', - 'mtlink!', - -) or usage(); $clo{'help'} and usage(); - -sub usage { - print "Usage: $0 [options]\n", <<EOT; - --cxx string The path to the compiler to use instead of \$CXX - --getid Get the current compiler ID - --setid id Don't run the compiler, assume it has the given id - - --ar, a Get the name of the tool for making archives - --arflags, A Get the flags for the ar tool - --arextra Get any commands to run after ar (ie ranlib) - --sar Get the name of the tool to create shared libs - --sarflags Get the flags for the sar tool - --debug Get flags for debugging - --depend, d Get the make depend compiler flags - --exec-extension Get the file extension for binary executables - --general Get general compiler flags that should always be used - --linker Get the name of the linker - --linkwith lib Get linker line for library - --linkwith path,lib Get linker libe for library in path - --mkexec file Get flag to output executable with given name - --mkstatic file Get flag to output static library with given name - --mkshared file Get flag to output shared library with given name - --mkshared-name file Get the complete name for a shared lib - --major number Set the major number for a shared lib - --mtcomplile Get flags for compiling multithreaded code - --mtlink Get flags for linking multithreaded objects - --object-extension Get the file extension for object files - --optimize, O Get the compilers level two optimization flags - --pic, p Get the flags for Position Independ Code - --static-lib-extension Get the file extension for a static library - --shared-lib-extension Get the file extension for a shared library - --static-lib-prefix Get the prefix for static libraries - --shared-lib-prefix Get the prefix for shared libraries - --warn Get compiler flags for generating warnings -EOT - exit; -} - -$clo{'cxx'} ||= $ENV{'CXX'} || 'c++'; -$clo{'linkwith'} ||= []; -$clo{'major'} ||= '1'; - -stat_compiler(); - -################################################################################ - -# -# this got out of hand ! -# -$clo{'debug'} and print "$flags{'debug'} "; -$clo{'depend'} and print "$flags{'depend'} "; -$clo{'pic'} and print "$flags{'pic'} "; -$clo{'optimize'} and print "$flags{'optimize'} "; -$clo{'ar'} and print "$flags{'ar'} "; -$clo{'arflags'} and print "$flags{'arflags'} "; -$clo{'arextra'} and print "$flags{'arextra'} "; -$clo{'sar'} and print "$flags{'sar'} "; -$clo{'sarflags'} and print "$flags{'sarflags'} "; -$clo{'warn'} and print "$flags{'warn'} "; -$clo{'general'} and print "$flags{'general'} "; -$clo{'object-extension'} and print "$flags{'object-ext'} "; -$clo{'static-lib-extension'}and print "$flags{'static-ext'} "; -$clo{'shared-lib-extension'}and print "$flags{'shared-ext'} "; -$clo{'static-lib-prefix'} and print "$flags{'static-pre'} "; -$clo{'shared-lib-prefix'} and print "$flags{'shared-pre'} "; -$clo{'mkshared-name'} and print "$flags{'shared-mjr'} "; -$clo{'exec-extension'} and print "$flags{'exec-ext'} "; -$clo{'mkexec'} and print "$flags{'mkexec'} "; -$clo{'mkstatic'} and print "$flags{'mkstatic'} "; -$clo{'mkshared'} and print "$flags{'mkshared'} "; -$clo{'linker'} and print "$flags{'linker'} "; -$clo{'linkwith'} and print "$flags{'linkwith'} "; -$clo{'mtcompile'} and print "$flags{'mtcompile'} "; -$clo{'mtlink'} and print "$flags{'mtlink'} "; -$clo{'getid'} and print "$flags{'getid'} "; - print "\n"; -################################################################################ - -sub stat_compiler { - my $output; - - if ($^O =~ /solaris/i) { - $flags{'mtcompile'} .= " -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT"; - } - - ################################################################################ - # gcc - if ($clo{'setid'} and $clo{'setid'} =~ /^gcc/) { - $output = $clo{'setid'}; - } else { - $output = `$clo{'cxx'} -v 2>&1`; - } - - if ($output =~ /gcc/) { - my $linker = 'gnu'; # default for now - - if ($^O =~ /solaris/i) { - if ($clo{'setid'}) { - if ($clo{'setid'} eq 'gcc-sun') { $linker = 'sun'; } - } else { - $output = `$clo{'cxx'} -Wl,-v 2>&1`; - - if ($output =~ /\[-h\s+name\]/ and $output =~ /\[-G\]/) { - $linker = 'sun'; - } - } - } elsif ($^O =~ /darwin/i) { - $linker = 'mach'; - } - - $flags{'debug'} = "-g"; - $flags{'depend'} = '-M'; - $flags{'optimize'} = '-O2'; - $flags{'ar'} = $ENV{'AR'} || 'ar'; - $flags{'arflags'} = $ENV{'ARFLAGS'} || 'rc'; - $flags{'sar'} = $clo{'cxx'}; - $flags{'sarflags'} = $ENV{'LDFLAGS'} || ''; - $flags{'warn'} = '-Wall -W -Wcast-align -Wwrite-strings'; - $flags{'object-ext'} = '.o'; - $flags{'static-ext'} = '.a'; - $flags{'shared-ext'} = '.so'; - $flags{'static-pre'} = "lib"; - $flags{'shared-pre'} = "lib"; - $flags{'linker'} = $clo{'cxx'}; - $flags{'mkexec'} = "-o $clo{'mkexec'}" if $clo{'mkexec'}; - $flags{'mkstatic'} = $clo{'mkstatic'} if $clo{'mkstatic'}; - - if ($clo{'mkshared'} or $clo{'mkshared-name'}) { - $flags{'shared-mjr'} = "lib$clo{'mkshared-name'}.so.$clo{'major'}" if $clo{'mkshared-name'}; - - if ($clo{'mkshared'}) { - if ($linker eq 'gnu') { - $flags{'mkshared'} = "-shared -o $clo{'mkshared'} -Wl,-soname,$clo{'mkshared'}.$clo{'major'}"; - } elsif ($linker eq 'sun') { - $flags{'mkshared'} = "-o $clo{'mkshared'} -Wl,-G,-h,$clo{'mkshared'}.$clo{'major'}"; - } elsif ($linker eq 'mach') { - $flags{'mkshared'} = "-o $clo{'mkshared'} -dynamiclib -compatibility_version $clo{'major'} -current_version $clo{'major'}"; - } else { - print STDERR "$0: your linker is not supported.\n"; - print STDERR "$0: you might want to install the GNU linker.\n"; - } - } - } - - foreach (@{$clo{'linkwith'}}) { - my ($path, $lib) = split(/,/, $_, 2); - if ($lib) { - $lib =~ s/^lib//; - $flags{'linkwith'} .= "-L$path -l$lib "; - } else { - $path =~ s/^lib//; - $flags{'linkwith'} .= "-l$path"; - } - } - - if ($^O =~ /freebsd/i) { - $flags{'mtlink'} .= " -pthread"; - $flags{'arextra'}.= "ranlib"; - $flags{'pic'} = '-fpic -shared'; - } elsif ($^O =~ /darwin/i) { - $flags{'pic'} = ''; - $flags{'shared.ext'} = '.dylib'; - $flags{'exec-ext'} = ''; - $flags{'arextra'} = "ranlib"; - } elsif ($^O =~ /cygwin/i) { - $flags{'pic'} = ''; - } else { - $flags{'mtlink'} .= " -lpthread"; - $flags{'pic'} = '-fpic -shared'; - } - - $flags{'getid'} = "gcc-$linker"; - return; - } - - ################################################################################ - # Microsoft Visual C++ (cl.exe) - if ($clo{'setid'} && $clo{'setid'} =~ /^microsoft/) { - $output = 'Microsoft'; - } else { - $output = `$clo{'cxx'} -verbose=version 2>&1`; - } - if ($output =~ /Microsoft/) { - - $flags{'debug'} = '/Od /Gz /Zi'; - $flags{'debug'} .= '/GA' if ($clo{'mkstatic'}); - $flags{'debug'} .= '/GD' if ($clo{'mkshared'}); - $flags{'depend'} ... [truncated message content] |
From: <vac...@us...> - 2008-11-26 12:09:28
|
Revision: 101 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=101&view=rev Author: vaclavslavik Date: 2008-11-26 12:09:18 +0000 (Wed, 26 Nov 2008) Log Message: ----------- split pkg-config file xmlwrapp.pc into xmlwrapp.pc and xsltwrapp.pc, to avoid unnecessary linking against libxslt in apps that only use libxml2 part Modified Paths: -------------- trunk/ChangeLog trunk/Makefile.am trunk/configure.ac trunk/xmlwrapp-config.in trunk/xmlwrapp.pc.in Added Paths: ----------- trunk/xsltwrapp.pc.in Property Changed: ---------------- trunk/xmlwrapp-config.in Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-11-25 16:03:00 UTC (rev 100) +++ trunk/ChangeLog 2008-11-26 12:09:18 UTC (rev 101) @@ -5,6 +5,10 @@ Ported Unix build system to Autotools. + Split pkg-config file xmlwrapp.pc into xmlwrapp.pc and + xsltwrapp.pc. Applications that use libxsltwrapp need to be + updated to use the latter (too). + Version 0.5.1 Various compilation fixes. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2008-11-25 16:03:00 UTC (rev 100) +++ trunk/Makefile.am 2008-11-26 12:09:18 UTC (rev 101) @@ -2,6 +2,11 @@ SUBDIRS = include src examples tests pkgconfigdir=$(libdir)/pkgconfig + +if WITH_XSLT +pkgconfig_DATA = xmlwrapp.pc xsltwrapp.pc +else pkgconfig_DATA = xmlwrapp.pc +endif bin_SCRIPTS = xmlwrapp-config Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2008-11-25 16:03:00 UTC (rev 100) +++ trunk/configure.ac 2008-11-26 12:09:18 UTC (rev 101) @@ -94,17 +94,20 @@ dnl === Generate output files === -XMLWRAPP_LINK_FLAGS="-lxmlwrapp $LIBXML_LIBS" +dnl This is support for the legacy xmlwrapp-config script, which has to behave +dnl as it did in 0.5.x, i.e. output flags for both libxmlwrapp and +dnl libxsltwrapp and also include dependency libs' flags for static linking +LEGACY_LINK_FLAGS="-lxmlwrapp $LIBXML_LIBS" if test "x$build_xslt" = "xyes" ; then - XMLWRAPP_LINK_FLAGS="-lxsltwrapp $LIBEXSLT_LIBS $LIBXSLT_LIBS $XMLWRAPP_LINK_FLAGS" + LEGACY_LINK_FLAGS="-lxsltwrapp $LIBEXSLT_LIBS $LIBXSLT_LIBS $LEGACY_LINK_FLAGS" fi +AC_SUBST(LEGACY_LINK_FLAGS) AM_CONDITIONAL(WITH_XSLT, [ test "x$build_xslt" = "xyes" ]) -AC_SUBST(XMLWRAPP_LINK_FLAGS) - AC_CONFIG_FILES([ xmlwrapp.pc + xsltwrapp.pc xmlwrapp-config Makefile include/Makefile Modified: trunk/xmlwrapp-config.in =================================================================== --- trunk/xmlwrapp-config.in 2008-11-25 16:03:00 UTC (rev 100) +++ trunk/xmlwrapp-config.in 2008-11-26 12:09:18 UTC (rev 101) @@ -29,7 +29,7 @@ ;; --libs) - echo "-L@libdir@ @XMLWRAPP_LINK_FLAGS@" + echo "-L@libdir@ @LEGACY_LINK_FLAGS@" ;; --cflags|--cxxflags) Property changes on: trunk/xmlwrapp-config.in ___________________________________________________________________ Deleted: svn:executable - * Modified: trunk/xmlwrapp.pc.in =================================================================== --- trunk/xmlwrapp.pc.in 2008-11-25 16:03:00 UTC (rev 100) +++ trunk/xmlwrapp.pc.in 2008-11-26 12:09:18 UTC (rev 101) @@ -5,7 +5,8 @@ Name: xmlwrapp Version: @VERSION@ -Description: A C++ wrapper around libxml2 and libxslt +Description: A C++ wrapper around libxml2 Requires: -Libs: -L${libdir} @XMLWRAPP_LINK_FLAGS@ +Libs: -L${libdir} -lxmlwrapp +Libs.private: @LIBXML_LIBS@ Cflags: -I${includedir} Added: trunk/xsltwrapp.pc.in =================================================================== --- trunk/xsltwrapp.pc.in (rev 0) +++ trunk/xsltwrapp.pc.in 2008-11-26 12:09:18 UTC (rev 101) @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: xsltwrapp +Version: @VERSION@ +Description: A C++ wrapper around libxslt +Requires: xmlwrapp = @VERSION@ +Libs: -L${libdir} -lxsltwrapp +Libs.private: @LIBEXSLT_LIBS@ @LIBXSLT_LIBS@ +Cflags: -I${includedir} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-11-26 14:26:40
|
Revision: 102 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=102&view=rev Author: vaclavslavik Date: 2008-11-26 14:26:37 +0000 (Wed, 26 Nov 2008) Log Message: ----------- xsltInit() is available since libxslt-1.1.6, use it Modified Paths: -------------- trunk/configure.ac trunk/src/libxslt/init.cxx Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2008-11-26 12:09:18 UTC (rev 101) +++ trunk/configure.ac 2008-11-26 14:26:37 UTC (rev 102) @@ -79,7 +79,7 @@ PKG_CHECK_MODULES(LIBXML, [libxml-2.0 >= 2.4.28]) if test "x$build_xslt" = "xyes" ; then - PKG_CHECK_MODULES(LIBXSLT, [libxslt >= 1.0.23]) + PKG_CHECK_MODULES(LIBXSLT, [libxslt >= 1.1.6]) PKG_CHECK_MODULES(LIBEXSLT, [libexslt]) fi Modified: trunk/src/libxslt/init.cxx =================================================================== --- trunk/src/libxslt/init.cxx 2008-11-26 12:09:18 UTC (rev 101) +++ trunk/src/libxslt/init.cxx 2008-11-26 14:26:37 UTC (rev 102) @@ -50,12 +50,7 @@ } //#################################################################### xslt::init::init (void) { - /* - * this really sucks, but it is the only way to call xsltInit() right - * now. This is necessary to make libxslt thread safe. - */ - xsltStylesheetPtr ss = xsltNewStylesheet(); - xsltFreeStylesheet(ss); + xsltInit(); // set some defautls process_xincludes(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-14 14:50:55
|
Revision: 111 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=111&view=rev Author: vaclavslavik Date: 2008-12-14 14:50:48 +0000 (Sun, 14 Dec 2008) Log Message: ----------- renamed ChangeLog file to NEWS, that's what its level of details is Added Paths: ----------- trunk/NEWS Removed Paths: ------------- trunk/ChangeLog Deleted: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-12-14 14:27:46 UTC (rev 110) +++ trunk/ChangeLog 2008-12-14 14:50:48 UTC (rev 111) @@ -1,261 +0,0 @@ -Version 0.6.0 - - Fixed libxmlwrapp to not depend on libxslt if XSLT support - is enabled (Vadim Zeitlin, #1927398). - - Ported Unix build system to Autotools. - - Split pkg-config file xmlwrapp.pc into xmlwrapp.pc and - xsltwrapp.pc. Applications that use libxsltwrapp need to be - updated to use the latter (too). - - Input document to xslt::stylesheet::apply() is now passed as - const reference instead of non-const one. - - It is no longer necessary to instantiate xml/xslt::init object before - using the library; this is now done automatically (thread safety is - preserved) and new code shouldn't do it. Moreover, creating multiple - xml/xslt::init object instances is now possible and doesn't result in - multiple initialization/shutdown of the library. - - Configuration methods of xml/xslt::init classes are now static. - -Version 0.5.1 - - Various compilation fixes. - -Version 0.5.0 - - Fixed a null pointer dereference problem in - xml::attributes, Bug ID 20. Thanks goes to John K. Hohm - for finding this and providing a working patch. - - Added three new constructors to the xml::node class for creating - CDATA sections, XML comments, and XML processing instructions. This - is done using three new helper structs, xml::node::cdata, - xml::node::comment, and xml::node::pi. - - Added new member functions to the xml::node class. - They are: size and empty. - - Added new member functions to the xml::document class. - They are: size, push_back, insert, replace, and erase. - - Added the ability to compress XML files saved with the - xml::document::save_to_file member function (Bug ID 19). - - Major clean ups in the test harness. Test code should be a lot easier - to write now. - -Version 0.4.4 - - Small changes so that xmlwrapp can work with libxml2 - version 2.6.0. Thanks goes to Craig Wiesen and Jonathan - Wakely for finding this. (Bug ID 18). - - Fixed a typo in the manual. Thanks goes to Bill - Luoma. (Bug ID 16). - -Version 0.4.3 - - Fixed a build problem on Linux (bug 10). This happens when - libxslt was installed in /usr. configure.pl could not find - libxslt because xslt-config does not list /usr/include. - - Updated the TODO list. - - -Version 0.4.2 - - Version 0.4.2 is a maintenance release. A few small bugs were - fixed and a work around for a bug in Perl 5.8 was added. - - Updated Perl scripts to work around a bug in the Perl 5.8 - regex parser. Thanks goes to Andy Chou. - - Added an encoding patch from Dmitriy Nikitinskiy. - -Version 0.4.1 - - Version 0.4.1 fixes a few small bugs and also includes some new - features. It is binary compatible with version 0.4.0. - - Typos in the doxygen documentation were fixed thanks to Jonathan - Wakely, Stephen Blake and Chris de Hoop. - - Fixed a bug in configure.pl that caused a bad xmlwrapp-config to - be generated when XSLT was enabled. - - Added support for pkg-config and the xmlwrapp.pc file. - - Added support for libexslt. - - Added the xml::init::remove_whitespace member function to skip - ignorable whitespace from parsed XML documents. Default value is - false, so whitespace is included in the node tree by default. - - Added the xml::node::self and xml::node::parent member - functions. They return @code{xml::node::iterator} or - xml::node::const_iterator objects. - - Added a new version of the xml::node::insert member function that - does not require a location iterator, but instead inserts at the - end of the child list like the xml::node::push_back member - function does. - - Added a range version of the xml::node::erase member function and - a version that takes the name of a node to erase. All nodes with - matching names will be removed from the child list. - - Added two versions of the xml::node::sort member function. The - first, will sort child nodes with the given name using one of - their attributes as a sort key. The other, uses a user supplied - function object to sort the child nodes. - -Version 0.4.0 - - Version 0.4.0 is a feature release. xmlwrapp now supports XSLT via - libxslt. This support is called xsltwrapp and is optional. - - Added the xslt::init and xslt::stylesheet classes to support XSLT. - - Added the xml::init::load_external_subsets member function to make - libxml load external subsets by default. - -Version 0.3.0 - - This version contains a lot of new features. Because of this, - certain API calls have been changed or removed. The following list - should help you update code that is using xmlwrapp. - - Changed configure.pl to require at least version 2.4.28 of - libxml2. - - The xml::tree_parser constructors can now throw exceptions if - there was an error during parsing. This is optional, and is - controlled by a bool flag passed to the constructors. This also - means that xml::tree_parser will now prevent libxml2 from sending - error messages to standard error. The new default behavior is to - throw an exception. - - Some of the xml::event_parser callback member functions have - changed. There are also new callbacks so that you can catch CDATA - sections, processing instructions and XML comments. - - It is now safe to throw exceptions from within an - xml::event_parser callback. The exception will not be passed up - the stack to the caller of one of the parsing member - functions. Instead, it will stop the parsing and set an error - condition. - - There is a new xml::document class that allows you to set XML - document variables such as the encoding and version. The document - class also supports saving itself to a file, string or a - std::ostream. It also includes functions for validating a document - against an internal or external DTD. - - The xml::tree_parser class no longer contains a get_root_node() - member function. It has been replaced with get_document() which - will return a reference to a xml::document object. That object can - then be used to call get_root_node(). - - Another new class, xml::attributes, for getting and setting the - attributes of a node. This class replaces all the member functions - of xml::node that dealt with attributes. This class is much better - than using the old xml::node member functions because it supports - iterators and functions like find. - - The xml::init class will prevent libxml2 from sending any messages - to stderr. This should not be a problem since most classes will - catch the message and use it in an exception or store it for later - use. - - xml::init will now set some default libxml2 global - variables. Indenting of output XML text is turned on. Default - substitution of entities on turned on. Validating of all - documents by default is turned off. There are new member functions - you can use to change these defaults. - - Compiler flags will no longer contain quotes around directory - names. This was added for cygwin when people have a space in the - current working directory path. It was removed because it was - causing problems on other platforms. - - There is a new header file, xmlwrapp/xmlwrapp.h, that includes all - of the other xmlwrapp header files. - - A real working test harness has been added with several tests. - - New member functions for xml::node. - - 4 different versions of xml::node::find. - - xml::node::insert. - - xml::node::replace. - - xml::node::erase. - - xml::node::get_attributes. - - xml::node::get_type. - -Version 0.2.2 - - Version 0.2.2 was a bug fix release. - - Changed include guards so that they don't violate the C++ - standard. Thanks to Greg Chicares. - - Include <cstddef> to get std::size_t and std::ptrdiff_t. Thanks to - Greg Chicares. - - Fix a major bug where a pimpl was not created in - xml::tree_parser. Thanks to Greg Chicares. - - Added a call to xmlKeepBlanksDefault(0) in xml::init constructor - to produce better looking XML. If this causes any problems we will - have to remove it. This was suggested by Daniel Evison. - - Fixed an issue with command quoting in the configure.pl script. - -Version 0.2.1 - - Version 0.2.1 was a bug fix release. - - Fixed a bug in the xml::event_parser class that caused parsing to - continue even when one of the event member functions returned - false. Thanks to Michael Grabner for finding this one. - - There were a few reports that xmlwrapp could be compiled using - MSVC on Win32. A project file for MSVC was added so that no one - would have to do this again. The STLport is needed on the Win32 - platform. - - The get_namespace and set_namespace functions were removed from - the xml::node class since they were defined but not yet - implemented. - -Version 0.2.0 - - Version 0.2.0 of xmlwrapp was the first public release. It - included the following changes from version 0.1.0. - - First draft of the documentation. - - Added example programs. - - Changed operator<< for xml::node from a template function to a - normal function that takes a std::ostream. This allows xmlwrapp - to compile with GCC < 3.0. - - Replaced calls to std::free with xmlFree in the libxml2 backend - wrapper. - -Version 0.1.0 - - Version 0.1.0 was the first packaged version. It was packaged for - <http://pmade.org/software/clo++/,clo++>. - - It included no documentation or examples, and was not intended for - use by other developers. Copied: trunk/NEWS (from rev 109, trunk/ChangeLog) =================================================================== --- trunk/NEWS (rev 0) +++ trunk/NEWS 2008-12-14 14:50:48 UTC (rev 111) @@ -0,0 +1,261 @@ +Version 0.6.0 + + Fixed libxmlwrapp to not depend on libxslt if XSLT support + is enabled (Vadim Zeitlin, #1927398). + + Ported Unix build system to Autotools. + + Split pkg-config file xmlwrapp.pc into xmlwrapp.pc and + xsltwrapp.pc. Applications that use libxsltwrapp need to be + updated to use the latter (too). + + Input document to xslt::stylesheet::apply() is now passed as + const reference instead of non-const one. + + It is no longer necessary to instantiate xml/xslt::init object before + using the library; this is now done automatically (thread safety is + preserved) and new code shouldn't do it. Moreover, creating multiple + xml/xslt::init object instances is now possible and doesn't result in + multiple initialization/shutdown of the library. + + Configuration methods of xml/xslt::init classes are now static. + +Version 0.5.1 + + Various compilation fixes. + +Version 0.5.0 + + Fixed a null pointer dereference problem in + xml::attributes, Bug ID 20. Thanks goes to John K. Hohm + for finding this and providing a working patch. + + Added three new constructors to the xml::node class for creating + CDATA sections, XML comments, and XML processing instructions. This + is done using three new helper structs, xml::node::cdata, + xml::node::comment, and xml::node::pi. + + Added new member functions to the xml::node class. + They are: size and empty. + + Added new member functions to the xml::document class. + They are: size, push_back, insert, replace, and erase. + + Added the ability to compress XML files saved with the + xml::document::save_to_file member function (Bug ID 19). + + Major clean ups in the test harness. Test code should be a lot easier + to write now. + +Version 0.4.4 + + Small changes so that xmlwrapp can work with libxml2 + version 2.6.0. Thanks goes to Craig Wiesen and Jonathan + Wakely for finding this. (Bug ID 18). + + Fixed a typo in the manual. Thanks goes to Bill + Luoma. (Bug ID 16). + +Version 0.4.3 + + Fixed a build problem on Linux (bug 10). This happens when + libxslt was installed in /usr. configure.pl could not find + libxslt because xslt-config does not list /usr/include. + + Updated the TODO list. + + +Version 0.4.2 + + Version 0.4.2 is a maintenance release. A few small bugs were + fixed and a work around for a bug in Perl 5.8 was added. + + Updated Perl scripts to work around a bug in the Perl 5.8 + regex parser. Thanks goes to Andy Chou. + + Added an encoding patch from Dmitriy Nikitinskiy. + +Version 0.4.1 + + Version 0.4.1 fixes a few small bugs and also includes some new + features. It is binary compatible with version 0.4.0. + + Typos in the doxygen documentation were fixed thanks to Jonathan + Wakely, Stephen Blake and Chris de Hoop. + + Fixed a bug in configure.pl that caused a bad xmlwrapp-config to + be generated when XSLT was enabled. + + Added support for pkg-config and the xmlwrapp.pc file. + + Added support for libexslt. + + Added the xml::init::remove_whitespace member function to skip + ignorable whitespace from parsed XML documents. Default value is + false, so whitespace is included in the node tree by default. + + Added the xml::node::self and xml::node::parent member + functions. They return @code{xml::node::iterator} or + xml::node::const_iterator objects. + + Added a new version of the xml::node::insert member function that + does not require a location iterator, but instead inserts at the + end of the child list like the xml::node::push_back member + function does. + + Added a range version of the xml::node::erase member function and + a version that takes the name of a node to erase. All nodes with + matching names will be removed from the child list. + + Added two versions of the xml::node::sort member function. The + first, will sort child nodes with the given name using one of + their attributes as a sort key. The other, uses a user supplied + function object to sort the child nodes. + +Version 0.4.0 + + Version 0.4.0 is a feature release. xmlwrapp now supports XSLT via + libxslt. This support is called xsltwrapp and is optional. + + Added the xslt::init and xslt::stylesheet classes to support XSLT. + + Added the xml::init::load_external_subsets member function to make + libxml load external subsets by default. + +Version 0.3.0 + + This version contains a lot of new features. Because of this, + certain API calls have been changed or removed. The following list + should help you update code that is using xmlwrapp. + + Changed configure.pl to require at least version 2.4.28 of + libxml2. + + The xml::tree_parser constructors can now throw exceptions if + there was an error during parsing. This is optional, and is + controlled by a bool flag passed to the constructors. This also + means that xml::tree_parser will now prevent libxml2 from sending + error messages to standard error. The new default behavior is to + throw an exception. + + Some of the xml::event_parser callback member functions have + changed. There are also new callbacks so that you can catch CDATA + sections, processing instructions and XML comments. + + It is now safe to throw exceptions from within an + xml::event_parser callback. The exception will not be passed up + the stack to the caller of one of the parsing member + functions. Instead, it will stop the parsing and set an error + condition. + + There is a new xml::document class that allows you to set XML + document variables such as the encoding and version. The document + class also supports saving itself to a file, string or a + std::ostream. It also includes functions for validating a document + against an internal or external DTD. + + The xml::tree_parser class no longer contains a get_root_node() + member function. It has been replaced with get_document() which + will return a reference to a xml::document object. That object can + then be used to call get_root_node(). + + Another new class, xml::attributes, for getting and setting the + attributes of a node. This class replaces all the member functions + of xml::node that dealt with attributes. This class is much better + than using the old xml::node member functions because it supports + iterators and functions like find. + + The xml::init class will prevent libxml2 from sending any messages + to stderr. This should not be a problem since most classes will + catch the message and use it in an exception or store it for later + use. + + xml::init will now set some default libxml2 global + variables. Indenting of output XML text is turned on. Default + substitution of entities on turned on. Validating of all + documents by default is turned off. There are new member functions + you can use to change these defaults. + + Compiler flags will no longer contain quotes around directory + names. This was added for cygwin when people have a space in the + current working directory path. It was removed because it was + causing problems on other platforms. + + There is a new header file, xmlwrapp/xmlwrapp.h, that includes all + of the other xmlwrapp header files. + + A real working test harness has been added with several tests. + + New member functions for xml::node. + + 4 different versions of xml::node::find. + + xml::node::insert. + + xml::node::replace. + + xml::node::erase. + + xml::node::get_attributes. + + xml::node::get_type. + +Version 0.2.2 + + Version 0.2.2 was a bug fix release. + + Changed include guards so that they don't violate the C++ + standard. Thanks to Greg Chicares. + + Include <cstddef> to get std::size_t and std::ptrdiff_t. Thanks to + Greg Chicares. + + Fix a major bug where a pimpl was not created in + xml::tree_parser. Thanks to Greg Chicares. + + Added a call to xmlKeepBlanksDefault(0) in xml::init constructor + to produce better looking XML. If this causes any problems we will + have to remove it. This was suggested by Daniel Evison. + + Fixed an issue with command quoting in the configure.pl script. + +Version 0.2.1 + + Version 0.2.1 was a bug fix release. + + Fixed a bug in the xml::event_parser class that caused parsing to + continue even when one of the event member functions returned + false. Thanks to Michael Grabner for finding this one. + + There were a few reports that xmlwrapp could be compiled using + MSVC on Win32. A project file for MSVC was added so that no one + would have to do this again. The STLport is needed on the Win32 + platform. + + The get_namespace and set_namespace functions were removed from + the xml::node class since they were defined but not yet + implemented. + +Version 0.2.0 + + Version 0.2.0 of xmlwrapp was the first public release. It + included the following changes from version 0.1.0. + + First draft of the documentation. + + Added example programs. + + Changed operator<< for xml::node from a template function to a + normal function that takes a std::ostream. This allows xmlwrapp + to compile with GCC < 3.0. + + Replaced calls to std::free with xmlFree in the libxml2 backend + wrapper. + +Version 0.1.0 + + Version 0.1.0 was the first packaged version. It was packaged for + <http://pmade.org/software/clo++/,clo++>. + + It included no documentation or examples, and was not intended for + use by other developers. Property changes on: trunk/NEWS ___________________________________________________________________ Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-16 18:24:52
|
Revision: 116 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=116&view=rev Author: vaclavslavik Date: 2008-12-16 18:24:46 +0000 (Tue, 16 Dec 2008) Log Message: ----------- added xml::node::get_namespace() function (patch #2102276) Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2008-12-16 18:19:01 UTC (rev 115) +++ trunk/NEWS 2008-12-16 18:24:46 UTC (rev 116) @@ -25,6 +25,8 @@ PDF version of the manual is no longer provided, use HTML documentation included with xmlwrapp source distribution. + Added xml::node::get_namespace() function. + Version 0.5.1 Various compilation fixes. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2008-12-16 18:19:01 UTC (rev 115) +++ trunk/include/xmlwrapp/node.h 2008-12-16 18:24:46 UTC (rev 116) @@ -328,6 +328,17 @@ //#################################################################### /** + * Get the namespace of this xml::node. + * + * @return The namespace of this node or NULL if no namespace is + * associated. + * @author Vaclav Slavik + **/ + //#################################################################### + const char* get_namespace (void) const; + + //#################################################################### + /** * Find out if this node is a text node or sometiming like a text node, * CDATA for example. * Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-12-16 18:19:01 UTC (rev 115) +++ trunk/src/libxml/node.cxx 2008-12-16 18:24:46 UTC (rev 116) @@ -340,6 +340,12 @@ return pimpl_->attrs_; } //#################################################################### +const char *xml::node::get_namespace (void) const { + return pimpl_->xmlnode_->ns + ? reinterpret_cast<const char*>(pimpl_->xmlnode_->ns->href) + : NULL; +} +//#################################################################### bool xml::node::is_text (void) const { return xmlNodeIsText(pimpl_->xmlnode_) != 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-16 19:05:16
|
Revision: 117 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=117&view=rev Author: vaclavslavik Date: 2008-12-16 19:05:11 +0000 (Tue, 16 Dec 2008) Log Message: ----------- added ability to create text nodes, using xml::node::text Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx trunk/tests/node/Makefile.am trunk/tests/node/runtest.pl Added Paths: ----------- trunk/tests/node/data/14.out trunk/tests/node/test_node-14.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2008-12-16 18:24:46 UTC (rev 116) +++ trunk/NEWS 2008-12-16 19:05:11 UTC (rev 117) @@ -27,6 +27,9 @@ Added xml::node::get_namespace() function. + Added new constructor to the xml::node class for creating text nodes, + using xml::node::text helper struct. + Version 0.5.1 Various compilation fixes. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2008-12-16 18:24:46 UTC (rev 116) +++ trunk/include/xmlwrapp/node.h 2008-12-16 19:05:11 UTC (rev 117) @@ -130,6 +130,18 @@ const char *n, *c; }; + /** + * Helper struct for creating a xml::node of type_text. + * + * @code + * xml::node mynode(xml::node::text("This is an XML text fragment")); + * @endcode + */ + struct text { + explicit text (const char *text) : t(text) { } + const char *t; + }; + //#################################################################### /** * Construct a new blank xml::node. @@ -212,6 +224,22 @@ //#################################################################### /** + * Construct a new xml::node that is of type_text. The text_info + * parameter should contain the text. + * + * @note Sample Use Example: + * @code + * xml::node mynode(xml::node::text("This is XML text")); + * @endcode + * + * @param text_info A text struct that tells xml::node what the text will be. + * @author Vaclav Slavik + **/ + //#################################################################### + explicit node (text text_info); + + //#################################################################### + /** * Construct a new xml::node by copying another xml::node. * * @param other The other node to copy. Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-12-16 18:24:46 UTC (rev 116) +++ trunk/src/libxml/node.cxx 2008-12-16 19:05:11 UTC (rev 117) @@ -240,6 +240,16 @@ ap.release(); } //#################################################################### +xml::node::node (text text_info) { + std::auto_ptr<node_impl> ap(pimpl_ = new node_impl); + + if ( (pimpl_->xmlnode_ = xmlNewText(reinterpret_cast<const xmlChar*>(text_info.t))) == 0) { + throw std::bad_alloc(); + } + + ap.release(); +} +//#################################################################### xml::node::node (const node &other) { std::auto_ptr<node_impl> ap(pimpl_ = new node_impl); Modified: trunk/tests/node/Makefile.am =================================================================== --- trunk/tests/node/Makefile.am 2008-12-16 18:24:46 UTC (rev 116) +++ trunk/tests/node/Makefile.am 2008-12-16 19:05:11 UTC (rev 117) @@ -25,7 +25,8 @@ test_node-10 \ test_node-11 \ test_node-12 \ - test_node-13 + test_node-13 \ + test_node-14 test_node_01_SOURCES = test_node-01.cxx test_node_02a_SOURCES = test_node-02a.cxx @@ -48,3 +49,4 @@ test_node_11_SOURCES = test_node-11.cxx test_node_12_SOURCES = test_node-12.cxx test_node_13_SOURCES = test_node-13.cxx +test_node_14_SOURCES = test_node-14.cxx Added: trunk/tests/node/data/14.out =================================================================== --- trunk/tests/node/data/14.out (rev 0) +++ trunk/tests/node/data/14.out 2008-12-16 19:05:11 UTC (rev 117) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<root>some text</root> Modified: trunk/tests/node/runtest.pl =================================================================== --- trunk/tests/node/runtest.pl 2008-12-16 18:24:46 UTC (rev 116) +++ trunk/tests/node/runtest.pl 2008-12-16 19:05:11 UTC (rev 117) @@ -81,5 +81,7 @@ ########################################################################### $test->regression("empty (13)", "./test_node-13", "data/13.out"); ########################################################################### + $test->regression("empty (14)", "./test_node-14", "data/14.out"); + ########################################################################### } ########################################################################### Added: trunk/tests/node/test_node-14.cxx =================================================================== --- trunk/tests/node/test_node-14.cxx (rev 0) +++ trunk/tests/node/test_node-14.cxx 2008-12-16 19:05:11 UTC (rev 117) @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This test checks xml::node::node(text) + */ + +#include <xmlwrapp/xmlwrapp.h> +#include <iostream> +#include <exception> + +int main (int argc, char *argv[]) { + if (argc != 1) { + std::cerr << "Usage: " << argv[0] << "\n"; + return 1; + } + + try { + xml::node root("root"); + xml::node n(xml::node::text("some text")); + root.push_back(n); + std::cout << root; + } catch (const std::exception &e) { + std::cout << e.what() << std::endl; + return 1; + } + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-21 01:39:21
|
Revision: 118 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=118&view=rev Author: vaclavslavik Date: 2008-12-21 01:36:38 +0000 (Sun, 21 Dec 2008) Log Message: ----------- made node_iterator creation a bit faster: don't initialize fake_node_ to blank node and avoid xmlNewNode() call and accompanying memory allocation Modified Paths: -------------- trunk/include/xmlwrapp/attributes.h trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.h Modified: trunk/include/xmlwrapp/attributes.h =================================================================== --- trunk/include/xmlwrapp/attributes.h 2008-12-16 19:05:11 UTC (rev 117) +++ trunk/include/xmlwrapp/attributes.h 2008-12-21 01:36:38 UTC (rev 118) @@ -372,7 +372,10 @@ private: struct pimpl; pimpl *pimpl_; + + // private ctor to create uninitialized instance explicit attributes (int); + void set_data (void *node); void* get_data (void); friend struct node_impl; Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2008-12-16 19:05:11 UTC (rev 117) +++ trunk/include/xmlwrapp/node.h 2008-12-21 01:36:38 UTC (rev 118) @@ -800,8 +800,13 @@ **/ //#################################################################### friend std::ostream& operator<< (std::ostream &stream, const node &n); + private: node_impl *pimpl_; + + // private ctor to create uninitialized instance + explicit node (int); + void set_node_data (void *data); void* get_node_data (void); void* release_node_data (void); Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-12-16 19:05:11 UTC (rev 117) +++ trunk/src/libxml/node.cxx 2008-12-21 01:36:38 UTC (rev 118) @@ -175,6 +175,10 @@ xmlNodePtr find_node(const char *name, xmlNodePtr first); } //#################################################################### +xml::node::node (int) { + pimpl_ = new node_impl; +} +//#################################################################### xml::node::node (void) { std::auto_ptr<node_impl> ap(pimpl_ = new node_impl); Modified: trunk/src/libxml/node_iterator.h =================================================================== --- trunk/src/libxml/node_iterator.h 2008-12-16 19:05:11 UTC (rev 117) +++ trunk/src/libxml/node_iterator.h 2008-12-21 01:36:38 UTC (rev 118) @@ -48,10 +48,10 @@ // base iterator class class node_iterator { public: - node_iterator (void) : node_(0) {} - node_iterator (node &parent) : node_(reinterpret_cast<xmlNodePtr>(parent.get_node_data())) {} - node_iterator (xmlNodePtr xmlnode) : node_(xmlnode) {} - node_iterator (const node_iterator &other) : node_(other.node_) {} + node_iterator (void) : fake_node_(0), node_(0) {} + node_iterator (node &parent) : fake_node_(0), node_(reinterpret_cast<xmlNodePtr>(parent.get_node_data())) {} + node_iterator (xmlNodePtr xmlnode) : fake_node_(0), node_(xmlnode) {} + node_iterator (const node_iterator &other) : fake_node_(0), node_(other.node_) {} node_iterator& operator= (const node_iterator &other) { node_ = other.node_; return *this;} node* get (void) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-21 15:55:54
|
Revision: 120 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=120&view=rev Author: vaclavslavik Date: 2008-12-21 15:55:51 +0000 (Sun, 21 Dec 2008) Log Message: ----------- Improved iterators performance by using pool allocator instead of standard operator new to allocate pimpl objects (only if Boost.Pool is available) Modified Paths: -------------- trunk/NEWS trunk/configure.ac trunk/src/Makefile.am trunk/src/libxml/ait_impl.h trunk/src/libxml/attributes.cxx trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx Added Paths: ----------- trunk/src/libxml/pimpl_base.h Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/NEWS 2008-12-21 15:55:51 UTC (rev 120) @@ -30,6 +30,8 @@ Added new constructor to the xml::node class for creating text nodes, using xml::node::text helper struct. + Improved iterators performance (only if Boost.Pool is available). + Version 0.5.1 Various compilation fixes. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/configure.ac 2008-12-21 15:55:51 UTC (rev 120) @@ -84,6 +84,10 @@ fi +AC_LANG_PUSH([C++]) +AC_CHECK_HEADERS([boost/pool/singleton_pool.hpp]) +AC_LANG_POP([C++]) + dnl === Compiler-specific stuff === if test "x$GCC" == "xyes"; then Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/src/Makefile.am 2008-12-21 15:55:51 UTC (rev 120) @@ -25,6 +25,7 @@ libxml/node_iterator.h \ libxml/node_manip.cxx \ libxml/node_manip.h \ + libxml/pimpl_base.h \ libxml/tree_parser.cxx \ libxml/utility.cxx \ libxml/utility.h Modified: trunk/src/libxml/ait_impl.h =================================================================== --- trunk/src/libxml/ait_impl.h 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/src/libxml/ait_impl.h 2008-12-21 15:55:51 UTC (rev 120) @@ -40,6 +40,8 @@ // xmlwrapp includes #include "xmlwrapp/attributes.h" +#include "pimpl_base.h" + // libxml2 includes #include <libxml/tree.h> @@ -49,7 +51,7 @@ * the class that does all the work behind xml::attributes::iterator and * xml::attributes::const_iterator. */ -class ait_impl { +class ait_impl : public pimpl_base<ait_impl> { public: ait_impl (xmlNodePtr node, xmlAttrPtr prop); ait_impl (const char *name, const char *value, bool); Modified: trunk/src/libxml/attributes.cxx =================================================================== --- trunk/src/libxml/attributes.cxx 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/src/libxml/attributes.cxx 2008-12-21 15:55:51 UTC (rev 120) @@ -37,6 +37,7 @@ // xmlwrapp includes #include "xmlwrapp/attributes.h" #include "ait_impl.h" +#include "pimpl_base.h" // standard includes #include <new> @@ -46,7 +47,7 @@ #include <libxml/tree.h> //#################################################################### -struct xml::attributes::pimpl { +struct xml::attributes::pimpl : public xml::pimpl_base<xml::attributes::pimpl> { //#################################################################### pimpl (void) : owner_(true) { xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/src/libxml/node.cxx 2008-12-21 15:55:51 UTC (rev 120) @@ -40,6 +40,7 @@ #include "utility.h" #include "ait_impl.h" #include "node_manip.h" +#include "pimpl_base.h" // standard includes #include <cstring> @@ -58,7 +59,7 @@ #include <libxml/parser.h> //#################################################################### -struct xml::node_impl { +struct xml::node_impl : public xml::pimpl_base<xml::node_impl> { //#################################################################### node_impl (void) : xmlnode_(0), owner_(true), attrs_(0) { } Modified: trunk/src/libxml/node_iterator.cxx =================================================================== --- trunk/src/libxml/node_iterator.cxx 2008-12-21 01:38:53 UTC (rev 119) +++ trunk/src/libxml/node_iterator.cxx 2008-12-21 15:55:51 UTC (rev 120) @@ -36,6 +36,7 @@ // definition include #include "node_iterator.h" +#include "pimpl_base.h" // xmlwrapp includes #include "xmlwrapp/node.h" @@ -47,7 +48,7 @@ #include <libxml/tree.h> // xml::node::iterator pimpl -struct xml::nipimpl { +struct xml::nipimpl : public xml::pimpl_base<xml::nipimpl> { node_iterator it; nipimpl (void) {}; Added: trunk/src/libxml/pimpl_base.h =================================================================== --- trunk/src/libxml/pimpl_base.h (rev 0) +++ trunk/src/libxml/pimpl_base.h 2008-12-21 15:55:51 UTC (rev 120) @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2008 Vaclav Slavik (vs...@fa...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _xmlwrapp_pimpl_base_h_ +#define _xmlwrapp_pimpl_base_h_ + +#ifdef HAVE_BOOST_POOL_SINGLETON_POOL_HPP + #include <cassert> + #include <boost/pool/singleton_pool.hpp> +#endif // HAVE_BOOST_POOL_SINGLETON_POOL_HPP + +namespace xml +{ + +// Base class for all pimpl classes. Uses custom pool allocator for better +// performance. Usage: derive your class FooImpl from pimpl_base<FooImpl>. +template<typename T> +class pimpl_base +{ +#ifdef HAVE_BOOST_POOL_SINGLETON_POOL_HPP +public: + struct xmlwrapp_pool_tag {}; + + // NB: we can't typedef the pool type as pimpl_base<T> subtype, + // because sizeof(T) is unknown (incomplete type) at this point, + // but it's OK to use the type in implementation of operators + // (compiled only when T, and so sizeof(T), is known) + #define XMLWRAPP_PIMPL_ALLOCATOR_TYPE(T) \ + boost::singleton_pool<xmlwrapp_pool_tag, sizeof(T)> + + static void* operator new(size_t size) + { + assert( size == sizeof(T) ); + return XMLWRAPP_PIMPL_ALLOCATOR_TYPE(T)::malloc(); + } + + static void operator delete(void *ptr, size_t size) + { + assert( size == sizeof(T) ); + if ( ptr ) + XMLWRAPP_PIMPL_ALLOCATOR_TYPE(T)::free(ptr); + } +#endif // HAVE_BOOST_POOL_SINGLETON_POOL_HPP +}; + +} // namespace xml + +#endif // _xmlwrapp_pimpl_base_h_ Property changes on: trunk/src/libxml/pimpl_base.h ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2008-12-22 00:55:30
|
Revision: 122 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=122&view=rev Author: vaclavslavik Date: 2008-12-22 00:55:26 +0000 (Mon, 22 Dec 2008) Log Message: ----------- move implementation code (helpers, pimpls etc.) into xml::impl namespace; leave only public API in xml namespace Modified Paths: -------------- trunk/include/xmlwrapp/_cbfo.h trunk/include/xmlwrapp/attributes.h trunk/include/xmlwrapp/document.h trunk/include/xmlwrapp/event_parser.h trunk/include/xmlwrapp/node.h trunk/include/xmlwrapp/tree_parser.h trunk/src/libxml/ait_impl.cxx trunk/src/libxml/ait_impl.h trunk/src/libxml/attributes.cxx trunk/src/libxml/document.cxx trunk/src/libxml/dtd_impl.cxx trunk/src/libxml/dtd_impl.h trunk/src/libxml/event_parser.cxx trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx trunk/src/libxml/node_iterator.h trunk/src/libxml/node_manip.cxx trunk/src/libxml/node_manip.h trunk/src/libxml/pimpl_base.h trunk/src/libxml/tree_parser.cxx trunk/src/libxml/utility.cxx trunk/src/libxml/utility.h trunk/src/libxslt/result.h trunk/src/libxslt/stylesheet.cxx Modified: trunk/include/xmlwrapp/_cbfo.h =================================================================== --- trunk/include/xmlwrapp/_cbfo.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/_cbfo.h 2008-12-22 00:55:26 UTC (rev 122) @@ -36,8 +36,11 @@ #include <functional> namespace xml { - class node; +class node; + +namespace impl { + struct cbfo_node_compare : public std::binary_function<xml::node, xml::node, bool> { virtual ~cbfo_node_compare (void) { } virtual bool operator() (const xml::node &lhs, const xml::node &rhs) = 0; @@ -51,5 +54,8 @@ T &t_; }; -} + +} // namespace impl + +} // namespace xml #endif Modified: trunk/include/xmlwrapp/attributes.h =================================================================== --- trunk/include/xmlwrapp/attributes.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/attributes.h 2008-12-22 00:55:26 UTC (rev 122) @@ -49,8 +49,11 @@ // forward declarations class node; + +namespace impl { class ait_impl; struct node_impl; +} /** * The xml::attributes class is used to access all the attributes of one @@ -154,7 +157,7 @@ void set_data (void *node, void *prop); void set_data (const char *name, const char *value, bool); - friend class ait_impl; + friend class impl::ait_impl; }; // end xml::attributes::attr class /** @@ -185,7 +188,7 @@ friend bool operator== (const iterator &lhs, const iterator &rhs); friend bool operator!= (const iterator &lhs, const iterator &rhs); private: - ait_impl *pimpl_; + impl::ait_impl *pimpl_; iterator (void *node, void *prop); iterator (const char *name, const char *value, bool); void swap (iterator &other); @@ -223,7 +226,7 @@ friend bool operator== (const const_iterator &lhs, const const_iterator &rhs); friend bool operator!= (const const_iterator &lhs, const const_iterator &rhs); private: - ait_impl *pimpl_; + impl::ait_impl *pimpl_; const_iterator (void *node, void *prop); const_iterator (const char *name, const char *value, bool); void swap (const_iterator &other); @@ -378,7 +381,7 @@ void set_data (void *node); void* get_data (void); - friend struct node_impl; + friend struct impl::node_impl; friend class node; }; // end xml::attributes class Modified: trunk/include/xmlwrapp/document.h =================================================================== --- trunk/include/xmlwrapp/document.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/document.h 2008-12-22 00:55:26 UTC (rev 122) @@ -48,15 +48,20 @@ // forward declaration namespace xslt { + class stylesheet; + namespace impl { class result; - class stylesheet; + } } // end xslt namespace namespace xml { // forward declarations class tree_parser; + +namespace impl { struct doc_impl; +} /** * The xml::document class is used to hold the XML tree and various bits of @@ -534,9 +539,9 @@ friend std::ostream& operator<< (std::ostream &stream, const document &doc); private: - doc_impl *pimpl_; + impl::doc_impl *pimpl_; void set_doc_data (void *data); - void set_doc_data_from_xslt (void *data, xslt::result *xr); + void set_doc_data_from_xslt (void *data, xslt::impl::result *xr); void* get_doc_data (void); void* get_doc_data_read_only (void) const; void* release_doc_data (void); Modified: trunk/include/xmlwrapp/event_parser.h =================================================================== --- trunk/include/xmlwrapp/event_parser.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/event_parser.h 2008-12-22 00:55:26 UTC (rev 122) @@ -47,8 +47,12 @@ #include <map> namespace xml { - struct epimpl; // forward declaration of private implementation + +namespace impl { +struct epimpl; // forward declaration of private implementation +} + /** * The xml::event_parser is used to parse an XML document by calling member * functions when certain things in the XML document are parsed. In order to @@ -255,8 +259,8 @@ //#################################################################### void set_error_message (const char *message); private: - friend struct epimpl; - epimpl *pimpl_; // private implementation + friend struct impl::epimpl; + impl::epimpl *pimpl_; // private implementation /* * Don't allow anyone to copy construct an event_parser or to call the Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/node.h 2008-12-22 00:55:26 UTC (rev 122) @@ -53,10 +53,16 @@ // forward declarations class document; class attributes; + +namespace impl { +class node_iterator; struct node_impl; +struct doc_impl; struct nipimpl; struct node_cmp; +} + /** * The xml::node class is used to hold information about one XML node. This * includes the name of the node, the namespace of the node and attributes @@ -428,7 +434,7 @@ friend bool operator== (const iterator &lhs, const iterator &rhs); friend bool operator!= (const iterator &lhs, const iterator &rhs); private: - nipimpl *pimpl_; + impl::nipimpl *pimpl_; explicit iterator (void *data); void* get_raw_node (void); void swap (iterator &other); @@ -468,7 +474,7 @@ friend bool operator== (const const_iterator &lhs, const const_iterator &rhs); friend bool operator!= (const const_iterator &lhs, const const_iterator &rhs); private: - nipimpl *pimpl_; + impl::nipimpl *pimpl_; explicit const_iterator (void *data); void* get_raw_node (void); void swap (const_iterator &other); @@ -776,7 +782,7 @@ **/ //#################################################################### template <typename T> void sort (T compare) - { sort_callback<T> cb(compare); sort_fo(cb); } + { impl::sort_callback<T> cb(compare); sort_fo(cb); } //#################################################################### /** @@ -802,7 +808,7 @@ friend std::ostream& operator<< (std::ostream &stream, const node &n); private: - node_impl *pimpl_; + impl::node_impl *pimpl_; // private ctor to create uninitialized instance explicit node (int); @@ -811,12 +817,12 @@ void* get_node_data (void); void* release_node_data (void); friend class tree_parser; - friend class node_iterator; + friend class impl::node_iterator; friend class document; - friend struct doc_impl; - friend struct node_cmp; + friend struct impl::doc_impl; + friend struct impl::node_cmp; - void sort_fo (cbfo_node_compare &fo); + void sort_fo (impl::cbfo_node_compare &fo); }; // end xml::node class } // end xml namespace Modified: trunk/include/xmlwrapp/tree_parser.h =================================================================== --- trunk/include/xmlwrapp/tree_parser.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/include/xmlwrapp/tree_parser.h 2008-12-22 00:55:26 UTC (rev 122) @@ -47,8 +47,10 @@ namespace xml { // forward declarations +class document; +namespace impl { struct tree_impl; -class document; +} /** * The xml::tree_parser class is used to parse an XML document and generate @@ -166,7 +168,7 @@ //#################################################################### const xml::document& get_document (void) const; private: - tree_impl *pimpl_; // private implementation + impl::tree_impl *pimpl_; // private implementation /* * Don't allow anyone to copy construct a xml::tree_parser or allow the Modified: trunk/src/libxml/ait_impl.cxx =================================================================== --- trunk/src/libxml/ait_impl.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/ait_impl.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -31,7 +31,7 @@ */ /** @file - * This file implements the xml::ait_impl, xml::attributes::iterator, + * This file implements the ait_impl, xml::attributes::iterator, * xml::attributes::const_iterator and xml::attributes::attr classes. **/ @@ -47,16 +47,19 @@ // libxml2 includes #include <libxml/tree.h> +using namespace xml; +using namespace xml::impl; + /* - * First we have the xml::ait_impl class. + * First we have the ait_impl class. */ //#################################################################### -xml::ait_impl::ait_impl (xmlNodePtr node, xmlAttrPtr prop) : xmlnode_(node), xmlattr_(prop), fake_(false) { +ait_impl::ait_impl (xmlNodePtr node, xmlAttrPtr prop) : xmlnode_(node), xmlattr_(prop), fake_(false) { attr_.set_data(xmlnode_, xmlattr_); } //#################################################################### -xml::ait_impl::ait_impl (const char *name, const char *value, bool) : xmlnode_(0), xmlattr_(0), fake_(true) { +ait_impl::ait_impl (const char *name, const char *value, bool) : xmlnode_(0), xmlattr_(0), fake_(true) { /* * in this constructor and in the functions to follow, the last * parameter, the bool, is only used to create a unique signature @@ -64,12 +67,12 @@ attr_.set_data(name, value, true); } //#################################################################### -xml::ait_impl::ait_impl (const ait_impl &other) : xmlnode_(other.xmlnode_), xmlattr_(other.xmlattr_), fake_(other.fake_) { +ait_impl::ait_impl (const ait_impl &other) : xmlnode_(other.xmlnode_), xmlattr_(other.xmlattr_), fake_(other.fake_) { if (fake_) attr_.set_data(other.attr_.get_name(), other.attr_.get_value(), true); else attr_.set_data(xmlnode_, xmlattr_); } //#################################################################### -xml::ait_impl& xml::ait_impl::operator= (const ait_impl &other) { +ait_impl& ait_impl::operator= (const ait_impl &other) { ait_impl tmp(other); std::swap(xmlnode_, tmp.xmlnode_); @@ -80,15 +83,15 @@ return *this; } //#################################################################### -xml::attributes::attr* xml::ait_impl::get (void) { +xml::attributes::attr* ait_impl::get (void) { return &attr_; } //#################################################################### -xmlAttrPtr xml::ait_impl::get_raw_attr (void) { +xmlAttrPtr ait_impl::get_raw_attr (void) { return xmlattr_; } //#################################################################### -xml::ait_impl& xml::ait_impl::operator++ (void) { +ait_impl& ait_impl::operator++ (void) { if (xmlattr_) xmlattr_ = xmlattr_->next; else fake_ = false; @@ -96,7 +99,7 @@ return *this; } //#################################################################### -xml::ait_impl xml::ait_impl::operator++ (int) { +ait_impl ait_impl::operator++ (int) { ait_impl tmp(xmlnode_, xmlattr_); ++(*this); return tmp; @@ -288,6 +291,8 @@ //#################################################################### namespace xml { + +namespace impl { //#################################################################### xmlAttrPtr find_prop (xmlNodePtr xmlnode, const char *name) { xmlAttrPtr prop = xmlnode->properties; @@ -320,16 +325,9 @@ return 0; } +} + //#################################################################### - bool operator== (const ait_impl &lhs, const ait_impl &rhs) { - if (lhs.fake_ || rhs.fake_) return false; - return lhs.xmlattr_ == rhs.xmlattr_; - } - //#################################################################### - bool operator!= (const ait_impl &lhs, const ait_impl &rhs) { - return !(lhs == rhs); - } - //#################################################################### bool operator== (const attributes::iterator &lhs, const attributes::iterator &rhs) { return *(lhs.pimpl_) == *(rhs.pimpl_); } @@ -346,5 +344,16 @@ return !(lhs == rhs); } //#################################################################### +namespace impl { + bool operator== (const ait_impl &lhs, const ait_impl &rhs) { + if (lhs.fake_ || rhs.fake_) return false; + return lhs.xmlattr_ == rhs.xmlattr_; + } + //#################################################################### + bool operator!= (const ait_impl &lhs, const ait_impl &rhs) { + return !(lhs == rhs); + } } + //#################################################################### +} //#################################################################### Modified: trunk/src/libxml/ait_impl.h =================================================================== --- trunk/src/libxml/ait_impl.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/ait_impl.h 2008-12-22 00:55:26 UTC (rev 122) @@ -47,6 +47,8 @@ namespace xml { +namespace impl { + /** * the class that does all the work behind xml::attributes::iterator and * xml::attributes::const_iterator. @@ -78,5 +80,7 @@ xmlAttrPtr find_prop (xmlNodePtr xmlnode, const char *name); xmlAttributePtr find_default_prop (xmlNodePtr xmlnode, const char *name); +} // end impl namespace + } // end xml namespace #endif Modified: trunk/src/libxml/attributes.cxx =================================================================== --- trunk/src/libxml/attributes.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/attributes.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -46,8 +46,11 @@ // libxml2 includes #include <libxml/tree.h> +using namespace xml; +using namespace xml::impl; + //#################################################################### -struct xml::attributes::pimpl : public xml::pimpl_base<xml::attributes::pimpl> { +struct xml::attributes::pimpl : public pimpl_base<xml::attributes::pimpl> { //#################################################################### pimpl (void) : owner_(true) { xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); Modified: trunk/src/libxml/document.cxx =================================================================== --- trunk/src/libxml/document.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/document.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -56,12 +56,16 @@ // bring in private libxslt stuff (see bug #1927398) #include "../libxslt/result.h" +using namespace xml; +using namespace xml::impl; + + //#################################################################### namespace { const char const_default_encoding[] = "ISO-8859-1"; } //#################################################################### -struct xml::doc_impl { +struct xml::impl::doc_impl { //#################################################################### doc_impl (void) : doc_(0), xslt_result_(0) { xmlDocPtr tmpdoc; @@ -123,7 +127,7 @@ //#################################################################### xmlDocPtr doc_; - xslt::result *xslt_result_; + xslt::impl::result *xslt_result_; node root_; std::string version_; mutable std::string encoding_; @@ -259,17 +263,17 @@ //#################################################################### void xml::document::push_back (const node &child) { if (child.get_type() == node::type_element) throw std::runtime_error("xml::document::push_back can't take element type nodes"); - xmlwrapp::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(child).get_node_data())); + xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(child).get_node_data())); } //#################################################################### xml::node::iterator xml::document::insert (const node &n) { if (n.get_type() == node::type_element) throw std::runtime_error("xml::document::insert can't take element type nodes"); - return node::iterator(xmlwrapp::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); + return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); } //#################################################################### xml::node::iterator xml::document::insert (node::iterator position, const node &n) { if (n.get_type() == node::type_element) throw std::runtime_error("xml::document::insert can't take element type nodes"); - return node::iterator(xmlwrapp::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), static_cast<xmlNodePtr>(position.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); + return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), static_cast<xmlNodePtr>(position.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); } //#################################################################### xml::node::iterator xml::document::replace (node::iterator old_node, const node &new_node) { @@ -277,12 +281,12 @@ throw std::runtime_error("xml::document::replace can't replace element type nodes"); } - return node::iterator(xmlwrapp::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(new_node).get_node_data()))); + return node::iterator(xml::impl::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(new_node).get_node_data()))); } //#################################################################### xml::node::iterator xml::document::erase (node::iterator to_erase) { if (to_erase->get_type() == node::type_element) throw std::runtime_error("xml::document::erase can't erase element type nodes"); - return node::iterator(xmlwrapp::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); + return node::iterator(xml::impl::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); } //#################################################################### xml::node::iterator xml::document::erase (node::iterator first, node::iterator last) { @@ -330,7 +334,7 @@ pimpl_->xslt_result_ = 0; } //#################################################################### -void xml::document::set_doc_data_from_xslt (void *data, xslt::result *xr) { +void xml::document::set_doc_data_from_xslt (void *data, xslt::impl::result *xr) { // this document came from a XSLT transformation pimpl_->set_doc_data(static_cast<xmlDocPtr>(data), false); pimpl_->xslt_result_ = xr; Modified: trunk/src/libxml/dtd_impl.cxx =================================================================== --- trunk/src/libxml/dtd_impl.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/dtd_impl.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -31,7 +31,7 @@ */ /** @file - * This file implements the xml::dtd_impl class. + * This file implements the dtd_impl class. **/ // xmlwrapp includes @@ -47,26 +47,29 @@ #include <libxml/valid.h> #include <libxml/tree.h> +using namespace xml; +using namespace xml::impl; + //#################################################################### namespace { extern "C" void dtd_error (void *ctxt, const char *message, ...); extern "C" void dtd_warning (void *ctxt, const char*, ...); } // end anonymous namespace //#################################################################### -xml::dtd_impl::dtd_impl (const char *filename) : warnings_(0), dtd_(0) { +dtd_impl::dtd_impl (const char *filename) : warnings_(0), dtd_(0) { if ( (dtd_ = xmlParseDTD(0, reinterpret_cast<const xmlChar*>(filename))) == 0) { error_ = "unable to parse DTD "; error_ += filename; } } //#################################################################### -xml::dtd_impl::dtd_impl (void) : warnings_(0), dtd_(0) { +dtd_impl::dtd_impl (void) : warnings_(0), dtd_(0) { } //#################################################################### -xml::dtd_impl::~dtd_impl (void) { +dtd_impl::~dtd_impl (void) { if (dtd_) xmlFreeDtd(dtd_); } //#################################################################### -void xml::dtd_impl::init_ctxt (void) { +void dtd_impl::init_ctxt (void) { std::memset(&vctxt_, 0, sizeof(vctxt_)); vctxt_.userData = this; @@ -74,14 +77,14 @@ vctxt_.warning = dtd_warning; } //#################################################################### -bool xml::dtd_impl::validate (xmlDocPtr xmldoc) { +bool dtd_impl::validate (xmlDocPtr xmldoc) { init_ctxt(); if (dtd_) return xmlValidateDtd(&vctxt_, xmldoc, dtd_) != 0; else return xmlValidateDocument(&vctxt_, xmldoc) != 0; } //#################################################################### -xmlDtdPtr xml::dtd_impl::release (void) { +xmlDtdPtr dtd_impl::release (void) { xmlDtdPtr xmldtd = dtd_; dtd_ = 0; return xmldtd; @@ -90,16 +93,16 @@ namespace { //#################################################################### extern "C" void dtd_error (void *ctxt, const char *message, ...) { - xml::dtd_impl *dtd = static_cast<xml::dtd_impl*>(ctxt); + dtd_impl *dtd = static_cast<dtd_impl*>(ctxt); va_list ap; va_start(ap, message); - xml::printf2string(dtd->error_, message, ap); + printf2string(dtd->error_, message, ap); va_end(ap); } //#################################################################### extern "C" void dtd_warning (void *ctxt, const char*, ...) { - xml::dtd_impl *dtd = static_cast<xml::dtd_impl*>(ctxt); + dtd_impl *dtd = static_cast<dtd_impl*>(ctxt); ++dtd->warnings_; } //#################################################################### Modified: trunk/src/libxml/dtd_impl.h =================================================================== --- trunk/src/libxml/dtd_impl.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/dtd_impl.h 2008-12-22 00:55:26 UTC (rev 122) @@ -47,6 +47,8 @@ namespace xml { +namespace impl { + class dtd_impl { public: /* @@ -83,7 +85,9 @@ dtd_impl (const dtd_impl&); dtd_impl& operator= (const dtd_impl&); void init_ctxt (void); -}; // end xml::dtd_impl class +}; // end xml::impl::dtd_impl class +} // end impl namespace + } // end xml namespace #endif Modified: trunk/src/libxml/event_parser.cxx =================================================================== --- trunk/src/libxml/event_parser.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/event_parser.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -55,6 +55,9 @@ #include <iostream> #include <fstream> +using namespace xml; +using namespace xml::impl; + //#################################################################### /* * This is a hack to fix a problem with a change in the libxml2 API for @@ -80,7 +83,7 @@ extern "C" void cb_ignore (void*, const xmlChar*, int); } // end anonymous namespace //#################################################################### -struct xml::epimpl { +struct xml::impl::epimpl { public: epimpl (event_parser &parent); ~epimpl (void); @@ -168,7 +171,7 @@ pimpl_->last_error_message_ = message; } //#################################################################### -xml::epimpl::epimpl (event_parser &parent) +epimpl::epimpl (event_parser &parent) : parser_status_(true), parent_(parent) { std::memset(&sax_handler_, 0, sizeof(sax_handler_)); @@ -191,11 +194,11 @@ } } //#################################################################### -xml::epimpl::~epimpl (void) { +epimpl::~epimpl (void) { xmlFreeParserCtxt(parser_context_); } //#################################################################### -void xml::epimpl::event_start_element (const xmlChar *tag, const xmlChar **props) { +void epimpl::event_start_element (const xmlChar *tag, const xmlChar **props) { if (!parser_status_) return; try { @@ -214,7 +217,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_end_element (const xmlChar *tag) { +void epimpl::event_end_element (const xmlChar *tag) { if (!parser_status_) return; try { @@ -226,7 +229,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_text (const xmlChar *text, int length) { +void epimpl::event_text (const xmlChar *text, int length) { if (!parser_status_) return; try { @@ -238,7 +241,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_pi (const xmlChar *target, const xmlChar *data) { +void epimpl::event_pi (const xmlChar *target, const xmlChar *data) { if (!parser_status_) return; try { @@ -251,7 +254,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_comment (const xmlChar *text) { +void epimpl::event_comment (const xmlChar *text) { if (!parser_status_) return; try { @@ -263,7 +266,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_cdata (const xmlChar *text, int length) { +void epimpl::event_cdata (const xmlChar *text, int length) { if (!parser_status_) return; try { @@ -275,7 +278,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_warning (const std::string &message) { +void epimpl::event_warning (const std::string &message) { if (!parser_status_) return; try { @@ -287,7 +290,7 @@ if (!parser_status_) xmlStopParser(parser_context_); } //#################################################################### -void xml::epimpl::event_error (const std::string &message) { +void epimpl::event_error (const std::string &message) { try { last_error_message_ = message; } catch ( ... ) { } parser_status_ = false; xmlStopParser(parser_context_); @@ -299,32 +302,32 @@ { return xmlGetPredefinedEntity(name); } //#################################################################### extern "C" void cb_start_element (void *parser, const xmlChar *tag, const xmlChar **props) - { static_cast<xml::epimpl*>(parser)->event_start_element(tag, props); } + { static_cast<epimpl*>(parser)->event_start_element(tag, props); } //#################################################################### extern "C" void cb_end_element (void *parser, const xmlChar *tag) - { static_cast<xml::epimpl*>(parser)->event_end_element(tag); } + { static_cast<epimpl*>(parser)->event_end_element(tag); } //#################################################################### extern "C" void cb_text (void *parser, const xmlChar *text, int length) - { static_cast<xml::epimpl*>(parser)->event_text(text, length); } + { static_cast<epimpl*>(parser)->event_text(text, length); } //#################################################################### extern "C" void cb_pi (void *parser, const xmlChar *target, const xmlChar *data) - { static_cast<xml::epimpl*>(parser)->event_pi(target, data); } + { static_cast<epimpl*>(parser)->event_pi(target, data); } //#################################################################### extern "C" void cb_comment (void *parser, const xmlChar *text) - { static_cast<xml::epimpl*>(parser)->event_comment(text); } + { static_cast<epimpl*>(parser)->event_comment(text); } //#################################################################### extern "C" void cb_cdata (void *parser, const xmlChar *text, int length) - { static_cast<xml::epimpl*>(parser)->event_cdata(text, length); } + { static_cast<epimpl*>(parser)->event_cdata(text, length); } //#################################################################### extern "C" void cb_warning (void *parser, const char *message, ...) { std::string complete_message; va_list ap; va_start(ap, message); - xml::printf2string(complete_message, message, ap); + printf2string(complete_message, message, ap); va_end(ap); - static_cast<xml::epimpl*>(parser)->event_warning(complete_message); + static_cast<epimpl*>(parser)->event_warning(complete_message); } //#################################################################### extern "C" void cb_error (void *parser, const char *message, ...) { @@ -332,10 +335,10 @@ va_list ap; va_start(ap, message); - xml::printf2string(complete_message, message, ap); + printf2string(complete_message, message, ap); va_end(ap); - static_cast<xml::epimpl*>(parser)->event_error(complete_message); + static_cast<epimpl*>(parser)->event_error(complete_message); } //#################################################################### extern "C" void cb_ignore (void*, const xmlChar*, int) { Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/node.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -58,8 +58,11 @@ #include <libxml/tree.h> #include <libxml/parser.h> +using namespace xml; +using namespace xml::impl; + //#################################################################### -struct xml::node_impl : public xml::pimpl_base<xml::node_impl> { +struct xml::impl::node_impl : public pimpl_base<xml::impl::node_impl> { //#################################################################### node_impl (void) : xmlnode_(0), owner_(true), attrs_(0) { } @@ -80,7 +83,7 @@ std::string tmp_string; }; //#################################################################### -struct xml::node_cmp : public std::binary_function<xmlNodePtr, xmlNodePtr, bool> { +struct xml::impl::node_cmp : public std::binary_function<xmlNodePtr, xmlNodePtr, bool> { //#################################################################### node_cmp (cbfo_node_compare &cb) : cb_(cb) { } //#################################################################### @@ -138,11 +141,11 @@ xmlAttrPtr attr_l, attr_r; xmlAttributePtr dtd_l(0), dtd_r(0); - attr_l = xml::find_prop(lhs, name_); - if (attr_l == 0 && (dtd_l = xml::find_default_prop(lhs, name_)) == 0) return true; + attr_l = find_prop(lhs, name_); + if (attr_l == 0 && (dtd_l = find_default_prop(lhs, name_)) == 0) return true; - attr_r = xml::find_prop(rhs, name_); - if (attr_r == 0 && (dtd_r = xml::find_default_prop(rhs, name_)) == 0) return false; + attr_r = find_prop(rhs, name_); + if (attr_r == 0 && (dtd_r = find_default_prop(rhs, name_)) == 0) return false; xmlChar *value_l, *value_r; @@ -366,7 +369,7 @@ } //#################################################################### void xml::node::push_back (const node &child) { - xmlwrapp::node_insert(pimpl_->xmlnode_, 0, child.pimpl_->xmlnode_); + xml::impl::node_insert(pimpl_->xmlnode_, 0, child.pimpl_->xmlnode_); } //#################################################################### xml::node::size_type xml::node::size (void) const { @@ -436,19 +439,19 @@ } //#################################################################### xml::node::iterator xml::node::insert (const node &n) { - return iterator(xmlwrapp::node_insert(pimpl_->xmlnode_, 0, n.pimpl_->xmlnode_)); + return iterator(xml::impl::node_insert(pimpl_->xmlnode_, 0, n.pimpl_->xmlnode_)); } //#################################################################### xml::node::iterator xml::node::insert (iterator position, const node &n) { - return iterator(xmlwrapp::node_insert(pimpl_->xmlnode_, static_cast<xmlNodePtr>(position.get_raw_node()), n.pimpl_->xmlnode_)); + return iterator(xml::impl::node_insert(pimpl_->xmlnode_, static_cast<xmlNodePtr>(position.get_raw_node()), n.pimpl_->xmlnode_)); } //#################################################################### xml::node::iterator xml::node::replace (iterator old_node, const node &new_node) { - return iterator(xmlwrapp::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), new_node.pimpl_->xmlnode_)); + return iterator(xml::impl::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), new_node.pimpl_->xmlnode_)); } //#################################################################### xml::node::iterator xml::node::erase (iterator to_erase) { - return iterator(xmlwrapp::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); + return iterator(xml::impl::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); } //#################################################################### xml::node::iterator xml::node::erase (iterator first, iterator last) { Modified: trunk/src/libxml/node_iterator.cxx =================================================================== --- trunk/src/libxml/node_iterator.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/node_iterator.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -31,7 +31,7 @@ */ /** @file - * This file implements the xml::node_iterator class for libxml2. + * This file implements the xml::impl::node_iterator class for libxml2. **/ // definition include @@ -47,8 +47,11 @@ // libxml includes #include <libxml/tree.h> +using namespace xml; +using namespace xml::impl; + // xml::node::iterator pimpl -struct xml::nipimpl : public xml::pimpl_base<xml::nipimpl> { +struct xml::impl::nipimpl : public pimpl_base<xml::impl::nipimpl> { node_iterator it; nipimpl (void) {}; @@ -57,27 +60,27 @@ }; /* - * xml::node_iterator Real Iterator class + * xml::impl::node_iterator Real Iterator class */ //#################################################################### -xml::node* xml::node_iterator::get (void) const { +xml::node* xml::impl::node_iterator::get (void) const { fake_node_.set_node_data(node_); return &fake_node_; } //#################################################################### -xml::node_iterator& xml::node_iterator::operator++ (void) { +xml::impl::node_iterator& xml::impl::node_iterator::operator++ (void) { node_ = node_->next; return *this; } //#################################################################### -xml::node_iterator xml::node_iterator::operator++ (int) { +xml::impl::node_iterator xml::impl::node_iterator::operator++ (int) { node_iterator old(*this); ++(*this); return old; } //#################################################################### -xmlNodePtr xml::node_iterator::get_raw_node (void) { +xmlNodePtr xml::impl::node_iterator::get_raw_node (void) { return node_; } //#################################################################### @@ -196,6 +199,8 @@ } //#################################################################### namespace xml { + +namespace impl { bool operator== (const node_iterator &lhs, const node_iterator &rhs) { return lhs.node_ == rhs.node_; } @@ -203,6 +208,7 @@ bool operator!= (const node_iterator &lhs, const node_iterator &rhs) { return !(lhs == rhs); } +} bool operator== (const node::iterator &lhs, const node::iterator &rhs) { return lhs.pimpl_->it == rhs.pimpl_->it; Modified: trunk/src/libxml/node_iterator.h =================================================================== --- trunk/src/libxml/node_iterator.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/node_iterator.h 2008-12-22 00:55:26 UTC (rev 122) @@ -31,7 +31,7 @@ */ /** @file - * This file defines the xml::node_iterator class for libxml2. + * This file defines the xml::impl::node_iterator class for libxml2. **/ #ifndef _xmlwrapp_node_iterator_h_ @@ -45,6 +45,8 @@ namespace xml { +namespace impl { + // base iterator class class node_iterator { public: @@ -65,7 +67,9 @@ private: mutable node fake_node_; xmlNodePtr node_; -}; // end xml::node_iterator class +}; // end xml::impl::node_iterator class +} // end impl namespace + } // end xml namespace #endif Modified: trunk/src/libxml/node_manip.cxx =================================================================== --- trunk/src/libxml/node_manip.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/node_manip.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -45,7 +45,7 @@ #include <libxml/tree.h> //#################################################################### -xmlNodePtr xmlwrapp::node_insert (xmlNodePtr parent, xmlNodePtr before, xmlNodePtr to_add) { +xmlNodePtr xml::impl::node_insert (xmlNodePtr parent, xmlNodePtr before, xmlNodePtr to_add) { xmlNodePtr new_xml_node = xmlCopyNode(to_add, 1); if (!new_xml_node) throw std::bad_alloc(); @@ -64,7 +64,7 @@ return new_xml_node; } //#################################################################### -xmlNodePtr xmlwrapp::node_replace (xmlNodePtr old_node, xmlNodePtr new_node) { +xmlNodePtr xml::impl::node_replace (xmlNodePtr old_node, xmlNodePtr new_node) { xmlNodePtr copied_node = xmlCopyNode(new_node, 1); if (!copied_node) throw std::bad_alloc(); @@ -81,7 +81,7 @@ return copied_node; } //#################################################################### -xmlNodePtr xmlwrapp::node_erase (xmlNodePtr to_erase) { +xmlNodePtr xml::impl::node_erase (xmlNodePtr to_erase) { xmlNodePtr after = to_erase->next; xmlUnlinkNode(to_erase); Modified: trunk/src/libxml/node_manip.h =================================================================== --- trunk/src/libxml/node_manip.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/node_manip.h 2008-12-22 00:55:26 UTC (rev 122) @@ -41,8 +41,10 @@ // libxml includes #include <libxml/tree.h> -namespace xmlwrapp { +namespace xml { +namespace impl { + //#################################################################### /** * Insert a node somewhere in the child list of a parent node. @@ -80,4 +82,6 @@ //#################################################################### xmlNodePtr node_erase (xmlNodePtr to_erase); } + +} #endif Modified: trunk/src/libxml/pimpl_base.h =================================================================== --- trunk/src/libxml/pimpl_base.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/pimpl_base.h 2008-12-22 00:55:26 UTC (rev 122) @@ -41,6 +41,9 @@ namespace xml { +namespace impl +{ + // Base class for all pimpl classes. Uses custom pool allocator for better // performance. Usage: derive your class FooImpl from pimpl_base<FooImpl>. template<typename T> @@ -72,6 +75,8 @@ #endif // HAVE_BOOST_POOL_SINGLETON_POOL_HPP }; +} // namespace impl + } // namespace xml #endif // _xmlwrapp_pimpl_base_h_ Modified: trunk/src/libxml/tree_parser.cxx =================================================================== --- trunk/src/libxml/tree_parser.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/tree_parser.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -52,6 +52,9 @@ #include <string> #include <memory> +using namespace xml; +using namespace xml::impl; + //#################################################################### /* * This is a hack to fix a problem with a change in the libxml2 API for @@ -70,7 +73,7 @@ extern "C" void cb_tree_ignore (void*, const xmlChar*, int); } //#################################################################### -struct xml::tree_impl { +struct xml::impl::tree_impl { tree_impl (void) : last_error_(const_default_error), warnings_(false), okay_(false) { std::memset(&sax_, 0, sizeof(sax_)); initxmlDefaultSAXHandler(&sax_, 0); @@ -166,12 +169,12 @@ try { xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(v); - xml::tree_impl *p = static_cast<xml::tree_impl*>(ctxt->_private); + tree_impl *p = static_cast<tree_impl*>(ctxt->_private); if (!p) return; // handle bug in older versions of libxml va_list ap; va_start(ap, message); - xml::printf2string(p->last_error_, message, ap); + printf2string(p->last_error_, message, ap); va_end(ap); xmlStopParser(ctxt); @@ -182,7 +185,7 @@ try { xmlParserCtxtPtr ctxt = static_cast<xmlParserCtxtPtr>(v); - xml::tree_impl *p = static_cast<xml::tree_impl*>(ctxt->_private); + tree_impl *p = static_cast<tree_impl*>(ctxt->_private); if (!p) return; // handle bug in older versions of libxml p->warnings_ = true; Modified: trunk/src/libxml/utility.cxx =================================================================== --- trunk/src/libxml/utility.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/utility.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -44,6 +44,8 @@ namespace xml { +namespace impl { + //#################################################################### void printf2string (std::string &s, const char *message, va_list ap) { char buffer[512]; @@ -60,4 +62,6 @@ } //#################################################################### +} // end impl namespace + } // end xml namespace Modified: trunk/src/libxml/utility.h =================================================================== --- trunk/src/libxml/utility.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxml/utility.h 2008-12-22 00:55:26 UTC (rev 122) @@ -42,6 +42,8 @@ namespace xml { +namespace impl { + /* * exception safe wrapper around xmlChar*s that are returned from some * of the libxml functions that the user must free. @@ -62,5 +64,7 @@ void printf2string (std::string &s, const char *message, va_list ap); +} // end impl namespace + } // end xml namespace #endif Modified: trunk/src/libxslt/result.h =================================================================== --- trunk/src/libxslt/result.h 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxslt/result.h 2008-12-22 00:55:26 UTC (rev 122) @@ -45,6 +45,8 @@ namespace xslt { +namespace impl { + /** * The xslt::result class is used as a callback by xml::document to allow * special treatment of XML documents which were created by XSLT. @@ -90,6 +92,8 @@ virtual ~result (void) { } }; +} // end impl namespace + } // end xslt namespace #endif Modified: trunk/src/libxslt/stylesheet.cxx =================================================================== --- trunk/src/libxslt/stylesheet.cxx 2008-12-21 15:56:37 UTC (rev 121) +++ trunk/src/libxslt/stylesheet.cxx 2008-12-22 00:55:26 UTC (rev 122) @@ -60,7 +60,7 @@ // implementation of xslt::result using xslt::stylesheet: we pass this object // to xml::document for the documents obtained via XSLT so that some operations // (currently only saving) could be done differently for them -class result_impl : public xslt::result { +class result_impl : public xslt::impl::result { public: // We don't own the pointers given to us, their lifetime must be greater // than the lifetime of this object. @@ -73,7 +73,7 @@ if (xsltSaveResultToString(&xml_string, &xml_string_length, doc_, ss_) >= 0) { - xml::xmlchar_helper helper(xml_string); + xml::impl::xmlchar_helper helper(xml_string); if (xml_string_length) s.assign(helper.get(), xml_string_length); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-01-05 23:33:55
|
Revision: 124 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=124&view=rev Author: vaclavslavik Date: 2009-01-05 23:33:51 +0000 (Mon, 05 Jan 2009) Log Message: ----------- added xml::node::set_namespace() too Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-01-03 12:08:34 UTC (rev 123) +++ trunk/NEWS 2009-01-05 23:33:51 UTC (rev 124) @@ -25,7 +25,7 @@ PDF version of the manual is no longer provided, use HTML documentation included with xmlwrapp source distribution. - Added xml::node::get_namespace() function. + Added xml::node::get_namespace() and set_namespace() functions. Added new constructor to the xml::node class for creating text nodes, using xml::node::text helper struct. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2009-01-03 12:08:34 UTC (rev 123) +++ trunk/include/xmlwrapp/node.h 2009-01-05 23:33:51 UTC (rev 124) @@ -374,6 +374,17 @@ //#################################################################### /** + * Sets the namespace of this xml::node. + * + * @param href URI of the namespace to associate with the node. + * @author Vaclav Slavik + * @since 0.6.0 + **/ + //#################################################################### + void set_namespace(const char *href); + + //#################################################################### + /** * Find out if this node is a text node or sometiming like a text node, * CDATA for example. * Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2009-01-03 12:08:34 UTC (rev 123) +++ trunk/src/libxml/node.cxx 2009-01-05 23:33:51 UTC (rev 124) @@ -364,6 +364,10 @@ : NULL; } //#################################################################### +void xml::node::set_namespace (const char *href) { + xmlNewNs(pimpl_->xmlnode_, reinterpret_cast<const xmlChar*>(href), 0); +} +//#################################################################### bool xml::node::is_text (void) const { return xmlNodeIsText(pimpl_->xmlnode_) != 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-01-21 23:19:50
|
Revision: 125 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=125&view=rev Author: vaclavslavik Date: 2009-01-21 23:19:45 +0000 (Wed, 21 Jan 2009) Log Message: ----------- moved xml::node::end() implementation inline so that its calls can be optimized by the compiler Modified Paths: -------------- trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2009-01-05 23:33:51 UTC (rev 124) +++ trunk/include/xmlwrapp/node.h 2009-01-21 23:19:45 UTC (rev 125) @@ -547,7 +547,7 @@ * @author Peter Jones **/ //#################################################################### - iterator end (void); + iterator end (void) { return iterator(); } //#################################################################### /** @@ -558,7 +558,7 @@ * @author Peter Jones **/ //#################################################################### - const_iterator end (void) const; + const_iterator end (void) const { return const_iterator(); } //#################################################################### /** Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2009-01-05 23:33:51 UTC (rev 124) +++ trunk/src/libxml/node.cxx 2009-01-21 23:19:45 UTC (rev 125) @@ -392,14 +392,6 @@ return const_iterator(pimpl_->xmlnode_->children); } //#################################################################### -xml::node::iterator xml::node::end (void) { - return iterator(); -} -//#################################################################### -xml::node::const_iterator xml::node::end (void) const { - return const_iterator(); -} -//#################################################################### xml::node::iterator xml::node::self (void) { return iterator(pimpl_->xmlnode_); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-01-25 13:42:55
|
Revision: 129 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=129&view=rev Author: vaclavslavik Date: 2009-01-25 13:42:49 +0000 (Sun, 25 Jan 2009) Log Message: ----------- build release tarballs with 'make dist'; install HTML docs in 'make install' Modified Paths: -------------- trunk/Makefile.am trunk/bootstrap trunk/configure.ac trunk/examples/04-xslt/Makefile.am trunk/tests/Makefile.am trunk/tests/attributes/Makefile.am trunk/tests/document/Makefile.am trunk/tests/event/Makefile.am trunk/tests/node/Makefile.am trunk/tests/tree/Makefile.am trunk/tests/xslt/Makefile.am Added Paths: ----------- trunk/docs/Makefile.am Removed Paths: ------------- trunk/docs/VERSION trunk/tools/ Property Changed: ---------------- trunk/docs/ Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -1,5 +1,5 @@ -SUBDIRS = include src examples tests +SUBDIRS = include src examples tests docs pkgconfigdir=$(libdir)/pkgconfig @@ -10,3 +10,6 @@ endif bin_SCRIPTS = xmlwrapp-config + +EXTRA_DIST = LICENSE bootstrap \ + platform/Win32/*.dsp platform/Win32/*.dsw Modified: trunk/bootstrap =================================================================== --- trunk/bootstrap 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/bootstrap 2009-01-25 13:42:49 UTC (rev 129) @@ -51,6 +51,7 @@ echo " - libtoolize " && libtoolize --copy --automake && \ echo " - autoconf " && autoconf && \ echo " - automake " && automake --add-missing --copy --foreign && \ +echo " - doxygen " && (cd docs && doxygen) && \ echo "Build setup successful, type \"configure\" to configure xmlwrapp now." && \ exit 0 Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/configure.ac 2009-01-25 13:42:49 UTC (rev 129) @@ -35,7 +35,7 @@ AC_REVISION($Id$)dnl -AC_PREREQ(2.56) +AC_PREREQ(2.60) AC_INIT(xmlwrapp, 0.6.0, [xml...@li...]) AC_CONFIG_SRCDIR([xmlwrapp.pc.in]) @@ -116,6 +116,7 @@ Makefile include/Makefile src/Makefile + docs/Makefile examples/Makefile examples/01-tree_parsing/Makefile examples/02-event_parsing/Makefile Property changes on: trunk/docs ___________________________________________________________________ Modified: svn:ignore - html + html Makefile Makefile.in Added: trunk/docs/Makefile.am =================================================================== --- trunk/docs/Makefile.am (rev 0) +++ trunk/docs/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -0,0 +1,7 @@ + +html_DATA = $(srcdir)/html/*.* + +EXTRA_DIST = Doxyfile manual/*.doxygen + +dist-hook: + cd $(distdir) && doxygen Property changes on: trunk/docs/Makefile.am ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Deleted: trunk/docs/VERSION =================================================================== --- trunk/docs/VERSION 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/docs/VERSION 2009-01-25 13:42:49 UTC (rev 129) @@ -1,12 +0,0 @@ -0.5.1 5 2 REL-0_5_1 2008/11/16 -0.5.0 5 2 REL-0_5_0 2004/03/18 -0.4.4 4 1 REL-0_4_4 2003/10/29 -0.4.3 4 1 REL-0_4_3 2003/08/19 -0.4.2 4 1 REL-0_4_2 2003/06/20 -0.4.1 4 1 REL-0_4_1 2003/04/07 -0.4.0 4 1 REL-0_4_0 2003/02/03 -0.3.0 3 0 REL-0_3_0 2003/01/07 -0.2.2 2 0 REL-0_2_2 2002/09/03 -0.2.1 2 0 REL-0_2_1 2002/06/26 -0.2.0 2 0 REL-0_2_0 2002/05/06 -0.1.0 1 0 REL-0_1_0 2002/04/11 Modified: trunk/examples/04-xslt/Makefile.am =================================================================== --- trunk/examples/04-xslt/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/examples/04-xslt/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -8,3 +8,5 @@ example_LDADD = ../../src/libxsltwrapp.la ../../src/libxmlwrapp.la endif + +EXTRA_DIST = example.xml example.xsl Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -6,3 +6,5 @@ node \ tree \ xslt + +EXTRA_DIST = harness/harness.pm Modified: trunk/tests/attributes/Makefile.am =================================================================== --- trunk/tests/attributes/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/attributes/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -26,3 +26,5 @@ test_attr_08_SOURCES = test_attr-08.cxx test_attr_09_SOURCES = test_attr-09.cxx test_attr_10_SOURCES = test_attr-10.cxx + +EXTRA_DIST = data/*.out data/*.xml data/*.dtd runtest.pl Modified: trunk/tests/document/Makefile.am =================================================================== --- trunk/tests/document/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/document/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -50,3 +50,5 @@ test_document_20_SOURCES = test_document-20.cxx test_document_21_SOURCES = test_document-21.cxx test_document_22_SOURCES = test_document-22.cxx + +EXTRA_DIST = data/*.out data/*.xml runtest.pl Modified: trunk/tests/event/Makefile.am =================================================================== --- trunk/tests/event/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/event/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -12,3 +12,5 @@ test_event_01_SOURCES = test_event-01.cxx test_event_02_SOURCES = test_event-02.cxx test_event_03_SOURCES = test_event-03.cxx + +EXTRA_DIST = data/*.out data/*.xml runtest.pl Modified: trunk/tests/node/Makefile.am =================================================================== --- trunk/tests/node/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/node/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -50,3 +50,5 @@ test_node_12_SOURCES = test_node-12.cxx test_node_13_SOURCES = test_node-13.cxx test_node_14_SOURCES = test_node-14.cxx + +EXTRA_DIST = data/*.out data/*.xml runtest.pl Modified: trunk/tests/tree/Makefile.am =================================================================== --- trunk/tests/tree/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/tree/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -18,3 +18,5 @@ test_tree_04_SOURCES = test_tree-04.cxx test_tree_05_SOURCES = test_tree-05.cxx test_tree_06_SOURCES = test_tree-06.cxx + +EXTRA_DIST = runtest.pl Modified: trunk/tests/xslt/Makefile.am =================================================================== --- trunk/tests/xslt/Makefile.am 2009-01-24 23:25:52 UTC (rev 128) +++ trunk/tests/xslt/Makefile.am 2009-01-25 13:42:49 UTC (rev 129) @@ -20,3 +20,5 @@ test_xslt_05_SOURCES = test_xslt-05.cxx endif + +EXTRA_DIST = data/*.xml data/*.xsl data/*.out runtest.pl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-02-06 22:42:27
|
Revision: 131 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=131&view=rev Author: vaclavslavik Date: 2009-02-06 22:42:15 +0000 (Fri, 06 Feb 2009) Log Message: ----------- improved performance of invalid iterators: don't allocate pimpl for them Modified Paths: -------------- trunk/include/xmlwrapp/node.h trunk/include/xmlwrapp/nodes_view.h trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx trunk/src/libxml/node_iterator.h Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2009-01-26 17:00:08 UTC (rev 130) +++ trunk/include/xmlwrapp/node.h 2009-02-06 22:42:15 UTC (rev 131) @@ -1,5 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * 2009 Vaclav Slavik <vs...@fa...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without @@ -431,7 +432,7 @@ typedef value_type& reference; typedef std::forward_iterator_tag iterator_category; - iterator (void); + iterator (void) : pimpl_(0) {} iterator (const iterator &other); iterator& operator= (const iterator& other); ~iterator (void); @@ -445,12 +446,15 @@ /// postfix increment (avoid if possible for better performance) iterator operator++ (int); - friend bool operator== (const iterator &lhs, const iterator &rhs); - friend bool operator!= (const iterator &lhs, const iterator &rhs); + bool operator==(const iterator& other) const + { return get_raw_node() == other.get_raw_node(); } + bool operator!=(const iterator& other) const + { return !(*this == other); } + private: impl::nipimpl *pimpl_; explicit iterator (void *data); - void* get_raw_node (void); + void* get_raw_node (void) const; void swap (iterator &other); friend class node; friend class document; @@ -470,7 +474,7 @@ typedef value_type& reference; typedef std::forward_iterator_tag iterator_category; - const_iterator (void); + const_iterator (void) : pimpl_(0) {} const_iterator (const const_iterator &other); const_iterator (const iterator &other); const_iterator& operator= (const const_iterator& other); @@ -485,12 +489,14 @@ /// postfix increment (avoid if possible for better performance) const_iterator operator++ (int); - friend bool operator== (const const_iterator &lhs, const const_iterator &rhs); - friend bool operator!= (const const_iterator &lhs, const const_iterator &rhs); + bool operator==(const const_iterator& other) const + { return get_raw_node() == other.get_raw_node(); } + bool operator!=(const const_iterator& other) const + { return !(*this == other); } private: impl::nipimpl *pimpl_; explicit const_iterator (void *data); - void* get_raw_node (void); + void* get_raw_node (void) const; void swap (const_iterator &other); friend class document; friend class node; Modified: trunk/include/xmlwrapp/nodes_view.h =================================================================== --- trunk/include/xmlwrapp/nodes_view.h 2009-01-26 17:00:08 UTC (rev 130) +++ trunk/include/xmlwrapp/nodes_view.h 2009-02-06 22:42:15 UTC (rev 131) @@ -94,7 +94,7 @@ typedef value_type& reference; typedef std::forward_iterator_tag iterator_category; - iterator(); + iterator() : pimpl_(0), advance_func_(0) {} iterator(const iterator& other); iterator& operator=(const iterator& other); ~iterator(); @@ -105,11 +105,14 @@ iterator& operator++(); iterator operator++(int); - bool operator==(const iterator& other) const; - bool operator!=(const iterator& other) const { return !(*this == other); } + bool operator==(const iterator& other) const + { return get_raw_node() == other.get_raw_node(); } + bool operator!=(const iterator& other) const + { return !(*this == other); } private: explicit iterator(void *data, impl::iter_advance_functor *advance_func); + void* get_raw_node() const; void swap(iterator& other); impl::nipimpl *pimpl_; @@ -137,7 +140,7 @@ typedef value_type& reference; typedef std::forward_iterator_tag iterator_category; - const_iterator(); + const_iterator() : pimpl_(0), advance_func_(0) {} const_iterator(const const_iterator& other); const_iterator(const iterator& other); const_iterator& operator=(const const_iterator& other); @@ -150,11 +153,14 @@ const_iterator& operator++(); const_iterator operator++(int); - bool operator==(const const_iterator& other) const; - bool operator!=(const const_iterator& other) const { return !(*this == other); } + bool operator==(const const_iterator& other) const + { return get_raw_node() == other.get_raw_node(); } + bool operator!=(const const_iterator& other) const + { return !(*this == other); } private: explicit const_iterator(void *data, impl::iter_advance_functor *advance_func); + void* get_raw_node() const; void swap(const_iterator& other); impl::nipimpl *pimpl_; Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2009-01-26 17:00:08 UTC (rev 130) +++ trunk/src/libxml/node.cxx 2009-02-06 22:42:15 UTC (rev 131) @@ -1,5 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * 2009 Vaclav Slavik <vs...@fa...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/src/libxml/node_iterator.cxx =================================================================== --- trunk/src/libxml/node_iterator.cxx 2009-01-26 17:00:08 UTC (rev 130) +++ trunk/src/libxml/node_iterator.cxx 2009-02-06 22:42:15 UTC (rev 131) @@ -1,5 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * 2009 Vaclav Slavik <vs...@fa...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without @@ -76,16 +77,12 @@ */ //#################################################################### -xml::node::iterator::iterator (void) { - pimpl_ = new nipimpl; -} -//#################################################################### xml::node::iterator::iterator (void *data) { pimpl_ = new nipimpl(static_cast<xmlNodePtr>(data)); } //#################################################################### xml::node::iterator::iterator (const iterator &other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; } //#################################################################### xml::node::iterator& xml::node::iterator::operator= (const iterator &other) { @@ -121,8 +118,8 @@ return tmp; } //#################################################################### -void* xml::node::iterator::get_raw_node (void) { - return pimpl_->it.get_raw_node(); +void* xml::node::iterator::get_raw_node (void) const { + return pimpl_ ? pimpl_->it.get_raw_node() : 0; } //#################################################################### @@ -131,20 +128,16 @@ */ //#################################################################### -xml::node::const_iterator::const_iterator (void) { - pimpl_ = new nipimpl; -} -//#################################################################### xml::node::const_iterator::const_iterator (void *data) { pimpl_ = new nipimpl(static_cast<xmlNodePtr>(data)); } //#################################################################### xml::node::const_iterator::const_iterator (const const_iterator &other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; } //#################################################################### xml::node::const_iterator::const_iterator (const iterator &other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; } //#################################################################### xml::node::const_iterator& xml::node::const_iterator::operator= (const const_iterator &other) { @@ -180,41 +173,12 @@ return tmp; } //#################################################################### -void* xml::node::const_iterator::get_raw_node (void) { - return pimpl_->it.get_raw_node(); +void* xml::node::const_iterator::get_raw_node (void) const { + return pimpl_ ? pimpl_->it.get_raw_node() : 0; } //#################################################################### -namespace xml { -namespace impl { - bool operator== (const node_iterator &lhs, const node_iterator &rhs) { - return lhs.node_ == rhs.node_; - } - bool operator!= (const node_iterator &lhs, const node_iterator &rhs) { - return !(lhs == rhs); - } -} - - bool operator== (const node::iterator &lhs, const node::iterator &rhs) { - return lhs.pimpl_->it == rhs.pimpl_->it; - } - - bool operator!= (const node::iterator &lhs, const node::iterator &rhs) { - return !(lhs == rhs); - } - - bool operator== (const node::const_iterator &lhs, const node::const_iterator &rhs) { - return lhs.pimpl_->it == rhs.pimpl_->it; - } - - bool operator!= (const node::const_iterator &lhs, const node::const_iterator &rhs) { - return !(lhs == rhs); - } -} -//#################################################################### - - namespace xml { @@ -222,15 +186,9 @@ // xml::nodes_view::iterator // ------------------------------------------------------------------------ -nodes_view::iterator::iterator() -{ - pimpl_ = new nipimpl; - advance_func_ = 0; -} - nodes_view::iterator::iterator(const iterator& other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; advance_func_ = other.advance_func_; } @@ -273,9 +231,9 @@ return tmp; } -bool nodes_view::iterator::operator==(const iterator& other) const +void* nodes_view::iterator::get_raw_node() const { - return pimpl_->it == other.pimpl_->it; + return pimpl_ ? pimpl_->it.get_raw_node() : 0; } nodes_view::iterator::iterator(void *data, impl::iter_advance_functor *advance_func) @@ -295,21 +253,15 @@ // xml::nodes_view::const_iterator // ------------------------------------------------------------------------ -nodes_view::const_iterator::const_iterator() -{ - pimpl_ = new nipimpl; - advance_func_ = 0; -} - nodes_view::const_iterator::const_iterator(const const_iterator& other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; advance_func_ = other.advance_func_; } nodes_view::const_iterator::const_iterator(const iterator& other) { - pimpl_ = new nipimpl(*(other.pimpl_)); + pimpl_ = other.pimpl_ ? new nipimpl(*(other.pimpl_)) : 0; advance_func_ = other.advance_func_; } @@ -360,9 +312,9 @@ return tmp; } -bool nodes_view::const_iterator::operator==(const const_iterator& other) const +void* nodes_view::const_iterator::get_raw_node() const { - return pimpl_->it == other.pimpl_->it; + return pimpl_ ? pimpl_->it.get_raw_node() : 0; } nodes_view::const_iterator::const_iterator(void *data, impl::iter_advance_functor *advance_func) Modified: trunk/src/libxml/node_iterator.h =================================================================== --- trunk/src/libxml/node_iterator.h 2009-01-26 17:00:08 UTC (rev 130) +++ trunk/src/libxml/node_iterator.h 2009-02-06 22:42:15 UTC (rev 131) @@ -1,5 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * 2009 Vaclav Slavik <vs...@fa...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without @@ -94,9 +95,7 @@ void advance() { node_ = node_->next; } void advance(iter_advance_functor& next) { node_ = next(node_); } - friend bool operator== (const node_iterator &lhs, const node_iterator &rhs); - private: mutable node fake_node_; xmlNodePtr node_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-02-06 22:54:56
|
Revision: 132 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=132&view=rev Author: vaclavslavik Date: 2009-02-06 22:54:50 +0000 (Fri, 06 Feb 2009) Log Message: ----------- pass iterator arguments to various xml::node methods by reference instead of by value, iterators are not as cheap to copy as we'd want them Modified Paths: -------------- trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2009-02-06 22:42:15 UTC (rev 131) +++ trunk/include/xmlwrapp/node.h 2009-02-06 22:54:50 UTC (rev 132) @@ -674,7 +674,7 @@ * @see elements(const char*) **/ //#################################################################### - iterator find (const char *name, iterator start); + iterator find (const char *name, const iterator& start); //#################################################################### /** @@ -696,7 +696,7 @@ * @see elements(const char*) const **/ //#################################################################### - const_iterator find (const char *name, const_iterator start) const; + const_iterator find (const char *name, const const_iterator& start) const; /** * Returns view of child nodes of type type_element. If no such node @@ -808,7 +808,7 @@ * @author Peter Jones **/ //#################################################################### - iterator insert (iterator position, const node &n); + iterator insert (const iterator& position, const node &n); //#################################################################### /** @@ -824,7 +824,7 @@ * @author Peter Jones **/ //#################################################################### - iterator replace (iterator old_node, const node &new_node); + iterator replace (const iterator& old_node, const node &new_node); //#################################################################### /** @@ -839,7 +839,7 @@ * @author Gary A. Passero **/ //#################################################################### - iterator erase (iterator to_erase); + iterator erase (const iterator& to_erase); //#################################################################### /** @@ -853,7 +853,7 @@ * @author Peter Jones **/ //#################################################################### - iterator erase (iterator first, iterator last); + iterator erase (iterator first, const iterator& last); //#################################################################### /** Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2009-02-06 22:42:15 UTC (rev 131) +++ trunk/src/libxml/node.cxx 2009-02-06 22:54:50 UTC (rev 132) @@ -458,13 +458,13 @@ return end(); } //#################################################################### -xml::node::iterator xml::node::find (const char *name, iterator start) { +xml::node::iterator xml::node::find (const char *name, const iterator& start) { xmlNodePtr n = static_cast<xmlNodePtr>(start.get_raw_node()); if ( (n = find_element(name, n))) return iterator(n); return end(); } //#################################################################### -xml::node::const_iterator xml::node::find (const char *name, const_iterator start) const { +xml::node::const_iterator xml::node::find (const char *name, const const_iterator& start) const { xmlNodePtr n = static_cast<xmlNodePtr>(start.get_raw_node()); if ( (n = find_element(name, n))) return const_iterator(n); return end(); @@ -511,19 +511,19 @@ return iterator(xml::impl::node_insert(pimpl_->xmlnode_, 0, n.pimpl_->xmlnode_)); } //#################################################################### -xml::node::iterator xml::node::insert (iterator position, const node &n) { +xml::node::iterator xml::node::insert (const iterator& position, const node &n) { return iterator(xml::impl::node_insert(pimpl_->xmlnode_, static_cast<xmlNodePtr>(position.get_raw_node()), n.pimpl_->xmlnode_)); } //#################################################################### -xml::node::iterator xml::node::replace (iterator old_node, const node &new_node) { +xml::node::iterator xml::node::replace (const iterator& old_node, const node &new_node) { return iterator(xml::impl::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), new_node.pimpl_->xmlnode_)); } //#################################################################### -xml::node::iterator xml::node::erase (iterator to_erase) { +xml::node::iterator xml::node::erase (const iterator& to_erase) { return iterator(xml::impl::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); } //#################################################################### -xml::node::iterator xml::node::erase (iterator first, iterator last) { +xml::node::iterator xml::node::erase (iterator first, const iterator& last) { while (first != last) first = erase(first); return first; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-02-21 16:22:45
|
Revision: 136 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=136&view=rev Author: vaclavslavik Date: 2009-02-21 16:22:40 +0000 (Sat, 21 Feb 2009) Log Message: ----------- reverted set_namespace() addition -- correct namespaces handling is more work than that Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-02-06 23:57:41 UTC (rev 135) +++ trunk/NEWS 2009-02-21 16:22:40 UTC (rev 136) @@ -25,7 +25,7 @@ PDF version of the manual is no longer provided, use HTML documentation included with xmlwrapp source distribution. - Added xml::node::get_namespace() and set_namespace() functions. + Added xml::node::get_namespace() function. Added new constructor to the xml::node class for creating text nodes, using xml::node::text helper struct. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2009-02-06 23:57:41 UTC (rev 135) +++ trunk/include/xmlwrapp/node.h 2009-02-21 16:22:40 UTC (rev 136) @@ -377,17 +377,6 @@ //#################################################################### /** - * Sets the namespace of this xml::node. - * - * @param href URI of the namespace to associate with the node. - * @author Vaclav Slavik - * @since 0.6.0 - **/ - //#################################################################### - void set_namespace(const char *href); - - //#################################################################### - /** * Find out if this node is a text node or sometiming like a text node, * CDATA for example. * Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2009-02-06 23:57:41 UTC (rev 135) +++ trunk/src/libxml/node.cxx 2009-02-21 16:22:40 UTC (rev 136) @@ -400,10 +400,6 @@ : NULL; } //#################################################################### -void xml::node::set_namespace (const char *href) { - xmlNewNs(pimpl_->xmlnode_, reinterpret_cast<const xmlChar*>(href), 0); -} -//#################################################################### bool xml::node::is_text (void) const { return xmlNodeIsText(pimpl_->xmlnode_) != 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-04-17 13:07:47
|
Revision: 139 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=139&view=rev Author: vaclavslavik Date: 2009-04-17 13:07:32 +0000 (Fri, 17 Apr 2009) Log Message: ----------- use pkg-config's Require: field instead of Libs.private for dependency libraries Modified Paths: -------------- trunk/xmlwrapp.pc.in trunk/xsltwrapp.pc.in Modified: trunk/xmlwrapp.pc.in =================================================================== --- trunk/xmlwrapp.pc.in 2009-02-22 12:45:16 UTC (rev 138) +++ trunk/xmlwrapp.pc.in 2009-04-17 13:07:32 UTC (rev 139) @@ -6,7 +6,6 @@ Name: xmlwrapp Version: @VERSION@ Description: A C++ wrapper around libxml2 -Requires: +Requires: libxml-2.0 Libs: -L${libdir} -lxmlwrapp -Libs.private: @LIBXML_LIBS@ Cflags: -I${includedir} Modified: trunk/xsltwrapp.pc.in =================================================================== --- trunk/xsltwrapp.pc.in 2009-02-22 12:45:16 UTC (rev 138) +++ trunk/xsltwrapp.pc.in 2009-04-17 13:07:32 UTC (rev 139) @@ -6,7 +6,6 @@ Name: xsltwrapp Version: @VERSION@ Description: A C++ wrapper around libxslt -Requires: xmlwrapp = @VERSION@ +Requires: xmlwrapp = @VERSION@, libexslt, libxslt Libs: -L${libdir} -lxsltwrapp -Libs.private: @LIBEXSLT_LIBS@ @LIBXSLT_LIBS@ Cflags: -I${includedir} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-04-27 18:43:10
|
Revision: 140 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=140&view=rev Author: vaclavslavik Date: 2009-04-27 18:43:00 +0000 (Mon, 27 Apr 2009) Log Message: ----------- added Bakefile-generated VC++ projects; changed VC6 project file to be generated too Modified Paths: -------------- trunk/Makefile.am trunk/NEWS trunk/README Added Paths: ----------- trunk/platform/Win32/Bakefiles.bkgen trunk/platform/Win32/README trunk/platform/Win32/xmlwrapp.bkl Removed Paths: ------------- trunk/platform/Win32/xmlwrapp.dsp trunk/platform/Win32/xmlwrapp.dsw Property Changed: ---------------- trunk/platform/Win32/ Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-04-17 13:07:32 UTC (rev 139) +++ trunk/Makefile.am 2009-04-27 18:43:00 UTC (rev 140) @@ -11,5 +11,13 @@ bin_SCRIPTS = xmlwrapp-config -EXTRA_DIST = LICENSE bootstrap \ - $(srcdir)/platform/Win32/*.dsp $(srcdir)/platform/Win32/*.dsw +EXTRA_DIST = \ + LICENSE bootstrap \ + $(srcdir)/platform/Win32/README \ + $(srcdir)/platform/Win32/*.dsp \ + $(srcdir)/platform/Win32/Bakefiles.bkgen \ + $(srcdir)/platform/Win32/*.bkl + +dist-hook: + (cd $(distdir)/platform/Win32 ; bakefile_gen) + rm -f $(distdir)/platform/Win32/.bakefile_gen.state Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-04-17 13:07:32 UTC (rev 139) +++ trunk/NEWS 2009-04-27 18:43:00 UTC (rev 140) @@ -1,3 +1,5 @@ + Added Visual C++ 200x projects and fixed VC6 project. + Version 0.6.0 Fixed libxmlwrapp to not depend on libxslt if XSLT support Modified: trunk/README =================================================================== --- trunk/README 2009-04-17 13:07:32 UTC (rev 139) +++ trunk/README 2009-04-27 18:43:00 UTC (rev 140) @@ -25,7 +25,9 @@ ---------------------- At this time, only building with Visual C++ compiler is supported. The required -project files are located in platform/Win32 directory. +project files are located in platform/Win32 directory. You will need libxml +and libxslt libraries built for Windows, e.g. the binaries from +http://www.zlatkovic.com/libxml.en.html. 4. Using xmlwrapp Property changes on: trunk/platform/Win32 ___________________________________________________________________ Added: svn:ignore + Debug Release xmlwrapp_vc?_xmlwrapp.vcproj* xmlwrapp_vc?_xsltwrapp.vcproj* xmlwrapp_vc?.sln *.ncb *.suo .bakefile_gen.state Added: trunk/platform/Win32/Bakefiles.bkgen =================================================================== --- trunk/platform/Win32/Bakefiles.bkgen (rev 0) +++ trunk/platform/Win32/Bakefiles.bkgen 2009-04-27 18:43:00 UTC (rev 140) @@ -0,0 +1,23 @@ +<?xml version="1.0" ?> + +<bakefile-gen xmlns="http://www.bakefile.org/schema/bakefile-gen"> + + <input> + xmlwrapp.bkl + </input> + + <add-formats> + msvc6prj,msvs2003prj,msvs2005prj,msvs2008prj + </add-formats> + + <add-flags formats="msvs2003prj"> + -o $(INPUT_FILE_DIR)/$(INPUT_FILE_BASENAME_NOEXT)_vc7.sln + </add-flags> + <add-flags formats="msvs2005prj"> + -o $(INPUT_FILE_DIR)/$(INPUT_FILE_BASENAME_NOEXT)_vc8.sln + </add-flags> + <add-flags formats="msvs2008prj"> + -o $(INPUT_FILE_DIR)/$(INPUT_FILE_BASENAME_NOEXT)_vc9.sln + </add-flags> + +</bakefile-gen> Added: trunk/platform/Win32/README =================================================================== --- trunk/platform/Win32/README (rev 0) +++ trunk/platform/Win32/README 2009-04-27 18:43:00 UTC (rev 140) @@ -0,0 +1,3 @@ + +Please use Bakefile (http://www.bakefile.org) to generate Visual C++ project +files. Added: trunk/platform/Win32/xmlwrapp.bkl =================================================================== --- trunk/platform/Win32/xmlwrapp.bkl (rev 0) +++ trunk/platform/Win32/xmlwrapp.bkl 2009-04-27 18:43:00 UTC (rev 140) @@ -0,0 +1,66 @@ +<?xml version="1.0" ?> + +<makefile> + <set-srcdir>../..</set-srcdir> + + <include file="presets/simple.bkl"/> + + <template id="xmlwrapp_lib" template="simple"> + </template> + + + <lib id="xmlwrapp" template="xmlwrapp_lib"> + <headers> + include/xmlwrapp/attributes.h + include/xmlwrapp/_cbfo.h + include/xmlwrapp/document.h + include/xmlwrapp/event_parser.h + include/xmlwrapp/init.h + include/xmlwrapp/node.h + include/xmlwrapp/nodes_view.h + include/xmlwrapp/tree_parser.h + include/xmlwrapp/xmlwrapp.h + + <!-- private headers --> + src/libxml/ait_impl.h + src/libxml/dtd_impl.h + src/libxml/node_iterator.h + src/libxml/node_manip.h + src/libxml/pimpl_base.h + src/libxml/utility.h + </headers> + + <sources> + src/libxml/ait_impl.cxx + src/libxml/attributes.cxx + src/libxml/document.cxx + src/libxml/dtd_impl.cxx + src/libxml/event_parser.cxx + src/libxml/init.cxx + src/libxml/node.cxx + src/libxml/node_iterator.cxx + src/libxml/node_manip.cxx + src/libxml/nodes_view.cxx + src/libxml/tree_parser.cxx + src/libxml/utility.cxx + </sources> + </lib> + + + <lib id="xsltwrapp" template="xmlwrapp_lib"> + <headers> + include/xsltwrapp/init.h + include/xsltwrapp/stylesheet.h + include/xsltwrapp/xsltwrapp.h + + <!-- private headers --> + src/libxslt/result.h + </headers> + + <sources> + src/libxslt/init.cxx + src/libxslt/stylesheet.cxx + </sources> + </lib> + +</makefile> Deleted: trunk/platform/Win32/xmlwrapp.dsp =================================================================== --- trunk/platform/Win32/xmlwrapp.dsp 2009-04-17 13:07:32 UTC (rev 139) +++ trunk/platform/Win32/xmlwrapp.dsp 2009-04-27 18:43:00 UTC (rev 140) @@ -1,172 +0,0 @@ -# Microsoft Developer Studio Project File - Name="xmlwrapp" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=xmlwrapp - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "xmlwrapp.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "xmlwrapp.mak" CFG="xmlwrapp - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "xmlwrapp - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "xmlwrapp - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "xmlwrapp - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /I../../include /I..\..\..\libxml2-2.4.30.win32\include /I..\..\..\iconv-1.8.win32\include /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "xmlwrapp - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /I../../include /I../../../libxml2-2.4.30.win32\include /I../../../iconv-1.8.win32\include /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "xmlwrapp - Win32 Release" -# Name "xmlwrapp - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\src\libxml\ait_impl.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\attributes.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\document.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\dtd_impl.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\event_parser.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\init.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\node.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\nodes_view.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\node_iterator.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\node_iterator.h -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\tree_parser.cxx -# End Source File -# Begin Source File - -SOURCE=..\..\src\libxml\utility.cxx -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\attributes.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\document.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\event_parser.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\init.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\node.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\nodes_view.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\tree_parser.h -# End Source File -# Begin Source File - -SOURCE=..\..\include\xmlwrapp\xmlwrapp.h -# End Source File -# End Group -# End Target -# End Project Deleted: trunk/platform/Win32/xmlwrapp.dsw =================================================================== --- trunk/platform/Win32/xmlwrapp.dsw 2009-04-17 13:07:32 UTC (rev 139) +++ trunk/platform/Win32/xmlwrapp.dsw 2009-04-27 18:43:00 UTC (rev 140) @@ -1,74 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "example event parser"=".\example_event_parser.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name xmlwrapp - End Project Dependency -}}} - -############################################################################### - -Project: "example tree parser"=".\example_tree_parser.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name xmlwrapp - End Project Dependency -}}} - -############################################################################### - -Project: "example xml generation"=".\example_xml_generation.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name xmlwrapp - End Project Dependency -}}} - -############################################################################### - -Project: "xmlwrapp"=".\xmlwrapp.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-05-31 18:19:25
|
Revision: 144 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=144&view=rev Author: vaclavslavik Date: 2009-05-31 18:19:17 +0000 (Sun, 31 May 2009) Log Message: ----------- pretified xsltwrapp code formatting; no real changes Modified Paths: -------------- trunk/include/xsltwrapp/init.h trunk/include/xsltwrapp/stylesheet.h trunk/include/xsltwrapp/xsltwrapp.h trunk/src/libxslt/init.cxx trunk/src/libxslt/result.h trunk/src/libxslt/stylesheet.cxx Modified: trunk/include/xsltwrapp/init.h =================================================================== --- trunk/include/xsltwrapp/init.h 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/include/xsltwrapp/init.h 2009-05-31 18:19:17 UTC (rev 144) @@ -1,11 +1,11 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the definition of the xslt::init class. -**/ +/** + @file + This file contains the definition of the xslt::init class. + */ + #ifndef _xsltwrapp_init_h_ #define _xsltwrapp_init_h_ @@ -41,41 +43,41 @@ #include "xmlwrapp/init.h" /// XSLT library namespace -namespace xslt { +namespace xslt +{ /** - * The xslt::init class is used to configure the XSLT engine. - * - * If you want to use any of the xslt::init member functions, do so before - * you start any threads or use any other part of xsltwrapp. The member - * functions may alter global and/or static variables. In other words, this - * class is not thread safe. - * - * @note In xmlwrapp versions prior to 0.6.0, this class was used to initialize - * the library and exactly one instance had to be created before first - * use. This is no longer true: user code doesn't have to create any - * instances, but it @em can create as many instances as it wants. -**/ -class init : public xml::init { + The xslt::init class is used to configure the XSLT engine. + + If you want to use any of the xslt::init member functions, do so before + you start any threads or use any other part of xsltwrapp. The member + functions may alter global and/or static variables. In other words, this + class is not thread safe. + + @note In xmlwrapp versions prior to 0.6.0, this class was used to initialize + the library and exactly one instance had to be created before first + use. This is no longer true: user code doesn't have to create any + instances, but it @em can create as many instances as it wants. + */ +class init : public xml::init +{ public: - init (void); - ~init (void); + init(); + ~init(); - //#################################################################### - /** - * This function controls whether or not the XSLT engine will process - * XInclusions by default while parsing the stylesheet. The default is - * true. - * - * @param flag True to enable XInclusing processing; False otherwise. - * @author Peter Jones - **/ - //#################################################################### - static void process_xincludes (bool flag); + /** + This function controls whether or not the XSLT engine will process + XInclusions by default while parsing the stylesheet. The default is + true. + @param flag True to enable XInclusing processing; False otherwise. + @author Peter Jones + */ + static void process_xincludes(bool flag); + private: - init (const init&); - init& operator= (const init&); + init(const init&); + init& operator=(const init&); void init_library(); void shutdown_library(); @@ -83,11 +85,14 @@ static int ms_counter; }; // end xslt::init class + // use a "nifty counter" to ensure that any source file that uses xsltwrapp // will initialize the library prior to its first use -namespace { - xslt::init g_xsltwrapp_initializer; +namespace +{ +xslt::init g_xsltwrapp_initializer; } } // end xslt namespace -#endif + +#endif // _xsltwrapp_init_h_ Modified: trunk/include/xsltwrapp/stylesheet.h =================================================================== --- trunk/include/xsltwrapp/stylesheet.h 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/include/xsltwrapp/stylesheet.h 2009-05-31 18:19:17 UTC (rev 144) @@ -1,11 +1,11 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the definition of the xslt::stylesheet class. -**/ +/** + @file + This file contains the definition of the xslt::stylesheet class. + */ + #ifndef _xsltwrapp_stylesheet_h_ #define _xsltwrapp_stylesheet_h_ @@ -45,139 +47,127 @@ #include <map> #include <string> -namespace xslt { +namespace xslt +{ /** - * The xslt::stylesheet class is used to hold information about an XSLT - * stylesheet. You can use it to load in a stylesheet and then use that - * stylesheet to transform an XML document to something else. -**/ -class stylesheet { + The xslt::stylesheet class is used to hold information about an XSLT + stylesheet. You can use it to load in a stylesheet and then use that + stylesheet to transform an XML document to something else. + */ +class stylesheet +{ public: /// Type for passing parameters to the stylesheet typedef std::map<std::string, std::string> param_type; - //#################################################################### - /** - * Create a new xslt::stylesheet object and load and parse the - * stylesheet in the given filename. - * - * @param filename The name of the file that contains the stylesheet. - * @author Peter Jones - **/ - //#################################################################### - explicit stylesheet (const char *filename); + /** + Create a new xslt::stylesheet object and load and parse the + stylesheet in the given filename. - //#################################################################### - /** - * Create a new xslt::stylesheet object from an xml::document object - * that contains the parsed stylesheet. The given xml::document is - * passed by value. This is needed because the stylesheet will own the - * document and free it. - * - * @param doc The parsed stylesheet. - * @author Peter Jones - **/ - //#################################################################### - explicit stylesheet (xml::document doc); + @param filename The name of the file that contains the stylesheet. + @author Peter Jones + */ + explicit stylesheet(const char *filename); - //#################################################################### - /** - * Clean up after an xslt::stylesheet. - * - * @author Peter Jones - **/ - //#################################################################### - ~stylesheet (void); + /** + Create a new xslt::stylesheet object from an xml::document object + that contains the parsed stylesheet. The given xml::document is + passed by value. This is needed because the stylesheet will own the + document and free it. - //#################################################################### - /** - * Apply this stylesheet to the given XML document. The result document - * is placed in the second document parameter. - * - * @param doc The XML document to transform. - * @param result The result tree after applying this stylesheet. - * @return True if the transformation was successful and the results placed in result. - * @return False if there was an error, result is not modified. - * @author Peter Jones - **/ - //#################################################################### - bool apply (const xml::document &doc, xml::document &result); + @param doc The parsed stylesheet. + @author Peter Jones + */ + explicit stylesheet(xml::document doc); - //#################################################################### - /** - * Apply this stylesheet to the given XML document. The result document - * is placed in the second document parameter. + /** + Clean up after an xslt::stylesheet. - * @param doc The XML document to transform. - * @param result The result tree after applying this stylesheet. - * @param with_params Override xsl:param elements using the given key/value map - * @return True if the transformation was successful and the results placed in result. - * @return False if there was an error, result is not modified. - * @author Peter Jones - **/ - //#################################################################### - bool apply (const xml::document &doc, xml::document &result, const param_type &with_params); + @author Peter Jones + */ + ~stylesheet(); - //#################################################################### - /** - * Apply this stylesheet to the given XML document. The results document - * is returned. If there is an error during transformation, this - * function will throw a std::runtime_error exception. - * - * Each time you call this member function, the xml::document object - * that was returned from the last call becomes invalid. That is, of - * course, unless you copied it first. - * - * @param doc The XML document to transform. - * @return A reference to the result tree. - * @author Peter Jones - **/ - //#################################################################### - xml::document& apply (const xml::document &doc); + /** + Apply this stylesheet to the given XML document. The result document + is placed in the second document parameter. - //#################################################################### - /** - * Apply this stylesheet to the given XML document. The results document - * is returned. If there is an error during transformation, this - * function will throw a std::runtime_error exception. - * - * Each time you call this member function, the xml::document object - * that was returned from the last call becomes invalid. That is, of - * course, unless you copied it first. - * - * @param doc The XML document to transform. - * @param with_params Override xsl:param elements using the given key/value map - * @return A reference to the result tree. - * @author Peter Jones - **/ - //#################################################################### - xml::document& apply (const xml::document &doc, const param_type &with_params); + @param doc The XML document to transform. + @param result The result tree after applying this stylesheet. + @return True if the transformation was successful and the results placed in result. + @return False if there was an error, result is not modified. + @author Peter Jones + */ + bool apply(const xml::document& doc, xml::document& result); - //#################################################################### - /** - * If you used one of the xslt::stylesheet::apply member functions that - * return a bool, you can use this function to get the text message for - * the transformation error. - * - * If you are using one of the apply member functions that throws - * exceptions, this function should not be used. The text message for - * the transformation error will be given to the std::runtime_error - * constructor. - * - * @return The last error message. - * @author Peter Jones - **/ - //#################################################################### - const std::string& get_error_message (void) const; + /** + Apply this stylesheet to the given XML document. The result document + is placed in the second document parameter. + @param doc The XML document to transform. + @param result The result tree after applying this stylesheet. + @param with_params Override xsl:param elements using the given key/value map + @return True if the transformation was successful and the results placed in result. + @return False if there was an error, result is not modified. + @author Peter Jones + */ + bool apply(const xml::document& doc, xml::document& result, const param_type& with_params); + + /** + Apply this stylesheet to the given XML document. The results document + is returned. If there is an error during transformation, this + function will throw a std::runtime_error exception. + + Each time you call this member function, the xml::document object + that was returned from the last call becomes invalid. That is, of + course, unless you copied it first. + + @param doc The XML document to transform. + @return A reference to the result tree. + @author Peter Jones + */ + xml::document& apply(const xml::document& doc); + + /** + Apply this stylesheet to the given XML document. The results document + is returned. If there is an error during transformation, this + function will throw a std::runtime_error exception. + + Each time you call this member function, the xml::document object + that was returned from the last call becomes invalid. That is, of + course, unless you copied it first. + + @param doc The XML document to transform. + @param with_params Override xsl:param elements using the given key/value map + @return A reference to the result tree. + @author Peter Jones + */ + xml::document& apply(const xml::document& doc, const param_type& with_params); + + /** + If you used one of the xslt::stylesheet::apply member functions that + return a bool, you can use this function to get the text message for + the transformation error. + + If you are using one of the apply member functions that throws + exceptions, this function should not be used. The text message for + the transformation error will be given to the std::runtime_error + constructor. + + @return The last error message. + @author Peter Jones + */ + const std::string& get_error_message() const; + private: - struct pimpl; pimpl *pimpl_; + struct pimpl; + pimpl *pimpl_; // an xslt::stylesheet cannot yet be copied or assigned to. - stylesheet (const stylesheet&); - stylesheet& operator= (const stylesheet&); + stylesheet(const stylesheet&); + stylesheet& operator=(const stylesheet&); }; // end xslt::stylesheet class - + } // end xslt namespace -#endif + +#endif // _xsltwrapp_stylesheet_h_ Modified: trunk/include/xsltwrapp/xsltwrapp.h =================================================================== --- trunk/include/xsltwrapp/xsltwrapp.h 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/include/xsltwrapp/xsltwrapp.h 2009-05-31 18:19:17 UTC (rev 144) @@ -5,7 +5,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A Modified: trunk/src/libxslt/init.cxx =================================================================== --- trunk/src/libxslt/init.cxx 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/src/libxslt/init.cxx 2009-05-31 18:19:17 UTC (rev 144) @@ -1,11 +1,11 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -30,38 +30,50 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the implementation of the xslt::init class. -**/ +/** + @file -// defintion include + This file contains the implementation of the xslt::init class. + */ + #include "xsltwrapp/init.h" -// libxslt includes #include <libxslt/xslt.h> #include <libxslt/xsltInternals.h> #include <libxslt/transform.h> #include <libxslt/xsltutils.h> #include <libexslt/exslt.h> -//#################################################################### -namespace { - extern "C" void xslt_error (void *, const char*, ...); +namespace +{ + +extern "C" void xslt_error(void *, const char*, ...) +{ + // don't do anything } -//#################################################################### + +} // anonymous namespace + + int xslt::init::ms_counter = 0; -//#################################################################### -xslt::init::init (void) { + + +xslt::init::init() +{ if ( ms_counter++ == 0 ) init_library(); } -//#################################################################### -xslt::init::~init (void) { + + +xslt::init::~init(void) +{ if ( --ms_counter == 0 ) shutdown_library(); } -//#################################################################### -void xslt::init::init_library() { + + +void xslt::init::init_library() +{ xsltInit(); // set some defautls @@ -74,17 +86,15 @@ // load EXSLT exsltRegisterAll(); } -//#################################################################### -void xslt::init::shutdown_library() { + + +void xslt::init::shutdown_library() +{ xsltCleanupGlobals(); } -//#################################################################### -void xslt::init::process_xincludes (bool flag) { + + +void xslt::init::process_xincludes(bool flag) +{ xsltSetXIncludeDefault(flag ? 1 : 0); } -//#################################################################### -namespace { - extern "C" void xslt_error (void*, const char*, ...) - { /* don't do anything */ } -} -//#################################################################### Modified: trunk/src/libxslt/result.h =================================================================== --- trunk/src/libxslt/result.h 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/src/libxslt/result.h 2009-05-31 18:19:17 UTC (rev 144) @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 Vadim Zeitlin (va...@ze...) * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the declaration of the xslt::result class. -**/ +/** + @file + This file contains the declaration of the xslt::result class. + */ + #ifndef _xsltwrapp_result_h_ #define _xsltwrapp_result_h_ @@ -43,57 +45,55 @@ // forward declarations typedef struct _xmlDoc *xmlDocPtr; -namespace xslt { +namespace xslt +{ -namespace impl { +namespace impl +{ /** - * The xslt::result class is used as a callback by xml::document to allow - * special treatment of XML documents which were created by XSLT. - * - * This class is only meant to be used internally by the library and is - * necessary to avoid the dependency of xml::document, which is part of - * libxmlwrapp, on libxslt which should be only a dependency of libxsltwrapp - * as this precludes calling the XSLT functions which must be used with such - * "result" documents directly from xml::document code. - * - * @author Vadim Zeitlin - * @internal -**/ -class result { + @internal + + The xslt::result class is used as a callback by xml::document to allow + special treatment of XML documents which were created by XSLT. + + This class is only meant to be used internally by the library and is + necessary to avoid the dependency of xml::document, which is part of + libxmlwrapp, on libxslt which should be only a dependency of libxsltwrapp + as this precludes calling the XSLT functions which must be used with such + "result" documents directly from xml::document code. + + @author Vadim Zeitlin + */ +class result +{ public: - //#################################################################### /** - * Save the contents of the given XML document in the provided string. - * - * @param s The string to place the XML text data. - **/ - //#################################################################### + Save the contents of the given XML document in the provided string. + + @param s The string to place the XML text data. + */ virtual void save_to_string(std::string &s) const = 0; - //#################################################################### - /** - * Save the contents of the given XML document in the provided filename. - * - * @param filename The name of the file to place the XML text data into. - * @param compression_level 0 is no compression, 1-9 allowed, where 1 is for better speed, and 9 is for smaller size - * @return True if the data was saved successfully. - * @return False otherwise. - **/ - //#################################################################### - virtual bool save_to_file (const char *filename, - int compression_level) const = 0; + /** + Save the contents of the given XML document in the provided filename. - //#################################################################### - /** - * Trivial but virtual base class destructor. - **/ - //#################################################################### - virtual ~result (void) { } + @param filename + The name of the file to place the XML text data into. + @param compression_level + 0 is no compression, 1-9 allowed, where 1 is for better speed, + and 9 is for smaller size + @return True if the data was saved successfully, false otherwise. + */ + virtual bool save_to_file(const char *filename, + int compression_level) const = 0; + + /// Trivial but virtual base class destructor. + virtual ~result() {} }; } // end impl namespace } // end xslt namespace -#endif +#endif // _xsltwrapp_result_h_ Modified: trunk/src/libxslt/stylesheet.cxx =================================================================== --- trunk/src/libxslt/stylesheet.cxx 2009-05-30 18:55:52 UTC (rev 143) +++ trunk/src/libxslt/stylesheet.cxx 2009-05-31 18:19:17 UTC (rev 144) @@ -1,11 +1,11 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -15,7 +15,7 @@ * 3. Neither the name of the Author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the implementation of the xslt::stylesheet class. -**/ +/** + @file + This file contains the implementation of the xslt::stylesheet class. + */ + // xmlwrapp includes #include "xsltwrapp/stylesheet.h" #include "xmlwrapp/document.h" @@ -55,33 +57,35 @@ #include <vector> #include <map> -namespace { +namespace +{ // implementation of xslt::result using xslt::stylesheet: we pass this object // to xml::document for the documents obtained via XSLT so that some operations // (currently only saving) could be done differently for them -class result_impl : public xslt::impl::result { +class result_impl : public xslt::impl::result +{ public: // We don't own the pointers given to us, their lifetime must be greater // than the lifetime of this object. - result_impl(xmlDocPtr doc, xsltStylesheetPtr ss) : doc_(doc), ss_(ss) { } + result_impl(xmlDocPtr doc, xsltStylesheetPtr ss) : doc_(doc), ss_(ss) {} virtual void save_to_string(std::string &s) const { - xmlChar *xml_string; - int xml_string_length; + xmlChar *xml_string; + int xml_string_length; - if (xsltSaveResultToString(&xml_string, &xml_string_length, doc_, ss_) >= 0) - { - xml::impl::xmlchar_helper helper(xml_string); - if (xml_string_length) s.assign(helper.get(), xml_string_length); - } + if (xsltSaveResultToString(&xml_string, &xml_string_length, doc_, ss_) >= 0) + { + xml::impl::xmlchar_helper helper(xml_string); + if (xml_string_length) s.assign(helper.get(), xml_string_length); + } } virtual bool - save_to_file (const char *filename, int /* compression_level */) const + save_to_file(const char *filename, int /* compression_level */) const { - return xsltSaveResultToFilename(filename, doc_, ss_, 0) >= 0; + return xsltSaveResultToFilename(filename, doc_, ss_, 0) >= 0; } private: @@ -89,145 +93,169 @@ xsltStylesheetPtr ss_; }; + +void make_vector_param(std::vector<const char*> &v, + const xslt::stylesheet::param_type &p) +{ + v.reserve(p.size()); + + xslt::stylesheet::param_type::const_iterator i = p.begin(), end = p.end(); + for (; i != end; ++i) + { + v.push_back(i->first.c_str()); + v.push_back(i->second.c_str()); + } + + v.push_back(static_cast<const char*>(0)); +} + + +xmlDocPtr apply_stylesheet(xsltStylesheetPtr s, xmlDocPtr d, + const xslt::stylesheet::param_type *p = NULL) +{ + /* + * TODO TODO TODO TODO + * + * use a transform context to capture error messages + * + * TODO TODO TODO TODO + */ + std::vector<const char*> v; + if (p) + make_vector_param(v, *p); + return xsltApplyStylesheet(s, d, p ? &v[0] : 0); +} + } // end of anonymous namespace -//#################################################################### -namespace { - void make_vector_param (std::vector<const char*> &v, const xslt::stylesheet::param_type &p); - xmlDocPtr apply_stylesheet (xsltStylesheetPtr s, xmlDocPtr d, const xslt::stylesheet::param_type *p=0); -} -//#################################################################### -struct xslt::stylesheet::pimpl { + +struct xslt::stylesheet::pimpl +{ pimpl (void) : ss_(0) { } xsltStylesheetPtr ss_; xml::document doc_; std::string error_; }; -//#################################################################### -xslt::stylesheet::stylesheet (const char *filename) { + + +xslt::stylesheet::stylesheet(const char *filename) +{ std::auto_ptr<pimpl> ap(pimpl_ = new pimpl); xml::tree_parser parser(filename); xmlDocPtr xmldoc = static_cast<xmlDocPtr>(parser.get_document().get_doc_data()); - if ( (pimpl_->ss_ = xsltParseStylesheetDoc(xmldoc)) == 0) { - // TODO error_ can't get set yet. Need changes from libxslt first - if (pimpl_->error_.empty()) pimpl_->error_ = "unknown XSLT parser error"; - throw std::runtime_error(pimpl_->error_); + if ( (pimpl_->ss_ = xsltParseStylesheetDoc(xmldoc)) == 0) + { + // TODO error_ can't get set yet. Need changes from libxslt first + if (pimpl_->error_.empty()) + pimpl_->error_ = "unknown XSLT parser error"; + throw std::runtime_error(pimpl_->error_); } - /* - * if we got this far, the xmldoc we gave to xsltParseStylesheetDoc is - * now owned by the stylesheet and will be cleaned up in our destructor. - */ + // if we got this far, the xmldoc we gave to xsltParseStylesheetDoc is + // now owned by the stylesheet and will be cleaned up in our destructor. parser.get_document().release_doc_data(); ap.release(); } -//#################################################################### -xslt::stylesheet::stylesheet (xml::document doc) { + + +xslt::stylesheet::stylesheet(xml::document doc) +{ xmlDocPtr xmldoc = static_cast<xmlDocPtr>(doc.get_doc_data()); std::auto_ptr<pimpl> ap(pimpl_ = new pimpl); - if ( (pimpl_->ss_ = xsltParseStylesheetDoc(xmldoc)) == 0) { - // TODO error_ can't get set yet. Need changes from libxslt first - if (pimpl_->error_.empty()) pimpl_->error_ = "unknown XSLT parser error"; - throw std::runtime_error(pimpl_->error_); + if ( (pimpl_->ss_ = xsltParseStylesheetDoc(xmldoc)) == 0) + { + // TODO error_ can't get set yet. Need changes from libxslt first + if (pimpl_->error_.empty()) + pimpl_->error_ = "unknown XSLT parser error"; + throw std::runtime_error(pimpl_->error_); } - /* - * if we got this far, the xmldoc we gave to xsltParseStylesheetDoc is - * now owned by the stylesheet and will be cleaned up in our destructor. - */ + // if we got this far, the xmldoc we gave to xsltParseStylesheetDoc is + // now owned by the stylesheet and will be cleaned up in our destructor. doc.release_doc_data(); ap.release(); } -//#################################################################### -xslt::stylesheet::~stylesheet (void) { - if (pimpl_->ss_) xsltFreeStylesheet(pimpl_->ss_); + + +xslt::stylesheet::~stylesheet() +{ + if (pimpl_->ss_) + xsltFreeStylesheet(pimpl_->ss_); delete pimpl_; } -//#################################################################### -bool xslt::stylesheet::apply (const xml::document &doc, xml::document &result) { + + +bool xslt::stylesheet::apply(const xml::document &doc, xml::document &result) +{ xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); - if (xmldoc) { - result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); - return true; + if (xmldoc) + { + result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); + return true; } return false; } -//#################################################################### -bool xslt::stylesheet::apply (const xml::document &doc, xml::document &result, const param_type &with_params) { + + +bool xslt::stylesheet::apply(const xml::document &doc, xml::document &result, + const param_type &with_params) +{ xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); - if (xmldoc) { - result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); - return true; + if (xmldoc) + { + result.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); + return true; } return false; } -//#################################################################### -xml::document& xslt::stylesheet::apply (const xml::document &doc) { + + +xml::document& xslt::stylesheet::apply(const xml::document &doc) +{ xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); - if (xmldoc == 0) { - if (pimpl_->error_.empty()) pimpl_->error_ = "unknown XSLT transformation error"; - throw std::runtime_error(pimpl_->error_); + if (xmldoc == 0) + { + if (pimpl_->error_.empty()) + pimpl_->error_ = "unknown XSLT transformation error"; + throw std::runtime_error(pimpl_->error_); } pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; } -//#################################################################### -xml::document& xslt::stylesheet::apply (const xml::document &doc, const param_type &with_params) { + + +xml::document& xslt::stylesheet::apply(const xml::document &doc, + const param_type &with_params) +{ xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); - if (xmldoc == 0) { - if (pimpl_->error_.empty()) pimpl_->error_ = "unknown XSLT transformation error"; - throw std::runtime_error(pimpl_->error_); + if (xmldoc == 0) + { + if (pimpl_->error_.empty()) + pimpl_->error_ = "unknown XSLT transformation error"; + throw std::runtime_error(pimpl_->error_); } pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; } -//#################################################################### -const std::string& xslt::stylesheet::get_error_message (void) const { - return pimpl_->error_; -} -//#################################################################### -namespace { - //#################################################################### - void make_vector_param (std::vector<const char*> &v, const xslt::stylesheet::param_type &p) { - v.reserve(p.size()); - xslt::stylesheet::param_type::const_iterator i=p.begin(), end=p.end(); - for (; i!=end; ++i) { - v.push_back(i->first.c_str()); - v.push_back(i->second.c_str()); - } - v.push_back(static_cast<const char*>(0)); - } - //#################################################################### - xmlDocPtr apply_stylesheet (xsltStylesheetPtr s, xmlDocPtr d, const xslt::stylesheet::param_type *p) { - /* - * TODO TODO TODO TODO - * - * use a transform context to capture error messages - * - * TODO TODO TODO TODO - */ - std::vector<const char*> v; - if (p) make_vector_param(v, *p); - return xsltApplyStylesheet(s, d, p ? &v[0] : 0); - } - //#################################################################### +const std::string& xslt::stylesheet::get_error_message() const +{ + return pimpl_->error_; } -//#################################################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-06-02 16:20:13
|
Revision: 149 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=149&view=rev Author: vaclavslavik Date: 2009-06-02 16:20:11 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Fixed xslt::stylesheet::apply() to detect and report errors. Modified Paths: -------------- trunk/NEWS trunk/include/xsltwrapp/stylesheet.h trunk/src/libxslt/init.cxx trunk/src/libxslt/stylesheet.cxx trunk/tests/xslt/test_xslt.cxx Added Paths: ----------- trunk/tests/xslt/data/with_errors.xsl Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-05-31 18:54:31 UTC (rev 148) +++ trunk/NEWS 2009-06-02 16:20:11 UTC (rev 149) @@ -5,6 +5,8 @@ Converted test suite to Boost Test. + Fixed xslt::stylesheet::apply() to detect and report errors. + Version 0.6.0 Fixed libxmlwrapp to not depend on libxslt if XSLT support Modified: trunk/include/xsltwrapp/stylesheet.h =================================================================== --- trunk/include/xsltwrapp/stylesheet.h 2009-05-31 18:54:31 UTC (rev 148) +++ trunk/include/xsltwrapp/stylesheet.h 2009-06-02 16:20:11 UTC (rev 149) @@ -58,6 +58,8 @@ class stylesheet { public: + struct pimpl; + /// Type for passing parameters to the stylesheet typedef std::map<std::string, std::string> param_type; @@ -160,7 +162,6 @@ const std::string& get_error_message() const; private: - struct pimpl; pimpl *pimpl_; // an xslt::stylesheet cannot yet be copied or assigned to. Modified: trunk/src/libxslt/init.cxx =================================================================== --- trunk/src/libxslt/init.cxx 2009-05-31 18:54:31 UTC (rev 148) +++ trunk/src/libxslt/init.cxx 2009-06-02 16:20:11 UTC (rev 149) @@ -49,7 +49,8 @@ extern "C" void xslt_error(void *, const char*, ...) { - // don't do anything + // don't do anything; we install context-specific error handler to + // catch errors while applying a stylesheet } } // anonymous namespace @@ -79,7 +80,8 @@ // set some defautls process_xincludes(true); - // keep libxslt silent + // keep libxslt silent; we install context-specific error handler to + // catch errors while applying a stylesheet xsltSetGenericErrorFunc(0, xslt_error); xsltSetGenericDebugFunc(0, xslt_error); Modified: trunk/src/libxslt/stylesheet.cxx =================================================================== --- trunk/src/libxslt/stylesheet.cxx 2009-05-31 18:54:31 UTC (rev 148) +++ trunk/src/libxslt/stylesheet.cxx 2009-06-02 16:20:11 UTC (rev 149) @@ -57,6 +57,17 @@ #include <vector> #include <map> + +struct xslt::stylesheet::pimpl +{ + pimpl (void) : ss_(0), errors_occured_(false) { } + + xsltStylesheetPtr ss_; + xml::document doc_; + std::string error_; + bool errors_occured_; +}; + namespace { @@ -110,35 +121,76 @@ } -xmlDocPtr apply_stylesheet(xsltStylesheetPtr s, xmlDocPtr d, +extern "C" void xsltwrapp_error_cb(void *c, const char *message, ...) +{ + xsltTransformContextPtr ctxt = static_cast<xsltTransformContextPtr>(c); + xslt::stylesheet::pimpl *impl = static_cast<xslt::stylesheet::pimpl*>(ctxt->_private); + + impl->errors_occured_ = true; + + // tell the processor to stop when it gets a chance: + if ( ctxt->state == XSLT_STATE_OK ) + ctxt->state = XSLT_STATE_STOPPED; + + // concatenate all error messages: + if ( impl->errors_occured_ ) + impl->error_.append("\n"); + + std::string formatted; + + va_list ap; + va_start(ap, message); + xml::impl::printf2string(formatted, message, ap); + va_end(ap); + + impl->error_.append(formatted); +} + + +xmlDocPtr apply_stylesheet(xslt::stylesheet::pimpl *impl, + xmlDocPtr doc, const xslt::stylesheet::param_type *p = NULL) { - /* - * TODO TODO TODO TODO - * - * use a transform context to capture error messages - * - * TODO TODO TODO TODO - */ + xsltStylesheetPtr style = impl->ss_; + std::vector<const char*> v; if (p) make_vector_param(v, *p); - return xsltApplyStylesheet(s, d, p ? &v[0] : 0); -} -} // end of anonymous namespace + xsltTransformContextPtr ctxt = xsltNewTransformContext(style, doc); + ctxt->_private = impl; + xsltSetTransformErrorFunc(ctxt, ctxt, xsltwrapp_error_cb); + // clear the error flag before applying the stylesheet + impl->errors_occured_ = false; -struct xslt::stylesheet::pimpl -{ - pimpl (void) : ss_(0) { } + xmlDocPtr result = + xsltApplyStylesheetUser(style, doc, p ? &v[0] : 0, NULL, NULL, ctxt); - xsltStylesheetPtr ss_; - xml::document doc_; - std::string error_; -}; + xsltFreeTransformContext(ctxt); + // it's possible there was an error that didn't prevent creation of some + // (incorrect) document + if ( result && impl->errors_occured_ ) + { + xmlFreeDoc(result); + return NULL; + } + if ( !result ) + { + // set generic error message if nothing more specific is known + if ( impl->error_.empty() ) + impl->error_ = "unknown XSLT transformation error"; + return NULL; + } + + return result; +} + +} // end of anonymous namespace + + xslt::stylesheet::stylesheet(const char *filename) { std::auto_ptr<pimpl> ap(pimpl_ = new pimpl); @@ -192,7 +244,7 @@ bool xslt::stylesheet::apply(const xml::document &doc, xml::document &result) { xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_, input); if (xmldoc) { @@ -208,7 +260,7 @@ const param_type &with_params) { xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_, input, &with_params); if (xmldoc) { @@ -223,14 +275,10 @@ xml::document& xslt::stylesheet::apply(const xml::document &doc) { xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_, input); - if (xmldoc == 0) - { - if (pimpl_->error_.empty()) - pimpl_->error_ = "unknown XSLT transformation error"; + if ( !xmldoc ) throw std::runtime_error(pimpl_->error_); - } pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; @@ -241,14 +289,10 @@ const param_type &with_params) { xmlDocPtr input = static_cast<xmlDocPtr>(doc.get_doc_data_read_only()); - xmlDocPtr xmldoc = apply_stylesheet(pimpl_->ss_, input, &with_params); + xmlDocPtr xmldoc = apply_stylesheet(pimpl_, input, &with_params); - if (xmldoc == 0) - { - if (pimpl_->error_.empty()) - pimpl_->error_ = "unknown XSLT transformation error"; + if ( !xmldoc ) throw std::runtime_error(pimpl_->error_); - } pimpl_->doc_.set_doc_data_from_xslt(xmldoc, new result_impl(xmldoc, pimpl_->ss_)); return pimpl_->doc_; Added: trunk/tests/xslt/data/with_errors.xsl =================================================================== --- trunk/tests/xslt/data/with_errors.xsl (rev 0) +++ trunk/tests/xslt/data/with_errors.xsl 2009-06-02 16:20:11 UTC (rev 149) @@ -0,0 +1,19 @@ +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="xml"/> + + <xsl:template name="foo"> + <output> + <xsl:value-of select="$x"/> + </output> + <!-- this is intentionally invalid: the parameters must be declared + at the top of the template --> + <xsl:param name="x"/> + </xsl:template> + + <xsl:template match="/"> + <xsl:call-template name="foo"> + <xsl:with-param name="x">42</xsl:with-param> + </xsl:call-template> + </xsl:template> + +</xsl:stylesheet> Modified: trunk/tests/xslt/test_xslt.cxx =================================================================== --- trunk/tests/xslt/test_xslt.cxx 2009-05-31 18:54:31 UTC (rev 148) +++ trunk/tests/xslt/test_xslt.cxx 2009-06-02 16:20:11 UTC (rev 149) @@ -131,4 +131,30 @@ } +/* + * Tests libxslt errors reporting + */ + +BOOST_AUTO_TEST_CASE( xsl_with_errors ) +{ + xslt::stylesheet style(test_file_path("xslt/data/with_errors.xsl").c_str()); + xml::tree_parser parser(test_file_path("xslt/data/input.xml").c_str()); + + xml::document result; + BOOST_CHECK( !style.apply(parser.get_document(), result) ); +} + +BOOST_AUTO_TEST_CASE( xsl_with_errors_throw ) +{ + xslt::stylesheet style(test_file_path("xslt/data/with_errors.xsl").c_str()); + xml::tree_parser parser(test_file_path("xslt/data/input.xml").c_str()); + + BOOST_CHECK_THROW + ( + style.apply(parser.get_document()), + std::exception + ); +} + + BOOST_AUTO_TEST_SUITE_END() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-06-02 17:03:22
|
Revision: 151 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=151&view=rev Author: vaclavslavik Date: 2009-06-02 17:03:19 +0000 (Tue, 02 Jun 2009) Log Message: ----------- updated version number to 0.6.1 in preparation for release Modified Paths: -------------- trunk/NEWS trunk/configure.ac Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-06-02 16:42:51 UTC (rev 150) +++ trunk/NEWS 2009-06-02 17:03:19 UTC (rev 151) @@ -1,3 +1,5 @@ +Version 0.6.1 + Added Visual C++ 200x projects and fixed VC6 project. Fixed xml::event_parser::parse_stream() to return false on empty Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-06-02 16:42:51 UTC (rev 150) +++ trunk/configure.ac 2009-06-02 17:03:19 UTC (rev 151) @@ -36,7 +36,7 @@ AC_REVISION($Id$)dnl AC_PREREQ(2.62) -AC_INIT(xmlwrapp, 0.6.0, [xml...@li...]) +AC_INIT(xmlwrapp, 0.6.1, [xml...@li...]) AC_CONFIG_SRCDIR([xmlwrapp.pc.in]) AC_CONFIG_AUX_DIR([admin]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-07-25 16:31:08
|
Revision: 160 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=160&view=rev Author: vaclavslavik Date: 2009-07-25 16:31:00 +0000 (Sat, 25 Jul 2009) Log Message: ----------- Fixed xml::tree_parser to fail on non-fatal parser errors (patch by Sergey Satskiy) Modified Paths: -------------- trunk/AUTHORS trunk/NEWS trunk/src/libxml/tree_parser.cxx trunk/tests/tree/test_tree.cxx Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2009-07-07 10:00:48 UTC (rev 159) +++ trunk/AUTHORS 2009-07-25 16:31:00 UTC (rev 160) @@ -7,6 +7,7 @@ Tom Browder <tbr...@us...> Other contributors: + Sergey Satskiy <ser...@gm...> Vadim Zeitlin <va...@tt...> Tiziano Mueller <ti...@us...> Greg Chicares <gch...@sb...> Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-07-07 10:00:48 UTC (rev 159) +++ trunk/NEWS 2009-07-25 16:31:00 UTC (rev 160) @@ -1,3 +1,6 @@ + + Fixed xml::tree_parser to fail on non-fatal parser errors. + Version 0.6.1 Added Visual C++ 200x projects and fixed VC6 project. Modified: trunk/src/libxml/tree_parser.cxx =================================================================== --- trunk/src/libxml/tree_parser.cxx 2009-07-07 10:00:48 UTC (rev 159) +++ trunk/src/libxml/tree_parser.cxx 2009-07-25 16:31:00 UTC (rev 160) @@ -106,6 +106,8 @@ tree_impl *p = static_cast<tree_impl*>(ctxt->_private); if (!p) return; // handle bug in older versions of libxml + p->okay_ = false; + va_list ap; va_start(ap, message); printf2string(p->last_error_, message, ap); @@ -137,14 +139,24 @@ xml::tree_parser::tree_parser (const char *name, bool allow_exceptions) { std::auto_ptr<tree_impl> ap(pimpl_ = new tree_impl); + pimpl_->okay_ = true; xmlDocPtr tmpdoc = xmlSAXParseFileWithData(&(pimpl_->sax_), name, 0, pimpl_); - if (allow_exceptions && !tmpdoc) throw std::runtime_error(pimpl_->last_error_); - if (tmpdoc) { - pimpl_->doc_.set_doc_data(tmpdoc); - pimpl_->okay_ = true; + if (tmpdoc && pimpl_->okay_) + { + // all is fine + pimpl_->doc_.set_doc_data(tmpdoc); } + else + { + // a problem appeared + if (tmpdoc) + xmlFreeDoc(tmpdoc); + if (allow_exceptions) + throw std::runtime_error(pimpl_->last_error_); + } + ap.release(); } //#################################################################### @@ -161,16 +173,21 @@ ctxt->_private = pimpl_; - xmlParseDocument(ctxt); + pimpl_->okay_ = true; + const int retval = xmlParseDocument(ctxt); - if (!ctxt->wellFormed) { - xmlFreeDoc(ctxt->myDoc); - ctxt->myDoc = 0; - ctxt->sax = 0; - xmlFreeParserCtxt(ctxt); + if (!ctxt->wellFormed || retval != 0 || !pimpl_->okay_) { + xmlFreeDoc(ctxt->myDoc); + ctxt->myDoc = 0; + ctxt->sax = 0; + xmlFreeParserCtxt(ctxt); + pimpl_->okay_ = false; - if (allow_exceptions) throw std::runtime_error(pimpl_->last_error_); - ap.release(); return; // handle non-exception case + if (allow_exceptions) + throw std::runtime_error(pimpl_->last_error_); + + ap.release(); + return; // handle non-exception case } pimpl_->doc_.set_doc_data(ctxt->myDoc); Modified: trunk/tests/tree/test_tree.cxx =================================================================== --- trunk/tests/tree/test_tree.cxx 2009-07-07 10:00:48 UTC (rev 159) +++ trunk/tests/tree/test_tree.cxx 2009-07-25 16:31:00 UTC (rev 160) @@ -186,4 +186,31 @@ } + +namespace +{ + +// this is invalid markup, libxml2 fails with +// namespace error : Namespace prefix a on book is not defined +const std::string XMLDATA_BAD_NS = + "<a:book> xmlns:a=\"a\" <title>title</title></a:book>"; + +} // anonymous namespace + +BOOST_AUTO_TEST_CASE( bad_ns_xml_data_throw ) +{ + + BOOST_CHECK_THROW + ( + xml::tree_parser parser( XMLDATA_BAD_NS.c_str(), XMLDATA_BAD_NS.size()), + std::exception + ); +} + +BOOST_AUTO_TEST_CASE( bad_ns_xml_data_no_throw ) +{ + xml::tree_parser parser(XMLDATA_BAD_NS.c_str(), XMLDATA_BAD_NS.size(), false); + BOOST_CHECK( !parser ); // failed +} + BOOST_AUTO_TEST_SUITE_END() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2009-12-20 11:28:28
|
Revision: 162 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=162&view=rev Author: vaclavslavik Date: 2009-12-20 11:28:20 +0000 (Sun, 20 Dec 2009) Log Message: ----------- Reformatted source code for better readibility. Modified Paths: -------------- trunk/include/xmlwrapp/_cbfo.h trunk/include/xmlwrapp/attributes.h trunk/include/xmlwrapp/document.h trunk/include/xmlwrapp/event_parser.h trunk/include/xmlwrapp/init.h trunk/include/xmlwrapp/node.h trunk/include/xmlwrapp/nodes_view.h trunk/include/xmlwrapp/tree_parser.h trunk/include/xmlwrapp/xmlwrapp.h trunk/include/xsltwrapp/xsltwrapp.h trunk/src/libxml/ait_impl.cxx trunk/src/libxml/ait_impl.h trunk/src/libxml/attributes.cxx trunk/src/libxml/document.cxx trunk/src/libxml/dtd_impl.cxx trunk/src/libxml/dtd_impl.h trunk/src/libxml/event_parser.cxx trunk/src/libxml/init.cxx trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx trunk/src/libxml/node_iterator.h trunk/src/libxml/node_manip.cxx trunk/src/libxml/node_manip.h trunk/src/libxml/nodes_view.cxx trunk/src/libxml/tree_parser.cxx trunk/src/libxml/utility.cxx trunk/src/libxml/utility.h Modified: trunk/include/xmlwrapp/_cbfo.h =================================================================== --- trunk/include/xmlwrapp/_cbfo.h 2009-11-26 14:30:19 UTC (rev 161) +++ trunk/include/xmlwrapp/_cbfo.h 2009-12-20 11:28:20 UTC (rev 162) @@ -35,27 +35,35 @@ #include <functional> -namespace xml { +namespace xml +{ class node; -namespace impl { +namespace impl +{ - struct cbfo_node_compare : public std::binary_function<xml::node, xml::node, bool> { - virtual ~cbfo_node_compare (void) { } - virtual bool operator() (const xml::node &lhs, const xml::node &rhs) = 0; + // helper for xml::node::sort() + struct cbfo_node_compare + : public std::binary_function<xml::node, xml::node, bool> + { + virtual ~cbfo_node_compare() {} + virtual bool operator()(const xml::node& lhs, const xml::node& rhs) = 0; }; - template <typename T> struct sort_callback : public cbfo_node_compare { - sort_callback (T &t) : t_(t) { } + template<typename T> + struct sort_callback : public cbfo_node_compare + { + sort_callback(T& t) : t_(t) {} - bool operator() (const xml::node &lhs, const xml::node &rhs) - { return t_(lhs, rhs); } + bool operator()(const xml::node& lhs, const xml::node& rhs) + { return t_(lhs, rhs); } - T &t_; + T &t_; }; } // namespace impl } // namespace xml -#endif + +#endif // _xmlwrapp_cbfo_h_ Modified: trunk/include/xmlwrapp/attributes.h =================================================================== --- trunk/include/xmlwrapp/attributes.h 2009-11-26 14:30:19 UTC (rev 161) +++ trunk/include/xmlwrapp/attributes.h 2009-12-20 11:28:20 UTC (rev 162) @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the definition of the xml::attributes class. -**/ +/** + @file + This file contains the definition of the xml::attributes class. + */ + #ifndef _xmlwrapp_attributes_h_ #define _xmlwrapp_attributes_h_ @@ -45,334 +47,308 @@ #include <iosfwd> #include <string> -namespace xml { - +namespace xml +{ + // forward declarations class node; -namespace impl { +namespace impl +{ class ait_impl; struct node_impl; } /** - * The xml::attributes class is used to access all the attributes of one - * xml::node. You can add, find and erase attributes by name, and for some - * member functions, use the provided iterator classes. - * - * The iterator classes allow you to access one XML attribute. This is done - * using the xml::attributes::attr class interface. -**/ -class attributes { + The xml::attributes class is used to access all the attributes of one + xml::node. You can add, find and erase attributes by name, and for some + member functions, use the provided iterator classes. + + The iterator classes allow you to access one XML attribute. This is done + using the xml::attributes::attr class interface. + */ +class attributes +{ public: - typedef std::size_t size_type; ///< size type + /// size type + typedef std::size_t size_type; - //#################################################################### - /** - * Create a new xml::attributes object with no attributes. - * - * @author Peter Jones - **/ - //#################################################################### - attributes (void); + /** + Create a new xml::attributes object with no attributes. - //#################################################################### - /** - * Copy construct a xml::attributes object. - * - * @param other The xml::attributes object to copy from. - * @author Peter Jones - **/ - //#################################################################### - attributes (const attributes &other); + @author Peter Jones + */ + attributes(); - //#################################################################### - /** - * Copy the given xml::attributes object into this one. - * - * @param other The xml::attributes object to copy from. - * @return *this. - * @author Peter Jones - **/ - //#################################################################### - attributes& operator= (const attributes &other); + /** + Copy construct a xml::attributes object. - //#################################################################### - /** - * Swap this xml::attributes object with another one. - * - * @param other The other xml::attributes object to swap with. - * @author Peter Jones - **/ - //#################################################################### - void swap (attributes &other); + @param other The xml::attributes object to copy from. + @author Peter Jones + */ + attributes(const attributes& other); - //#################################################################### - /** - * Clean up after a xml::attributes object. - * - * @author Peter Jones - **/ - //#################################################################### - ~attributes (void); + /** + Copy the given xml::attributes object into this one. + @param other The xml::attributes object to copy from. + @return this. + @author Peter Jones + */ + attributes& operator=(const attributes& other); + + /** + Swap this xml::attributes object with another one. + + @param other The other xml::attributes object to swap with. + @author Peter Jones + */ + void swap(attributes& other); + + ~attributes(); + // forward declarations class const_iterator; /** - * The xml::attributes::attr class is used to hold information about one - * attribute. + The xml::attributes::attr class is used to hold information about one + attribute. */ - class attr { + class attr + { public: - //#################################################################### - /** - * Get the name of this attribute. - * - * @return The name for this attribute. - * @author Peter Jones - **/ - //#################################################################### - const char* get_name (void) const; + /** + Get the name of this attribute. - //#################################################################### - /** - * Get the value of this attribute. - * - * @return The value for this attribute. - * @author Peter Jones - **/ - //#################################################################### - const char* get_value (void) const; + @return The name for this attribute. + @author Peter Jones + */ + const char *get_name() const; + + /** + Get the value of this attribute. + + @return The value for this attribute. + @author Peter Jones + */ + const char* get_value() const; + private: - void *node_; - void *prop_; - std::string name_; - mutable std::string value_; + void *node_; + void *prop_; + std::string name_; + mutable std::string value_; - attr (void); - attr (const attr &other); - attr& operator= (const attr &other); - void swap (attr &other); + attr(); + attr(const attr& other); + attr& operator=(const attr& other); + void swap(attr& other); - void set_data (void *node, void *prop); - void set_data (const char *name, const char *value, bool); - friend class impl::ait_impl; - }; // end xml::attributes::attr class + void set_data(void *node, void *prop); + void set_data(const char *name, const char *value, bool); + friend class impl::ait_impl; + }; + /** - * Iterator class for accessing attribute pairs. + Iterator class for accessing attribute pairs. */ - class iterator { + class iterator + { public: - typedef attr value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::forward_iterator_tag iterator_category; + typedef attr value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::forward_iterator_tag iterator_category; - iterator (void); - iterator (const iterator &other); - iterator& operator= (const iterator& other); - ~iterator (void); + iterator(); + iterator(const iterator& other); + iterator& operator=(const iterator& other); + ~iterator(); - reference operator* (void) const; - pointer operator-> (void) const; + reference operator*() const; + pointer operator->() const; - /// prefix increment - iterator& operator++ (void); + /// prefix increment + iterator& operator++(); - /// postfix increment (avoid if possible for better performance) - iterator operator++ (int); + /// postfix increment (avoid if possible for better performance) + iterator operator++(int); - friend bool operator== (const iterator &lhs, const iterator &rhs); - friend bool operator!= (const iterator &lhs, const iterator &rhs); + friend bool operator==(const iterator& lhs, const iterator& rhs); + friend bool operator!=(const iterator& lhs, const iterator& rhs); + private: - impl::ait_impl *pimpl_; - iterator (void *node, void *prop); - iterator (const char *name, const char *value, bool); - void swap (iterator &other); - void* get_raw_attr (void); - friend class attributes; - friend class const_iterator; - }; // end xml::attributes::iterator class + impl::ait_impl *pimpl_; + iterator(void *node, void *prop); + iterator(const char *name, const char *value, bool); + void swap(iterator& other); + void* get_raw_attr(); + + friend class attributes; + friend class const_iterator; + }; + /** - * Const Iterator class for accessing attribute pairs. + Const Iterator class for accessing attribute pairs. */ - class const_iterator { + class const_iterator + { public: - typedef const attr value_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef value_type& reference; - typedef std::forward_iterator_tag iterator_category; + typedef const attr value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef std::forward_iterator_tag iterator_category; - const_iterator (void); - const_iterator (const const_iterator &other); - const_iterator (const iterator &other); - const_iterator& operator= (const const_iterator& other); - ~const_iterator (void); + const_iterator(); + const_iterator(const const_iterator& other); + const_iterator(const iterator& other); + const_iterator& operator=(const const_iterator& other); + ~const_iterator(); - reference operator* (void) const; - pointer operator-> (void) const; + reference operator*() const; + pointer operator->() const; - /// prefix increment - const_iterator& operator++ (void); + /// prefix increment + const_iterator& operator++(); - /// postfix increment (avoid if possible better for performance) - const_iterator operator++ (int); + /// postfix increment (avoid if possible better for performance) + const_iterator operator++ (int); - friend bool operator== (const const_iterator &lhs, const const_iterator &rhs); - friend bool operator!= (const const_iterator &lhs, const const_iterator &rhs); + friend bool operator== (const const_iterator &lhs, const const_iterator &rhs); + friend bool operator!= (const const_iterator &lhs, const const_iterator &rhs); + private: - impl::ait_impl *pimpl_; - const_iterator (void *node, void *prop); - const_iterator (const char *name, const char *value, bool); - void swap (const_iterator &other); - void* get_raw_attr (void); - friend class attributes; - }; // end xml::attributes::const_iterator class + impl::ait_impl *pimpl_; - //#################################################################### - /** - * Get an iterator that points to the first attribute. - * - * @return An iterator that points to the first attribute. - * @return An iterator equal to end() if there are no attributes. - * @see xml::attributes::iterator - * @see xml::attributes::attr - * @author Peter Jones - **/ - //#################################################################### - iterator begin (void); + const_iterator(void *node, void *prop); + const_iterator(const char *name, const char *value, bool); + void swap(const_iterator &other); + void* get_raw_attr(); - //#################################################################### - /** - * Get a const_iterator that points to the first attribute. - * - * @return A const_iterator that points to the first attribute. - * @return A const_iterator equal to end() if there are no attributes. - * @see xml::attributes::const_iterator - * @see xml::attributes::attr - * @author Peter Jones - **/ - //#################################################################### - const_iterator begin (void) const; + friend class attributes; + }; - //#################################################################### - /** - * Get an iterator that points one past the the last attribute. - * - * @return An "end" iterator. - * @author Peter Jones - **/ - //#################################################################### - iterator end (void); + /** + Get an iterator that points to the first attribute. - //#################################################################### - /** - * Get a const_iterator that points one past the last attribute. - * - * @return An "end" const_iterator. - * @author Peter Jones - **/ - //#################################################################### - const_iterator end (void) const; + @return An iterator that points to the first attribute. + @return An iterator equal to end() if there are no attributes. + @see xml::attributes::iterator + @see xml::attributes::attr + @author Peter Jones + */ + iterator begin(); - //#################################################################### - /** - * Add an attribute to the attributes list. If there is another - * attribute with the same name, it will be replaced with this one. - * - * @param name The name of the attribute to add. - * @param value The value of the attribute to add. - * @author Peter Jones - **/ - //#################################################################### - void insert (const char *name, const char *value); + /** + Get a const_iterator that points to the first attribute. - //#################################################################### - /** - * Find the attribute with the given name. If the attribute is not found - * on the current node, the DTD will be searched for a default value. - * This is, of course, if there was a DTD parsed with the XML document. - * - * @param name The name of the attribute to find. - * @return An iterator that points to the attribute with the given name. - * @return If the attribute was not found, find will return end(). - * @see xml::attributes::iterator - * @see xml::attributes::attr - * @author Peter Jones - **/ - //#################################################################### - iterator find (const char *name); + @return A const_iterator that points to the first attribute. + @return A const_iterator equal to end() if there are no attributes. + @see xml::attributes::const_iterator + @see xml::attributes::attr + @author Peter Jones + */ + const_iterator begin() const; - //#################################################################### - /** - * Find the attribute with the given name. If the attribute is not found - * on the current node, the DTD will be searched for a default value. - * This is, of course, if there was a DTD parsed with the XML document. - * - * @param name The name of the attribute to find. - * @return A const_iterator that points to the attribute with the given name. - * @return If the attribute was not found, find will return end(). - * @see xml::attributes::const_iterator - * @see xml::attributes::attr - * @author Peter Jones - **/ - //#################################################################### - const_iterator find (const char *name) const; + /** + Get an iterator that points one past the the last attribute. - //#################################################################### - /** - * Erase the attribute that is pointed to by the given iterator. This - * will invalidate any iterators for this attribute, as well as any - * pointers or references to it. - * - * @param to_erase An iterator that points to the attribute to erased. - * @return An iterator that points to the attribute after the one to be erased. - * @see xml::attributes::iterator - * @see xml::attributes::attr - * @author Peter Jones - **/ - //#################################################################### - iterator erase (iterator to_erase); + @return An "end" iterator. + @author Peter Jones + */ + iterator end(); - //#################################################################### - /** - * Erase the attribute with the given name. This will invalidate any - * iterators that are pointing to that attribute, as well as any - * pointers or references to that attribute. - * - * @param name The name of the attribute to erase. - * @author Peter Jones - **/ - //#################################################################### - void erase (const char *name); + /** + Get a const_iterator that points one past the last attribute. - //#################################################################### - /** - * Find out if there are any attributes in this xml::attributes object. - * - * @return True if there are no attributes. - * @return False if there is at least one attribute. - * @author Peter Jones - **/ - //#################################################################### - bool empty (void) const; + @return An "end" const_iterator. + @author Peter Jones + */ + const_iterator end() const; - //#################################################################### - /** - * Find out how many attributes there are in this xml::attributes - * object. - * - * @return The number of attributes in this xml::attributes object. - * @author Peter Jones - **/ - //#################################################################### - size_type size (void) const; + /** + Add an attribute to the attributes list. If there is another + attribute with the same name, it will be replaced with this one. + @param name The name of the attribute to add. + @param value The value of the attribute to add. + @author Peter Jones + */ + void insert(const char *name, const char *value); + + /** + Find the attribute with the given name. If the attribute is not found + on the current node, the DTD will be searched for a default value. + This is, of course, if there was a DTD parsed with the XML document. + + @param name The name of the attribute to find. + @return An iterator that points to the attribute with the given name. + @return If the attribute was not found, find will return end(). + @see xml::attributes::iterator + @see xml::attributes::attr + @author Peter Jones + */ + iterator find(const char *name); + + /** + Find the attribute with the given name. If the attribute is not found + on the current node, the DTD will be searched for a default value. + This is, of course, if there was a DTD parsed with the XML document. + + @param name The name of the attribute to find. + @return A const_iterator that points to the attribute with the given name. + @return If the attribute was not found, find will return end(). + @see xml::attributes::const_iterator + @see xml::attributes::attr + @author Peter Jones + */ + const_iterator find(const char *name) const; + + /** + Erase the attribute that is pointed to by the given iterator. This + will invalidate any iterators for this attribute, as well as any + pointers or references to it. + + @param to_erase An iterator that points to the attribute to erased. + @return An iterator that points to the attribute after the one to be erased. + @see xml::attributes::iterator + @see xml::attributes::attr + @author Peter Jones + */ + iterator erase(iterator to_erase); + + /** + Erase the attribute with the given name. This will invalidate any + iterators that are pointing to that attribute, as well as any + pointers or references to that attribute. + + @param name The name of the attribute to erase. + @author Peter Jones + */ + void erase(const char *name); + + /** + Find out if there are any attributes in this xml::attributes object. + + @return True if there are no attributes. + @return False if there is at least one attribute. + @author Peter Jones + */ + bool empty() const; + + /** + Find out how many attributes there are in this xml::attributes + object. + + @return The number of attributes in this xml::attributes object. + @author Peter Jones + */ + size_type size() const; + private: struct pimpl; pimpl *pimpl_; @@ -380,10 +356,11 @@ explicit attributes (int); void set_data (void *node); - void* get_data (void); + void* get_data(); friend struct impl::node_impl; friend class node; -}; // end xml::attributes class - -} // end xml namespace -#endif +}; + +} // namespace xml + +#endif // _xmlwrapp_attributes_h_ Modified: trunk/include/xmlwrapp/document.h =================================================================== --- trunk/include/xmlwrapp/document.h 2009-11-26 14:30:19 UTC (rev 161) +++ trunk/include/xmlwrapp/document.h 2009-12-20 11:28:20 UTC (rev 162) @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the definition of the xml::document class. -**/ +/** + @file + This file contains the definition of the xml::document class. + */ + #ifndef _xmlwrapp_document_h_ #define _xmlwrapp_document_h_ @@ -47,508 +49,448 @@ #include <cstddef> // forward declaration -namespace xslt { - class stylesheet; - namespace impl { - class result; - } +namespace xslt +{ + +class stylesheet; +namespace impl +{ +class result; +} + } // end xslt namespace -namespace xml { +namespace xml +{ // forward declarations class tree_parser; -namespace impl { +namespace impl +{ struct doc_impl; } /** - * The xml::document class is used to hold the XML tree and various bits of - * information about it. -**/ -class document { + The xml::document class is used to hold the XML tree and various bits of + information about it. + */ +class document +{ public: /// size type typedef std::size_t size_type; - //#################################################################### - /** - * Create a new XML document with the default settings. The new document - * will contain a root node with a name of "blank". - * - * @author Peter Jones - **/ - //#################################################################### - document (void); + /** + Create a new XML document with the default settings. The new document + will contain a root node with a name of "blank". - //#################################################################### - /** - * Create a new XML document and set the name of the root element to the - * given text. - * - * @param root_name What to set the name of the root element to. - * @author Peter Jones - **/ - //#################################################################### - explicit document (const char *root_name); + @author Peter Jones + */ + document(); - //#################################################################### - /** - * Create a new XML document and set the root node. - * - * @param n The node to use as the root node. n will be copied. - * @author Peter Jones - **/ - //#################################################################### - explicit document (const node &n); + /** + Create a new XML document and set the name of the root element to the + given text. - //#################################################################### - /** - * Copy construct a new XML document. The new document will be an exact - * copy of the original. - * - * @param other The other document object to copy from. - * @author Peter Jones - **/ - //#################################################################### - document (const document &other); + @param root_name What to set the name of the root element to. + @author Peter Jones + */ + explicit document(const char *root_name); - //#################################################################### - /** - * Copy another document object into this one using the assignment - * operator. This document object will be an exact copy of the other - * document after the assignement. - * - * @param other The document to copy from. - * @return *this. - * @author Peter Jones - **/ - //#################################################################### - document& operator= (const document &other); + /** + Create a new XML document and set the root node. - //#################################################################### - /** - * Swap one xml::document object for another. - * - * @param other The other document to swap - * @author Peter Jones - **/ - //#################################################################### - void swap (document &other); + @param n The node to use as the root node. n will be copied. + @author Peter Jones + */ + explicit document(const node& n); - //#################################################################### - /** - * Clean up after an XML document object. - * - * @author Peter Jones - **/ - //#################################################################### - ~document (void); + /** + Copy construct a new XML document. The new document will be an exact + copy of the original. - //#################################################################### - /** - * Get a reference to the root node of this document. If no root node - * has been set, the returned node will be a blank node. You should take - * caution to use a reference so that you don't copy the whole node - * tree! - * - * @return A const reference to the root node. - * @author Peter Jones - **/ - //#################################################################### - const node& get_root_node (void) const; + @param other The other document object to copy from. + @author Peter Jones + */ + document(const document& other); - //#################################################################### - /** - * Get a reference to the root node of this document. If no root node - * has been set, the returned node will be a blank node. You should take - * caution to use a reference so that you don't copy the whole node - * tree! - * - * @return A reference to the root node. - * @author Peter Jones - **/ - //#################################################################### - node& get_root_node (void); + /** + Copy another document object into this one using the assignment + operator. This document object will be an exact copy of the other + document after the assignement. - //#################################################################### - /** - * Set the root node to the given node. A full copy is made and stored - * in the document object. - * - * @param n The new root node to use. - * @author Peter Jones - **/ - //#################################################################### - void set_root_node (const node &n); + @param other The document to copy from. + @return *this. + @author Peter Jones + */ + document& operator=(const document& other); - //#################################################################### - /** - * Get the XML version for this document. For generated documents, the - * version will be the default. For parsed documents, this will be the - * version from the XML processing instruction. - * - * @return The XML version string for this document. - * @author Peter Jones - **/ - //#################################################################### - const std::string& get_version (void) const; + /** + Swap one xml::document object for another. - //#################################################################### - /** - * Set the XML version number for this document. This version string - * will be used when generating the XML output. - * - * @param version The version string to use, like "1.0". - * @author Peter Jones - **/ - //#################################################################### - void set_version (const char *version); + @param other The other document to swap + @author Peter Jones + */ + void swap(document& other); - //#################################################################### - /** - * Get the XML encoding for this document. The default encoding is - * ISO-8859-1. - * - * @return The encoding string. - * @author Peter Jones - **/ - //#################################################################### - const std::string& get_encoding (void) const; + /** + Clean up after an XML document object. - //#################################################################### - /** - * Set the XML encoding string. If you don't set this, it will default - * to ISO-8859-1. - * - * @param encoding The XML encoding to use. - * @author Peter Jones - * @author Dmitriy Nikitinskiy - **/ - //#################################################################### - void set_encoding (const char *encoding); + @author Peter Jones + */ + ~document(); - //#################################################################### - /** - * Find out if the current document is a standalone document. For - * generated documents, this will be the default. For parsed documents - * this will be set based on the XML processing instruction. - * - * @return True if this document is standalone. - * @return False if this document is not standalone. - * @author Peter Jones - **/ - //#################################################################### - bool get_is_standalone (void) const; + /** + Get a reference to the root node of this document. If no root node + has been set, the returned node will be a blank node. You should take + caution to use a reference so that you don't copy the whole node + tree! - //#################################################################### - /** - * Set the standalone flag. This will show up in the XML output in the - * correct processing instruction. - * - * @param sa What to set the standalone flag to. - * @author Peter Jones - **/ - //#################################################################### - void set_is_standalone (bool sa); + @return A const reference to the root node. + @author Peter Jones + */ + const node& get_root_node() const; - //#################################################################### - /** - * Walk through the document and expand <xi:include> elements. For more - * information, please see the w3c recomendation for XInclude. - * http://www.w3.org/2001/XInclude. - * - * The return value of this function may change to int after a bug has - * been fixed in libxml2 (xmlXIncludeDoProcess). - * - * @return False if there was an error with substitutions. - * @return True if there were no errors (with or without substitutions). - * @author Peter Jones - * @author Daniel Evison - **/ - //#################################################################### - bool process_xinclude (void); + /** + Get a reference to the root node of this document. If no root node + has been set, the returned node will be a blank node. You should take + caution to use a reference so that you don't copy the whole node + tree! - //#################################################################### - /** - * Test to see if this document has an internal subset. That is, DTD - * data that is declared within the XML document itself. - * - * @return True if this document has an internal subset. - * @return False otherwise. - * @author Peter Jones - **/ - //#################################################################### - bool has_internal_subset (void) const; + @return A reference to the root node. + @author Peter Jones + */ + node& get_root_node(); - //#################################################################### - /** - * Test to see if this document has an external subset. That is, it - * references a DTD from an external source, such as a file or URL. - * - * @return True if this document has an external subset. - * @return False otherwise. - * @author Peter Jones - **/ - //#################################################################### - bool has_external_subset (void) const; + /** + Set the root node to the given node. A full copy is made and stored + in the document object. - //#################################################################### - /** - * Validate this document against the DTD that has been attached to it. - * This would happen at parse time if there was a !DOCTYPE definition. - * If the DTD is valid, and the document is valid, this member function - * will return true. - * - * If it returns false, you may want to send the document through - * xmllint to get the actual error messages. - * - * @return True if the document is valid. - * @return False if there was a problem with the DTD or XML doc. - * @author Peter Jones - **/ - //#################################################################### - bool validate (void); + @param n The new root node to use. + @author Peter Jones + */ + void set_root_node(const node& n); - //#################################################################### - /** - * Parse the given DTD and try to validate this document against it. If - * the DTD is valid, and the document is valid, this member function - * will return true. - * - * If it returns false, you may want to send the document through - * xmllint to get the actual error messages. - * - * This member function will add the parsed DTD to this document as the - * external subset after the validation. If there is already an external - * DTD attached to this document it will be removed and deleted. - * - * @param dtdname A filename or URL for the DTD to use. - * @return True if the document is valid. - * @return False if there was a problem with the DTD or XML doc. - * @author Peter Jones - **/ - //#################################################################### - bool validate (const char *dtdname); + /** + Get the XML version for this document. For generated documents, the + version will be the default. For parsed documents, this will be the + version from the XML processing instruction. - //#################################################################### - /** - * Returns the number of child nodes of this document. This will always - * be at least one, since all xmlwrapp documents must have a root node. - * This member function is useful to find out how many document children - * there are, including processing instructions, comments, etc. - * - * @return The number of children nodes that this document has. - * @author Peter Jones - **/ - //#################################################################### - size_type size (void) const; + @return The XML version string for this document. + @author Peter Jones + */ + const std::string& get_version() const; - //#################################################################### - /** - * Get an iterator to the first child node of this document. If what you - * really wanted was the root node (the first element) you should use - * the get_root_node() member function instead. - * - * @return A xml::node::iterator that points to the first child node. - * @return An end iterator if there are no children in this document - * @author Peter Jones - **/ - //#################################################################### - node::iterator begin (void); + /** + Set the XML version number for this document. This version string + will be used when generating the XML output. - //#################################################################### - /** - * Get a const_iterator to the first child node of this document. If - * what you really wanted was the root node (the first element) you - * should use the get_root_node() member function instead. - * - * @return A xml::node::const_iterator that points to the first child node. - * @return An end const_iterator if there are no children in this document. - * @author Peter Jones - **/ - //#################################################################### - node::const_iterator begin (void) const; + @param version The version string to use, like "1.0". + @author Peter Jones + */ + void set_version(const char *version); - //#################################################################### - /** - * Get an iterator that points one past the last child node for this - * document. - * - * @return An end xml::node::iterator. - * @author Peter Jones - **/ - //#################################################################### - node::iterator end (void); + /** + Get the XML encoding for this document. The default encoding is + ISO-8859-1. - //#################################################################### - /** - * Get a const_iterator that points one past the last child node for - * this document. - * - * @return An end xml::node::const_iterator. - * @author Peter Jones - **/ - //#################################################################### - node::const_iterator end (void) const; + @return The encoding string. + @author Peter Jones + */ + const std::string& get_encoding() const; - //#################################################################### - /** - * Add a child xml::node to this document. You should not add a element - * type node, since there can only be one root node. This member - * function is only useful for adding processing instructions, comments, - * etc.. If you do try to add a node of type element, an exception will - * be thrown. - * - * @param child The child xml::node to add. - * @author Peter Jones - **/ - //#################################################################### + /** + Set the XML encoding string. If you don't set this, it will default + to ISO-8859-1. + + @param encoding The XML encoding to use. + @author Peter Jones + @author Dmitriy Nikitinskiy + */ + void set_encoding(const char *encoding); + + /** + Find out if the current document is a standalone document. For + generated documents, this will be the default. For parsed documents + this will be set based on the XML processing instruction. + + @return True if this document is standalone. + @return False if this document is not standalone. + @author Peter Jones + */ + bool get_is_standalone() const; + + /** + Set the standalone flag. This will show up in the XML output in the + correct processing instruction. + + @param sa What to set the standalone flag to. + @author Peter Jones + */ + void set_is_standalone(bool sa); + + /** + Walk through the document and expand <xi:include> elements. For more + information, please see the w3c recomendation for XInclude. + http://www.w3.org/2001/XInclude. + + The return value of this function may change to int after a bug has + been fixed in libxml2 (xmlXIncludeDoProcess). + + @return False if there was an error with substitutions. + @return True if there were no errors (with or without substitutions). + @author Peter Jones + @author Daniel Evison + */ + bool process_xinclude(); + + /** + Test to see if this document has an internal subset. That is, DTD + data that is declared within the XML document itself. + + @return True if this document has an internal subset. + @return False otherwise. + @author Peter Jones + */ + bool has_internal_subset() const; + + /** + Test to see if this document has an external subset. That is, it + references a DTD from an external source, such as a file or URL. + + @return True if this document has an external subset. + @return False otherwise. + @author Peter Jones + */ + bool has_external_subset() const; + + /** + Validate this document against the DTD that has been attached to it. + This would happen at parse time if there was a !DOCTYPE definition. + If the DTD is valid, and the document is valid, this member function + will return true. + + If it returns false, you may want to send the document through + xmllint to get the actual error messages. + + @return True if the document is valid. + @return False if there was a problem with the DTD or XML doc. + @author Peter Jones + */ + bool validate(); + + /** + Parse the given DTD and try to validate this document against it. If + the DTD is valid, and the document is valid, this member function + will return true. + + If it returns false, you may want to send the document through + xmllint to get the actual error messages. + + This member function will add the parsed DTD to this document as the + external subset after the validation. If there is already an external + DTD attached to this document it will be removed and deleted. + + @param dtdname A filename or URL for the DTD to use. + @return True if the document is valid. + @return False if there was a problem with the DTD or XML doc. + @author Peter Jones + */ + bool validate(const char *dtdname); + + /** + Returns the number of child nodes of this document. This will always + be at least one, since all xmlwrapp documents must have a root node. + This member function is useful to find out how many document children + there are, including processing instructions, comments, etc. + + @return The number of children nodes that this document has. + @author Peter Jones + */ + size_type size() const; + + /** + Get an iterator to the first child node of this document. If what you + really wanted was the root node (the first element) you should use + the get_root_node() member function instead. + + @return A xml::node::iterator that points to the first child node. + @return An end iterator if there are no children in this document + @author Peter Jones + */ + node::iterator begin(); + + /** + Get a const_iterator to the first child node of this document. If + what you really wanted was the root node (the first element) you + should use the get_root_node() member function instead. + + @return A xml::node::const_iterator that points to the first child node. + @return An end const_iterator if there are no children in this document. + @author Peter Jones + */ + node::const_iterator begin() const; + + /** + Get an iterator that points one past the last child node for this + document. + + @return An end xml::node::iterator. + @author Peter Jones + */ + node::iterator end(); + + /** + Get a const_iterator that points one past the last child node for + this document. + + @return An end xml::node::const_iterator. + @author Peter Jones + */ + node::const_iterator end() const; + + /** + Add a child xml::node to this document. You should not add a element + type node, since there can only be one root node. This member + function is only useful for adding processing instructions, comments, + etc.. If you do try to add a node of type element, an exception will + be thrown. + + @param child The child xml::node to add. + @author Peter Jones + */ void push_back (const node &child); - //#################################################################### - /** - * Insert a new child node. The new node will be inserted at the end of - * the child list. This is similar to the xml::node::push_back member - * function except that an iterator to the inserted node is returned. - * - * The rules from the push_back member function apply here. Don't add a - * node of type element. - * - * @param n The node to insert as a child of this document. - * @return An iterator that points to the newly inserted node. - * @see xml::document::push_back - * @author Peter Jones - **/ - //#################################################################### + /** + Insert a new child node. The new node will be inserted at the end of + the child list. This is similar to the xml::node::push_back member + function except that an iterator to the inserted node is returned. + + The rules from the push_back member function apply here. Don't add a + node of type element. + + @param n The node to insert as a child of this document. + @return An iterator that points to the newly inserted node. + @see xml::document::push_back + @author Peter Jones + */ node::iterator insert (const node &n); - //#################################################################### - /** - * Insert a new child node. The new node will be inserted before the - * node pointed to by the given iterator. - * - * The rules from the push_back member function apply here. Don't add a - * node of type element. - * - * @param position An iterator that points to the location where the new node should be inserted (before it). - * @param n The node to insert as a child of this document. - * @return An iterator that points to the newly inserted node. - * @see xml::document::push_back - * @author Peter Jones - **/ - //#################################################################### - node::iterator insert (node::iterator position, const node &n); + /** + Insert a new child node. The new node will be inserted before the + node pointed to by the given iterator. - //#################################################################### - /** - * Replace the node pointed to by the given iterator with another node. - * The old node will be removed, including all its children, and - * replaced with the new node. This will invalidate any iterators that - * point to the node to be replaced, or any pointers or references to - * that node. - * - * Do not replace this root node with this member function. The same - * rules that apply to push_back apply here. If you try to replace a - * node of type element, an exception will be thrown. - * - * @param old_node An iterator that points to the node that should be removed. - * @param new_node The node to put in old_node's place. - * @return An iterator that points to the new node. - * @see xml::document::push_back - * @author Peter Jones - **/ - //#################################################################### - node::iterator replace (node::iterator old_node, const node &new_node); + The rules from the push_back member function apply here. Don't add a + node of type element. - //#################################################################### - /** - * Erase the node that is pointed to by the given iterator. The node - * and all its children will be removed from this node. This will - * invalidate any iterators that point to the node to be erased, or any - * pointers or references to that node. - * - * Do not remove the root node using this member function. The same - * rules that apply to push_back apply here. If you try to erase the - * root node, an exception will be thrown. - * - * @param to_erase An iterator that points to the node to be erased. - * @return An iterator that points to the node after the one being erased. - * @see xml::document::push_back - * @author Peter Jones - **/ - //#################################################################### - node::iterator erase (node::iterator to_erase); + @param position An iterator that points to the location where the new node should be inserted (before it). + @param n The node to insert as a child of this document. + @return An iterator that points to the newly inserted node. + @see xml::document::push_back + @author Peter Jones + */ + node::iterator insert(node::iterator position, const node &n); - //#################################################################### - /** - * Erase all nodes in the given range, from frist to last. This will - * invalidate any iterators that point to the nodes to be erased, or any - * pointers or references to those nodes. - * - * Do not remove the root node using this member function. The same - * rules that apply to push_back apply here. If you try to erase the - * root node, an exception will be thrown. - * - * @param first The first node in the range to be removed. - * @param last An iterator that points one past the last node to erase. Think xml::node::end(). - * @return An iterator that points to the node after the last one being erased. - * @see xml::document::push_back - * @author Peter Jones - **/ - //#################################################################### - node::iterator erase (node::iterator first, node::iterator last); + /** + Replace the node pointed to by the given iterator with another node. + The old node will be removed, including all its children, and + replaced with the new node. This will invalidate any iterators that + point to the node to be replaced, or any pointers or references to + that node. - //#################################################################### - /** - * Convert the XML document tree into XML text data and place it into - * the given string. - * - * @param s The string to place the XML text data. - * @author Peter Jones - **/ - //#################################################################### - void save_to_string (std::string &s) const; + Do not replace this root node with this member function. The same + rules that apply to push_back apply here. If you try to replace a + node of type element, an exception will be thrown. - //#################################################################### - /** - * Convert the XML document tree into XML text data and place it into - * the given filename. - * - * @param filename The name of the file to place the XML text data into. - * @param compression_level 0 is no compression, 1-9 allowed, where 1 is for better speed, and 9 is for smaller size - * @return True if the data was saved successfully. - * @return False otherwise. - * @author Peter Jones - **/ - //#################################################################### - bool save_to_file (const char *filename, int compression_level=0) const; + @param old_node An iterator that points to the node that should be removed. + @param new_node The node to put in old_node's place. + @return An iterator that points to the new node. + @see xml::document::push_back + @author Peter Jones + */ + node::iterator replace(node::iterator old_node, const node& new_node); - //#################################################################### - /** - * Convert the XML document tree into XML text data and then insert it - * into the given stream. - * - * @param stream The stream to insert the XML into. - * @param doc The document to insert. - * @return The stream from the first parameter. - * @author Peter Jones - **/ - //#################################################################### + /** + Erase the node that is pointed to by the given iterator. The node + and all its children will be removed from this node. This will + invalidate any iterators that point to the node to be erased, or any + pointers or references to that node. + + Do not remove the root node using this member function. The same + rules that apply to push_back apply here. If you try to erase the + root node, an exception will be thrown. + + @param to_erase An iterator that points to the node to be erased. + @return An iterator that points to the node after the one being erased. + @see xml::document::push_back + @author Peter Jones + */ + node::iterator erase(node::iterator to_erase); + + /** + Erase all nodes in the given range, from frist to last. This will + invalidate any iterators that point to the nodes to be erased, or any + pointers or references to those nodes. + + Do not remove the root node using this member function. The same + rules that apply to push_back apply here. If you try to erase the + root node, an exception will be thrown. + + @param first The first node in the range to be removed. + @param last An iterator that points one past the last node to erase. Think xml::node::end(). + @return An iterator that points to the node after the last one being erased. + @see xml::document::push_back + @author Peter Jones + */ + node::iterator erase(node::iterator first, node::iterator last); + + /** + Convert the XML document tree into XML text data and place it into + the given string. + + @param s The string to place the XML text data. + @author Peter Jones + */ + void save_to_string(std::string& s) const; + + /** + Convert the XML document tree into XML text data and place it into + the given filename. + + @param filename The name of the file to place the XML text data into. + @param compression_level 0 is no compression, 1-9 allowed, where 1 is + for better speed, and 9 is for smaller size + @return True if the data was saved successfully. + @return False otherwise. + @author Peter Jones + */ + bool save_to_file(const char *filename, int compression_level = 0) const; + + /** + Convert the XML document tree into XML text data and then insert it + into the given stream. + + @param stream The stream to insert the XML into. + @param doc The document to insert. + @return The stream from the first parameter. + @author Peter Jones + */ friend std::ostream& operator<< (std::ostream &stream, const document &doc); private: impl::doc_impl *pimpl_; + void set_doc_data (void *data); void set_doc_data_from_xslt (void *data, xslt::impl::result *xr); - void* get_doc_data (void); - void* get_doc_data_read_only (void) const; - void* release_doc_data (void); + void* get_doc_data(); + void* get_doc_data_read_only() const; + void* release_doc_data(); friend class tree_parser; friend class xslt::stylesheet; -}; // end xml::document class +}; -} // end xml namespace -#endif +} // namespace xml + +#endif // _xmlwrapp_document_h_ Modified: trunk/include/xmlwrapp/event_parser.h =================================================================== --- trunk/include/xmlwrapp/event_parser.h 2009-11-26 14:30:19 UTC (rev 161) +++ trunk/include/xmlwrapp/event_parser.h 2009-12-20 11:28:20 UTC (rev 162) @@ -30,10 +30,12 @@ * SUCH DAMAGE. */ -/** @file - * This file contains the definition of the xml::event_parser class. -**/ +/** + @file + This file contains the definition of the xml::event_parser class. + */ + #ifndef _xmlwrapp_event_parser_h_ #define _xmlwrapp_event_parser_h_ @@ -46,230 +48,195 @@ #include <iosfwd> #include <map> -namespace xml { +namespace xml +{ - -namespace impl { +namespace impl +{ struct epimpl; // forward declaration of private implementation } /** - * The xml::event_parser is used to parse an XML document by calling member - * functions when certain things in the XML document are parsed. In order to - * use this class you derive a sub-class from it and override the protected - * virtual functions. -**/ -class event_parser { + The xml::event_parser is used to par... [truncated message content] |