summaryrefslogtreecommitdiff
path: root/src/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/value.h b/src/value.h
index f8674864..148d5bd6 100644
--- a/src/value.h
+++ b/src/value.h
@@ -229,7 +229,12 @@ public:
TRACE_DTOR(value_t);
}
- value_t& operator=(const value_t& val);
+ value_t& operator=(const value_t& val) {
+ if (this == &val || storage == val.storage)
+ return *this;
+ storage = val.storage;
+ return *this;
+ }
/**
* _dup() makes a private copy of the current value so that it can
@@ -427,6 +432,11 @@ public:
assert(is_xml_node());
return *(const xml::node_t **) storage->data;
}
+ template <typename T>
+ T * as_xml_node() const {
+ assert(is_xml_node());
+ return *(T **) storage->data;
+ }
void set_xml_node(xml::node_t * val) {
set_type(XML_NODE);
*(xml::node_t **) storage->data = val;
@@ -592,6 +602,13 @@ public:
friend std::ostream& operator<<(std::ostream& out, const value_t& val);
};
+template <>
+inline const xml::node_t * value_t::as_xml_node() const {
+ assert(is_xml_node());
+ assert(! is_type(CONST_XML_NODE));
+ return *(const xml::node_t **) storage->data;
+}
+
std::ostream& operator<<(std::ostream& out, const value_t& val);
DECLARE_EXCEPTION(value_error);