forked from gildor2/UEViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextContainer.h
57 lines (51 loc) · 1.01 KB
/
TextContainer.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
#ifndef __TEXT_CONTAINER_H__
#define __TEXT_CONTAINER_H__
struct CTextRec
{
char *text;
CTextRec *next;
};
class CTextContainer
{
protected:
// static values
int recSize;
char *textBuf;
int bufSize;
// dynamic values
bool filled; // !empty
int fillPos;
CTextRec *lastRec;
public:
inline void Clear()
{
filled = false;
}
CTextRec *Add(const char *text);
void Enumerate(void (*func) (const CTextRec *rec));
};
// Type 'R' should be derived from CTextRec.
template<class R, int BufferSize>
class TTextContainer : public CTextContainer
{
public:
inline TTextContainer()
{
textBuf = new char [BufferSize];
bufSize = BufferSize;
recSize = sizeof(R);
}
~TTextContainer()
{
delete[] textBuf;
}
inline R *Add(const char *text)
{
return static_cast<R*>(CTextContainer::Add(text));
}
inline void Enumerate(void (*func) (const R *rec))
{
CTextContainer::Enumerate((void(*)(const CTextRec*)) func);
}
};
#endif // __TEXT_CONTAINER_H__