forked from uncrustify/uncrustify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChunkStack.h
More file actions
77 lines (62 loc) · 1.21 KB
/
ChunkStack.h
File metadata and controls
77 lines (62 loc) · 1.21 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
/**
* @file ChunkStack.h
* Manages a simple stack of chunks
*
* @author Ben Gardner
* @license GPL v2+
*/
#ifndef CHUNKSTACK_H_INCLUDED
#define CHUNKSTACK_H_INCLUDED
#include "uncrustify_types.h"
#include <deque>
class ChunkStack
{
public:
struct Entry
{
Entry() : m_seqnum(0), m_pc(0) { }
Entry(const Entry& ref) : m_seqnum(ref.m_seqnum), m_pc(ref.m_pc) { }
Entry(int sn, chunk_t *pc) : m_seqnum(sn), m_pc(pc) { }
int m_seqnum;
chunk_t *m_pc;
};
protected:
deque<Entry> m_cse;
int m_seqnum; // current seq num
public:
ChunkStack() : m_seqnum(0)
{
}
ChunkStack(const ChunkStack& cs)
{
Set(cs);
}
virtual ~ChunkStack()
{
}
void Set(const ChunkStack& cs);
void Push(chunk_t *pc)
{
Push(pc, ++m_seqnum);
}
bool Empty() const
{
return(m_cse.empty());
}
int Len() const
{
return(m_cse.size());
}
const Entry *Top() const;
const Entry *Get(int idx) const;
chunk_t *GetChunk(int idx) const;
chunk_t *Pop();
void Push(chunk_t *pc, int seqnum);
void Reset()
{
m_cse.clear();
}
void Zap(int idx);
void Collapse();
};
#endif /* CHUNKSTACK_H_INCLUDED */