summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-19 03:11:00 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:39:05 -0400
commit5a72d17d026aa6a1bb0cd32f413963ef9f24ab64 (patch)
tree5aec31b69f0dcba9ff07f8a8d4abad60a00c0655 /src/node.h
parentcdea8aa18c8bbd018849fb890dba87f7ef1a1140 (diff)
downloadfork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.tar.gz
fork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.tar.bz2
fork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.zip
Node compilation is beginning to work.
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h29
1 files changed, 26 insertions, 3 deletions
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_node_t&> parent_;
- typedef std::pair<nameid_t, string> attr_pair;
+ typedef std::pair<nameid_t, value_t> attr_pair;
typedef multi_index_container<
attr_pair,
@@ -69,6 +71,11 @@ protected:
optional<attributes_t> 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_node_t&>& _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);
}
@@ -114,10 +126,16 @@ 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<const string&> get_attr(const string& _name) const;
- optional<const string&> get_attr(const nameid_t _name_id) const {
+
+ optional<value_t> get_attr(const string& _name) const;
+ optional<value_t> 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 <typename T>
T * create_child(nameid_t _name_id) {
T * child = new T(_name_id, document(), *this);