aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/logger/llreader.h
blob: 26d3bf3e4a54e81d4372e31863be39c5441433fd (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.

#include <vespa/log/llparser.h>
#include <stdexcept>

namespace ns_log {

class MsgException : public std::exception {
private:
    const char *_string;
    MsgException& operator = (const MsgException &);
public:
    MsgException(const MsgException &x) : std::exception(), _string(x._string) {}
    MsgException(const char *s) : _string(s) {}
    ~MsgException() override = default;
    const char *what() const noexcept override { return _string; }
};

class InputBuf
{
private:
    int _inputfd;
    int _size;
    char *_buf;
    char *_bp;
    int _left;
    void extend();
    InputBuf(const InputBuf& other);
    InputBuf& operator= (const InputBuf& other);
public:
    InputBuf(int fd);
    ~InputBuf();
    bool blockRead();
    bool hasInput();
    void doInput(LLParser &via);
    void doAllInput(LLParser &via);
};

} // namespace