summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-19 07:34:52 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:39:05 -0400
commit3e0f510b296c0b72353f146912bb0225af0a5647 (patch)
tree8ff4098ea790bbaf2b26a13d1b76487fe80b6041 /src/node.cc
parent5a72d17d026aa6a1bb0cd32f413963ef9f24ab64 (diff)
downloadfork-ledger-3e0f510b296c0b72353f146912bb0225af0a5647.tar.gz
fork-ledger-3e0f510b296c0b72353f146912bb0225af0a5647.tar.bz2
fork-ledger-3e0f510b296c0b72353f146912bb0225af0a5647.zip
More work on the compilation of nodes.
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/node.cc b/src/node.cc
index b03f5f5a..0ca0a04c 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -40,7 +40,19 @@ const char * node_t::name() const
return *document().lookup_name(name_id());
}
-optional<value_t> node_t::get_attr(const string& _name) const
+value_t& node_t::set_attr(const string& _name, const char * value)
+{
+ nameid_t name_id = document().register_name(_name);
+ return set_attr(name_id, value);
+}
+
+value_t& node_t::set_attr(const string& _name, const value_t& value)
+{
+ nameid_t name_id = document().register_name(_name);
+ return set_attr(name_id, value);
+}
+
+optional<value_t&> node_t::get_attr(const string& _name)
{
optional<nameid_t> name_id = document().lookup_name_id(_name);
if (name_id)
@@ -71,10 +83,17 @@ void output_xml_string(std::ostream& out, const string& str)
void node_t::print_attributes(std::ostream& out) const
{
- if (attributes)
+ if (attributes) {
+#if 1
+ foreach (const attr_pair& attr, *attributes)
+ out << ' ' << *document().lookup_name(attr.first)
+ << "=\"" << attr.second << "\"";
+#else
foreach (const attr_pair& attr, attributes->get<0>())
out << ' ' << *document().lookup_name(attr.first)
<< "=\"" << attr.second << "\"";
+#endif
+ }
IF_VERIFY()
out << " type=\"parent_node_t\"";