aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/common/configdefinition.cpp
blob: a02460f8e64bc022b172f8cf46b4dbcea14f53e5 (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
41
42
43
44
45
46
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configdefinition.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/data/slime/slime.h>

using namespace vespalib;
using namespace vespalib::slime;

namespace config {

ConfigDefinition::ConfigDefinition()
    : _schema()
{}

ConfigDefinition::ConfigDefinition(StringVector schema)
    : _schema(std::move(schema))
{}

void
ConfigDefinition::serialize(Cursor & cursor) const
{
    for (auto it(_schema.begin()), mt(_schema.end()); it != mt; it++) {
        cursor.addString(Memory(*it));
    }
}

void
ConfigDefinition::deserialize(const Inspector & inspector)
{
    for (size_t i(0); i < inspector.entries(); i++) {
        _schema.push_back(inspector[i].asString().make_string());
    }
}

vespalib::string
ConfigDefinition::asString() const
{
    vespalib::asciistream as;
    for (const auto & line : _schema) {
        as << line;
    }
    return as.str();
}

}