aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/line-splitter.h
blob: 905412b50d0970934a036429bb60b7cf35be060f (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

namespace config::sentinel {

class LineSplitter {
private:
    int _fd;
    int _size;
    char *_buffer;
    int _readPos;
    int _writePos;
    bool _eof;

    LineSplitter();
    LineSplitter& operator =(const LineSplitter&);
    LineSplitter(const LineSplitter&);

    bool resize();
    bool fill();

public:
    explicit LineSplitter(int fd);
    char *getLine();
    bool eof() const { return _eof && _readPos >= _writePos; }

    ~LineSplitter();
};

}