blob: a4ddb12ed8da4937dfdf149f114f9c4a393b3596 (
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
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <string>
namespace vespalib {
namespace xml {
class XmlOutputStream;
/**
* @class document::XmlSerializable
*
* Base class for classes that can be converted into XML.
*/
class XmlSerializable
{
public:
XmlSerializable() {}
virtual ~XmlSerializable() {}
virtual void printXml(XmlOutputStream& out) const = 0;
/** Utility function, using printXml() to create a string. */
virtual std::string toXml(const std::string& indent = "") const;
};
} // xml
// The XmlSerializable and XmlOutputStream is often used in header files
// and is thus available in the vespalib namespace. To not pollute the
// vespalib namespace with all the other classes, use
// "using namespace vespalib::xml" within your printXml functions
using XmlSerializable = vespalib::xml::XmlSerializable;
using XmlOutputStream = vespalib::xml::XmlOutputStream;
} // vespalib
|