blob: 0da684d6b28a229b36d4aaa2c1872b3382a5627f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "xmlserializable.h"
#include <vespa/vespalib/util/exceptions.h>
#include <sstream>
namespace vespalib {
namespace xml {
template<typename T>
XmlAttribute::XmlAttribute(const std::string& name, const T& 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");
}
}
}
}
|