-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.h
139 lines (106 loc) · 2.63 KB
/
atom.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
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
136
137
138
139
//
// Copyright (C) 2003-2004 Trevor Hogan
//
#ifndef ATOM_H
#define ATOM_H
class CAtom
{
public:
virtual ~CAtom( ) { }
virtual bool isLong( ) { return false; }
virtual bool isList( ) { return false; }
virtual bool isDicti( ) { return false; }
virtual int EncodedLength( ) = 0;
virtual int Length( ) = 0;
virtual string toString( ) = 0;
};
class CAtomInt : public CAtom
{
public:
CAtomInt( );
CAtomInt( int iInt );
CAtomInt( const CAtomInt &c );
virtual ~CAtomInt( );
virtual int EncodedLength( );
virtual int Length( );
virtual string toString( );
int getValue( ) const;
void setValue( int iInt );
private:
int m_iInt;
};
class CAtomLong : public CAtom
{
public:
CAtomLong( );
CAtomLong( int64 iLong );
CAtomLong( const CAtomLong &c );
virtual ~CAtomLong( );
virtual bool isLong( ) { return true; }
virtual int EncodedLength( );
virtual int Length( );
virtual string toString( );
int64 getValue( ) const;
void setValue( int64 iLong );
private:
int64 m_iLong;
};
class CAtomString : public CAtom
{
public:
CAtomString( );
CAtomString( string strString );
CAtomString( const CAtomString &c );
virtual ~CAtomString( );
virtual int EncodedLength( );
virtual int Length( );
virtual string toString( );
string getValue( ) const;
void setValue( string strString );
private:
string m_strString;
};
class CAtomList : public CAtom
{
public:
CAtomList( );
CAtomList( vector<CAtom *> vecList );
CAtomList( const CAtomList &c );
virtual ~CAtomList( );
virtual bool isList( ) { return true; }
virtual int EncodedLength( );
virtual int Length( );
virtual string toString( );
virtual bool isEmpty( );
virtual void clear( );
virtual void Randomize( );
vector<CAtom *> getValue( ) const;
vector<CAtom *> *getValuePtr( ) const;
void setValue( vector<CAtom *> vecList );
void delItem( CAtom *atmItem );
void addItem( CAtom *atmItem );
private:
vector<CAtom *> m_vecList;
};
class CAtomDicti : public CAtom
{
public:
CAtomDicti( );
CAtomDicti( const CAtomDicti &c );
virtual ~CAtomDicti( );
virtual bool isDicti( ) { return true; }
virtual int EncodedLength( );
virtual int Length( );
virtual string toString( );
virtual bool isEmpty( );
virtual void clear( );
map<string, CAtom *> *getValuePtr( ) const;
void setValue( map<string, CAtom *> mapDicti );
void delItem( string strKey );
CAtom *getItem( string strKey );
CAtom *getItem( string strKey, CAtom *pReturn );
void setItem( string strKey, CAtom *pValue );
private:
map<string, CAtom *> m_mapDicti;
};
#endif