forked from nickbnf/glogg
-
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathonelinelog.h
More file actions
47 lines (34 loc) · 1.01 KB
/
onelinelog.h
File metadata and controls
47 lines (34 loc) · 1.01 KB
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
46
47
//
// Created by marvin on 23-7-26.
//
#pragma once
#include <memory>
#include <QByteArray>
#include <QRegularExpression>
#include <QString>
#include "encodingdetector.h"
class OneLineLog {
public:
using Length = QByteArray::size_type;
public:
OneLineLog() = default;
OneLineLog( const char* data, Length len, std::shared_ptr<TextDecoder> dec,
std::shared_ptr<QRegularExpression> reg );
~OneLineLog() = default;
// no copying allowed
OneLineLog( const OneLineLog& ) = delete;
OneLineLog& operator=( const OneLineLog& ) = delete;
OneLineLog& operator=( OneLineLog&& ) = default;
OneLineLog( OneLineLog&& ) = default;
QString string() const;
QString expandedString() const;
QString process( std::function<void( QString& )> fn ) const;
inline bool empty() const
{
return buffer_.isEmpty() || !decoder_ || !reg_;
}
private:
QByteArray buffer_;
std::shared_ptr<TextDecoder> decoder_;
std::shared_ptr<QRegularExpression> reg_;
};