-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringtree.h
More file actions
82 lines (73 loc) · 2.39 KB
/
stringtree.h
File metadata and controls
82 lines (73 loc) · 2.39 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
#ifndef __StringTreeH__H
#define __StringTreeH__H
#include <string>
#include <vector>
#include <map>
using namespace std;
//==============================================================================
class StringTree
{
public:
class Node;
StringTree();
StringTree(string *);
StringTree(StringTree &);
virtual ~ StringTree(void);
void * Add(string,int=0,void * = 0);
void * Add(void *,string,int=0,void * =0);
void Clear();
void Dump();
void Get(void *,string &,int &,void *&);
void Get(void *,void(*)(StringTree *,void *));
StringTree::Node * Root();
void Stream(string *);
void UnStream(string &);
private:
string STint2str(int);
int STstr2int(string &,unsigned &);
string STstr2str(string &,unsigned &);
unsigned STstr2unsigned(string &,unsigned &);
void * STstr2voidp(string &,unsigned &);
string STunsigned2str(unsigned);
string STvoidp2str(void *);
void WalkStream(Node *);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Subclass StringTree::Node
public:
class Node {
friend class StringTree;
public :
Node(StringTree *,string,int,void *);
virtual ~ Node(void);
void Dump(int=0);
void WalkTree(void *,void(*)(void *,Node *));
string str;
int image;
Node * par;
vector<Node *> child;
int cnt;
void * pdata;
StringTree * pST;
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
friend class Node;
static const unsigned BPP = sizeof(void *);
static const unsigned BPI = sizeof(int);
static const unsigned BPU = sizeof(unsigned);
Node * root;
int count;
unsigned nfc;
map<Node *,unsigned> smap;
map<unsigned,Node *> umap;
string * pstream;
union bodgeU;
friend union bodgeU;
union bodgeU {
unsigned u;
int i;
void * p;
char cc[BPP];
} bodge;
};
//==============================================================================
#endif