blob: 6067275c2e4f28f96278a60352357cbe827c7d32 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "ostreamconfigwriter.h"
#include "fileconfigformatter.h"
#include <ostream>
namespace config {
OstreamConfigWriter::OstreamConfigWriter(std::ostream & os)
: _os(os)
{
}
bool
OstreamConfigWriter::write(const ConfigInstance & config, const ConfigFormatter & formatter)
{
ConfigDataBuffer buffer;
config.serialize(buffer);
formatter.encode(buffer);
_os << buffer.getEncodedString();
return !_os.fail();
}
bool
OstreamConfigWriter::write(const ConfigInstance & config)
{
return write(config, FileConfigFormatter());
}
} // namespace config
|