-
Notifications
You must be signed in to change notification settings - Fork 0
/
para.h
73 lines (57 loc) · 1.33 KB
/
para.h
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
#ifndef __PARAGRAPH_H__
#define __PARAGRAPH_H__
#include <qstring.h>
typedef union Attr{
struct {
unsigned char ccol :1;
unsigned short col :12;
unsigned char bold :1;
unsigned char under :1;
unsigned char link :1;
} attr;
unsigned short flag;
Attr() { this->flag = 0; }
Attr(const Attr &o) { this->flag = o.flag; }
bool operator == (const Attr &o) { return this->flag == o.flag; }
const Attr &operator = (const Attr &o) { this->flag = o.flag ; return *this; }
} Attr;
struct Link {
int sidx, eidx;
QString str;
struct Link *next;
Link(int s, int e, QString qs) { sidx=s; eidx=e; str=qs; next=NULL; }
Link *findLink(int off);
~Link() { delete next; }
};
struct ParaData
{
int m_ref;
QString m_str;
Attr *m_attr;
int m_len;
int m_ind;
int m_lines;
Link *m_link;
ParaData(int len);
~ParaData();
};
struct Paragraph {
ParaData *m_para;
QString *m_str;
Attr *m_attr;
private:
void grab();
void release();
public:
Paragraph();
Paragraph(int length);
~Paragraph();
Paragraph(const Paragraph&p);
void addLink(int s, int e, QString st);
Link *findLink(int s);
bool empty();
bool operator()();
Paragraph &operator = (const Paragraph &p);
//Paragraph &operator = (Paragraph p);
};
#endif