From b187cc1667dcfe0373651bac5d64d25658d0d05a Mon Sep 17 00:00:00 2001 From: jez Date: Wed, 6 Aug 2008 11:48:06 +0100 Subject: [PATCH] Removed use of boost:ptr_vector. Turns out that std::vector > won't compile. Also see http://sourceforge.net/mailarchive/message.php?msg_name=2103b1960807291110y5f0063eaqb4c855f5aa56974e%40mail.gmail.com and discussion for bonus reason. --- include/XSLT/impl/xslt_choose.hpp | 12 +++++++----- include/XSLT/impl/xslt_item.hpp | 16 ++++++---------- include/XSLT/impl/xslt_stylesheet.hpp | 14 +++++++++----- include/XSLT/impl/xslt_with_param.hpp | 13 ++++++++----- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/include/XSLT/impl/xslt_choose.hpp b/include/XSLT/impl/xslt_choose.hpp index 7e9a7d02..dc2dd27d 100755 --- a/include/XSLT/impl/xslt_choose.hpp +++ b/include/XSLT/impl/xslt_choose.hpp @@ -1,7 +1,6 @@ #ifndef ARABICA_XSLT_CHOOSE_HPP #define ARABICA_XSLT_CHOOSE_HPP -#include #include "xslt_item.hpp" #include "xslt_if.hpp" @@ -54,16 +53,18 @@ public: virtual ~Choose() { + for(WhenList::const_iterator w = when_.begin(), e = when_.end(); w != e; ++w) + delete (*w); delete otherwise_; } // ~Choose virtual void execute(const DOM::Node& node, ExecutionContext& context) const { ChainStackFrame frame(context); - for(boost::ptr_vector::const_iterator w = when_.begin(), e = when_.end(); w != e; ++w) - if(w->is_met(node, context)) + for(WhenList::const_iterator w = when_.begin(), e = when_.end(); w != e; ++w) + if((*w)->is_met(node, context)) { - w->execute(node, context); + (*w)->execute(node, context); return; } // if ... @@ -83,7 +84,8 @@ public: } // set_otherwise private: - boost::ptr_vector when_; + typedef std::vector WhenList; + WhenList when_; Otherwise* otherwise_; }; // class Choose diff --git a/include/XSLT/impl/xslt_item.hpp b/include/XSLT/impl/xslt_item.hpp index dfa090fa..c441675b 100755 --- a/include/XSLT/impl/xslt_item.hpp +++ b/include/XSLT/impl/xslt_item.hpp @@ -1,8 +1,6 @@ #ifndef ARABICA_XSLT_ITEM_HPP #define ARABICA_XSLT_ITEM_HPP -#include - namespace Arabica { namespace XSLT @@ -23,21 +21,18 @@ public: class ItemContainer : public Item { protected: - typedef boost::ptr_vector Children; - - ~ItemContainer() + virtual ~ItemContainer() { + for(Children::const_iterator ci = children_.begin(), ce = children_.end(); ci != ce; ++ci) + delete *ci; } // ~ItemContainer void execute_children(const DOM::Node& node, ExecutionContext& context) const { - for(Children::const_iterator ci = children_begin(), ce = children_end(); ci != ce; ++ci) - ci->execute(node, context); + for(Children::const_iterator ci = children_.begin(), ce = children_.end(); ci != ce; ++ci) + (*ci)->execute(node, context); } // execute - Children::const_iterator children_begin() const { return children_.begin(); } - Children::const_iterator children_end() const { return children_.end(); } - public: void add_item(Item* child) { @@ -45,6 +40,7 @@ public: } // add_child private: + typedef std::vector Children; Children children_; }; // ItemContainer diff --git a/include/XSLT/impl/xslt_stylesheet.hpp b/include/XSLT/impl/xslt_stylesheet.hpp index 0cb96fa6..c036388d 100755 --- a/include/XSLT/impl/xslt_stylesheet.hpp +++ b/include/XSLT/impl/xslt_stylesheet.hpp @@ -2,7 +2,6 @@ #define ARABICA_XSLT_STYLESHEET_HPP #include -#include #include #include @@ -32,9 +31,14 @@ public: ~Stylesheet() { + // let's clean up! for(ItemStack::const_iterator isi = items_.begin(), ise = items_.end(); isi != ise; ++isi) for(ItemList::const_iterator ci = isi->begin(), ce = isi->end(); ci != ce; ++ci) delete *ci; + for(ParamList::const_iterator pi = params_.begin(), pe = params_.end(); pi != pe; ++pi) + delete *pi; + for(TemplateList::const_iterator ti = all_templates_.begin(), te = all_templates_.end(); ti != te; ++ti) + delete *ti; } // ~Stylesheet void set_parameter(const std::string& name, bool value) @@ -75,8 +79,8 @@ public: ExecutionContext context(*this, output_.get(), *error_output_); // set up variables and so forth - for(boost::ptr_vector::const_iterator pi = params_.begin(), pe = params_.end(); pi != pe; ++pi) - pi->declare(context); + for(ParamList::const_iterator pi = params_.begin(), pe = params_.end(); pi != pe; ++pi) + (*pi)->declare(context); for(ItemStack::const_iterator isi = items_.begin(), ise = items_.end(); isi != ise; ++isi) { for(ItemList::const_iterator ci = isi->begin(), ce = isi->end(); ci != ce; ++ci) @@ -297,7 +301,7 @@ private: Template* template_; }; // struct MatchTemplate - typedef boost::ptr_vector