summaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-01 15:43:38 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-12 02:55:43 +0100
commit3f5b1bd8b6aa14a57f4d4dde11e1998bf8735842 (patch)
treee3e5739d2a31cd4f8fa883dc72cd95faec002029 /staging_vespalib
parent406960f054ade094282b648156c997d95c26f813 (diff)
Include asciistream in implementation only.
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp15
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/xmlserializable.h4
2 files changed, 17 insertions, 2 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp
index bced837e3a1..17c5a2e4a68 100644
--- a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp
@@ -374,6 +374,21 @@ XmlAttribute::XmlAttribute(const XmlAttribute& attribute)
{
}
+XmlAttribute::XmlAttribute(const std::string& name, const char * value, uint32_t flags)
+ : _name(name),
+ _value(),
+ _next()
+{
+ std::ostringstream ost;
+ if (flags & HEX) ost << std::hex << "0x";
+ ost << value;
+ _value = ost.str();
+ if (!isLegalName(name)) {
+ throw vespalib::IllegalArgumentException("Name '" + name + "' contains "
+ "illegal XML characters and cannot be used as attribute name");
+ }
+}
+
XmlEndTag::XmlEndTag()
{
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h
index 8454ea045ee..0c064ebd43f 100644
--- a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h
+++ b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.h
@@ -89,8 +89,8 @@ public:
XmlAttribute(const XmlAttribute&);
/** Add any value that can be written to an ostringstream. */
template<typename T>
- XmlAttribute(const std::string& name, const T& value,
- uint32_t flags = NONE);
+ XmlAttribute(const std::string& name, const T& value, uint32_t flags = NONE);
+ XmlAttribute(const std::string& name, const char * value, uint32_t flags = NONE);
~XmlAttribute();
const std::string& getName() const { return _name; }