aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/print/asciiconfigsnapshotwriter.cpp
blob: 08bba16265165677c837999d5e0a87ad0fc8d553 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "asciiconfigsnapshotwriter.h"
#include "jsonconfigformatter.h"

namespace config {

AsciiConfigSnapshotWriter::AsciiConfigSnapshotWriter(vespalib::asciistream & os)
    : _os(os)
{
}

bool
AsciiConfigSnapshotWriter::write(const ConfigSnapshot & snapshot)
{
    ConfigDataBuffer buffer;
    snapshot.serialize(buffer);
    JsonConfigFormatter formatter(true);
    formatter.encode(buffer);
    _os << buffer.getEncodedString();
    return !_os.fail();
}

} // namespace config