forked from nickbnf/glogg
-
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathabstractlogdata.h
More file actions
135 lines (121 loc) · 5.53 KB
/
abstractlogdata.h
File metadata and controls
135 lines (121 loc) · 5.53 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Copyright (C) 2009, 2010 Nicolas Bonnefon and other contributors
*
* This file is part of glogg.
*
* glogg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* glogg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with glogg. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (C) 2016 -- 2019 Anton Filimonov and other contributors
*
* This file is part of klogg.
*
* klogg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* klogg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with klogg. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ABSTRACTLOGDATA_H
#define ABSTRACTLOGDATA_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <QTextCodec>
#include "linetypes.h"
#include "onelinelog.h"
// Base class representing a set of data.
// It can be either a full set or a filtered set.
class AbstractLogData : public QObject {
Q_OBJECT
public:
public:
// Returns then line as OneLineLog structure, You can do anything with it.
OneLineLog getOneLineLog( LineNumber line ) const;
// Returns a set of lines as a set of OneLineLog structure, You can do anything with it.
klogg::vector<OneLineLog> getOneLineLogs( LineNumber firstLine, LinesCount number ) const;
// Returns the line passed as a QString
QString getLineString( LineNumber line ) const;
// Returns the line passed as a QString, with tabs expanded
QString getExpandedLineString( LineNumber line ) const;
// Returns a set of lines as a QStringList
klogg::vector<QString> getLines( LineNumber first_line, LinesCount number ) const;
// Returns a set of lines with tabs expanded
klogg::vector<QString> getExpandedLines( LineNumber first_line, LinesCount number ) const;
// Returns the line numer
LineNumber getLineNumber( LineNumber index ) const;
// Returns the total number of lines
LinesCount getNbLine() const;
// Returns the visible length of the longest line
// Tabs are expanded
LineLength getMaxLength() const;
// Returns the visible length of the passed line
// Tabs are expanded
LineLength getLineLength( LineNumber line ) const;
// Set the view to use the passed encoding for display
void setDisplayEncoding( const char* encoding_name );
// Configure how the view shall interpret newline characters
// this should be non zero for encodings where \n is encoded
// in multiple bytes (e.g. UTF-16)
void setMultibyteEncodingOffsets( int before_cr, int after_cr );
QTextCodec* getDisplayEncoding() const;
void attachReader() const;
void detachReader() const;
// The "type" of a line, which will appear in the FilteredView
enum class LineTypeFlags {
Plain = 0, // 0 can be checked like a proper flag in QFlags
Match = 1 << 0,
Mark = 1 << 1,
};
Q_DECLARE_FLAGS( LineType, LineTypeFlags )
protected:
// Returns then line as OneLineLog structure, You can do anything with it.
virtual OneLineLog doGetOneLineLog( LineNumber line ) const = 0;
// Returns a set of lines as a set of OneLineLog structure, You can do anything with it.
virtual klogg::vector<OneLineLog> doGetOneLineLogs( LineNumber firstLine,
LinesCount number ) const
= 0;
// Internal function called to get a given line
virtual QString doGetLineString( LineNumber line ) const = 0;
// Internal function called to get a given line
virtual QString doGetExpandedLineString( LineNumber line ) const = 0;
// Internal function called to get a set of lines
virtual klogg::vector<QString> doGetLines( LineNumber first_line, LinesCount number ) const = 0;
// Internal function called to get a set of expanded lines
virtual klogg::vector<QString> doGetExpandedLines( LineNumber first_line,
LinesCount number ) const
= 0;
// Internal function called to get the index of given line
virtual LineNumber doGetLineNumber( LineNumber index ) const = 0;
// Internal function called to get the number of lines
virtual LinesCount doGetNbLine() const = 0;
// Internal function called to get the maximum length
virtual LineLength doGetMaxLength() const = 0;
// Internal function called to get the line length
virtual LineLength doGetLineLength( LineNumber line ) const = 0;
// Internal function called to set the encoding
virtual void doSetDisplayEncoding( const char* encoding ) = 0;
virtual QTextCodec* doGetDisplayEncoding() const = 0;
virtual void doAttachReader() const = 0;
virtual void doDetachReader() const = 0;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( AbstractLogData::LineType )
#endif