blob: 82f1146df29d8fc73dcfa6ee7826d425bc5f44a0 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "xmlstream.h"
#include <vespa/vespalib/util/exceptions.h>
#include <sstream>
namespace vespalib::xml {
template<typename T>
XmlAttribute::XmlAttribute(const std::string& name, 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 IllegalArgumentException("Name '" + name + "' contains "
"illegal XML characters and cannot be used as attribute name");
}
}
}
|