From 5a72d17d026aa6a1bb0cd32f413963ef9f24ab64 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 19 May 2007 03:11:00 +0000 Subject: Node compilation is beginning to work. --- src/node.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/node.h') diff --git a/src/node.h b/src/node.h index 7b1f9919..8d221049 100644 --- a/src/node.h +++ b/src/node.h @@ -50,13 +50,15 @@ class node_t : public supports_flags<>, public noncopyable public: typedef uint_fast16_t nameid_t; + // This has to be public so that multi_index_container can reference + // it in parent_node_t. nameid_t name_id_; protected: document_t& document_; optional parent_; - typedef std::pair attr_pair; + typedef std::pair attr_pair; typedef multi_index_container< attr_pair, @@ -69,6 +71,11 @@ protected: optional attributes; + typedef attributes_t::nth_index<0>::type attributes_by_order; + typedef attributes_t::nth_index<1>::type attributes_hashed; + + bool compiled; + public: node_t(nameid_t _name_id, document_t& _document, const optional& _parent = none, flags_t _flags = 0) @@ -81,6 +88,11 @@ public: TRACE_DTOR(node_t); } + bool is_compiled() const { + return compiled; + } + virtual void compile() {} + bool is_parent_node() const { return has_flags(XML_NODE_IS_PARENT); } @@ -112,12 +124,18 @@ public: } void set_attr(const nameid_t _name_id, const char * value) { + if (! attributes) + attributes = attributes_t(); + attributes->push_back(attr_pair(_name_id, string_value(value))); + } + void set_attr(const nameid_t _name_id, const value_t& value) { if (! attributes) attributes = attributes_t(); attributes->push_back(attr_pair(_name_id, value)); } - optional get_attr(const string& _name) const; - optional get_attr(const nameid_t _name_id) const { + + optional get_attr(const string& _name) const; + optional get_attr(const nameid_t _name_id) const { if (attributes) { typedef attributes_t::nth_index<1>::type attributes_by_name; @@ -159,6 +177,11 @@ public: clear_children(); } + virtual void compile() { + foreach (node_t * child, *this) + child->compile(); + } + template T * create_child(nameid_t _name_id) { T * child = new T(_name_id, document(), *this); -- cgit v1.2.3