arabica/include/XSLT/impl/xslt_item.hpp

56 lines
1.3 KiB
C++
Raw Normal View History

2007-07-19 19:01:42 +02:00
#ifndef ARABICA_XSLT_ITEM_HPP
#define ARABICA_XSLT_ITEM_HPP
namespace Arabica
{
namespace XSLT
{
class ExecutionContext;
2012-11-08 17:18:49 +01:00
template<class string_type, class string_adaptor>
2007-07-19 19:01:42 +02:00
class Item
{
public:
virtual ~Item()
{
} // ~Item
2012-11-08 17:18:49 +01:00
virtual void execute(const DOM::Node<string_type, string_adaptor>& node, ExecutionContext& context) const = 0;
2007-07-19 19:01:42 +02:00
}; // class Item
2012-11-08 17:18:49 +01:00
template<class string_type, class string_adaptor>
class ItemContainer : public Item<string_type, string_adaptor>
2007-07-19 19:01:42 +02:00
{
protected:
virtual ~ItemContainer()
2007-07-19 19:01:42 +02:00
{
2012-11-08 17:18:49 +01:00
for(ChildrenIterator ci = children_.begin(), ce = children_.end(); ci != ce; ++ci)
delete *ci;
2007-07-19 19:01:42 +02:00
} // ~ItemContainer
2012-11-08 17:18:49 +01:00
void execute_children(const DOM::Node<string_type, string_adaptor>& node, ExecutionContext& context) const
2007-07-19 19:01:42 +02:00
{
2012-11-08 17:18:49 +01:00
for(ChildrenIterator ci = children_.begin(), ce = children_.end(); ci != ce; ++ci)
(*ci)->execute(node, context);
2007-07-19 19:01:42 +02:00
} // execute
public:
2012-11-08 17:18:49 +01:00
void add_item(Item<string_type, string_adaptor>* child)
2007-07-19 19:01:42 +02:00
{
children_.push_back(child);
} // add_child
private:
2012-11-08 17:18:49 +01:00
typedef std::vector<Item<string_type, string_adaptor>*> Children;
typedef typename Children::const_iterator ChildrenIterator;
2007-07-19 19:01:42 +02:00
Children children_;
}; // ItemContainer
} // namespace XSLT
} // namespace Arabica
#endif