From 3e0f510b296c0b72353f146912bb0225af0a5647 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 19 May 2007 07:34:52 +0000 Subject: More work on the compilation of nodes. --- src/node.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/node.cc') 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 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 node_t::get_attr(const string& _name) { optional 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\""; -- cgit v1.2.3