blob: 6f9919e6f711d3c78bad08d5ab636c50b242fe9b (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "asciiconfigreader.h"
#include <vespa/config/common/types.h>
#include <vespa/config/common/configvalue.h>
namespace config {
template <typename ConfigType>
AsciiConfigReader<ConfigType>::AsciiConfigReader(vespalib::asciistream & is)
: _is(is)
{
}
template <typename ConfigType>
std::unique_ptr<ConfigType>
AsciiConfigReader<ConfigType>::read(const ConfigFormatter & formatter)
{
ConfigDataBuffer buffer;
buffer.setEncodedString(_is.str());
formatter.decode(buffer);
return std::make_unique<ConfigType>(buffer);
}
template <typename ConfigType>
std::unique_ptr<ConfigType>
AsciiConfigReader<ConfigType>::read()
{
StringVector lines;
vespalib::string line;
while (getline(_is, line)) {
lines.push_back(line);
}
return std::make_unique<ConfigType>(ConfigValue(std::move(lines)));
}
} // namespace config
|