aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/core/line_reader.h
blob: e562759782f9177127505c1e356ba6f2e5929455 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/data/input_reader.h>
#include "string.h"

namespace vbench {

using Input = vespalib::Input;

/**
 * Concrete utility class used to read individual lines of text from
 * an underlying input. This class is implemented in terms of the
 * ByteInput class.
 **/
class LineReader
{
public:
    using InputReader = vespalib::InputReader;
private:
    InputReader _input;

public:
    /**
     * Wrap an Input to read one line at a time.
     *
     * @param input the underlying Input
     **/
    LineReader(Input &input);

    /**
     * Read the next line of input. Lines are separated by '\n'. '\r'
     * appearing directly in from of '\n' will be stripped. Empty
     * lines will be returned.
     *
     * @return true if a line could be read,
     *         false if no more data was available
     * @param dst where to store the line that was read
     **/
    bool readLine(string &dst);
};

} // namespace vbench