summaryrefslogtreecommitdiffstats
path: root/vespalog/src/logger/llreader.h
blob: 27b39d23df78303f62aaf8ebaa9ed8b0c6a26b26 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <stdexcept>

#include <vespa/log/log.h>
#include <vespa/log/log-target.h>
#include <vespa/log/llparser.h>

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() throw() {} // nothing to do
    const char *what() const throw() 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