diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/variable.cpp | 38 | ||||
-rw-r--r-- | src/variable.h | 33 |
2 files changed, 66 insertions, 5 deletions
diff --git a/src/variable.cpp b/src/variable.cpp index 3954ccd..fab0c46 100644 --- a/src/variable.cpp +++ b/src/variable.cpp | |||
@@ -1,12 +1,46 @@ | |||
1 | #include "variable.h" | 1 | #include "variable.h" |
2 | 2 | ||
3 | Variable::Variable() : | 3 | Variable::Variable() : |
4 | eType( Undef ), | 4 | eType( Null ), |
5 | bNull( true ), | ||
6 | iValue( 0 ) | 5 | iValue( 0 ) |
7 | { | 6 | { |
8 | } | 7 | } |
9 | 8 | ||
9 | Variable::Variable( Type eType ) : | ||
10 | eType( eType ), | ||
11 | iValue( 0 ) | ||
12 | { | ||
13 | if( eType == String ) | ||
14 | { | ||
15 | sValue = new Bu::String(); | ||
16 | } | ||
17 | } | ||
18 | |||
19 | Variable::Variable( int64_t iValue ) : | ||
20 | eType( Int ), | ||
21 | iValue( iValue ) | ||
22 | { | ||
23 | } | ||
24 | |||
25 | Variable::Variable( double fValue ) : | ||
26 | eType( Float ), | ||
27 | fValue( fValue ) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | Variable::Variable( bool bValue ) : | ||
32 | eType( Bool ), | ||
33 | bValue( bValue ) | ||
34 | { | ||
35 | } | ||
36 | |||
37 | Variable::Variable( const Bu::String &sValue ) : | ||
38 | eType( String ), | ||
39 | iValue( 0 ) | ||
40 | { | ||
41 | this->sValue = new Bu::String( sValue ); | ||
42 | } | ||
43 | |||
10 | Variable::~Variable() | 44 | Variable::~Variable() |
11 | { | 45 | { |
12 | if( eType == String ) | 46 | if( eType == String ) |
diff --git a/src/variable.h b/src/variable.h index 3df9255..c9665f5 100644 --- a/src/variable.h +++ b/src/variable.h | |||
@@ -4,26 +4,51 @@ | |||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | 5 | ||
6 | #include <bu/string.h> | 6 | #include <bu/string.h> |
7 | #include <bu/hash.h> | ||
7 | 8 | ||
8 | class Variable | 9 | class Variable |
9 | { | 10 | { |
10 | public: | 11 | public: |
11 | enum Type | 12 | enum Type |
12 | { | 13 | { |
13 | Undef, | 14 | Null, |
14 | Int, | 15 | Int, |
15 | Float, | 16 | Float, |
16 | Bool, | 17 | Bool, |
17 | String | 18 | String, |
19 | List, | ||
20 | Dictionary | ||
18 | }; | 21 | }; |
19 | 22 | ||
20 | public: | 23 | public: |
21 | Variable(); | 24 | Variable(); |
25 | Variable( Type eType ); | ||
26 | Variable( int64_t iValue ); | ||
27 | Variable( double fValue ); | ||
28 | Variable( bool bValue ); | ||
29 | Variable( const Bu::String &sValue ); | ||
22 | virtual ~Variable(); | 30 | virtual ~Variable(); |
23 | 31 | ||
32 | Variable &operator=( const Variable &rhs ); | ||
33 | Variable &operator+=( const Variable &rhs ); | ||
34 | Variable &operator-=( const Variable &rhs ); | ||
35 | Variable &operator*=( const Variable &rhs ); | ||
36 | Variable &operator/=( const Variable &rhs ); | ||
37 | Variable &operator+( const Variable &rhs ); | ||
38 | Variable &operator-( const Variable &rhs ); | ||
39 | Variable &operator*( const Variable &rhs ); | ||
40 | Variable &operator/( const Variable &rhs ); | ||
41 | Variable &operator!=( const Variable &rhs ); | ||
42 | Variable &operator>( const Variable &rhs ); | ||
43 | Variable &operator<( const Variable &rhs ); | ||
44 | Variable &operator>=( const Variable &rhs ); | ||
45 | Variable &operator<=( const Variable &rhs ); | ||
46 | |||
24 | private: | 47 | private: |
25 | Type eType; | 48 | Type eType; |
26 | bool bNull; | 49 | |
50 | typedef Bu::List<Variable> VList; | ||
51 | typedef Bu::Hash<Variable, Variable> VHash; | ||
27 | 52 | ||
28 | union | 53 | union |
29 | { | 54 | { |
@@ -31,6 +56,8 @@ private: | |||
31 | double fValue; | 56 | double fValue; |
32 | bool bValue; | 57 | bool bValue; |
33 | Bu::String *sValue; | 58 | Bu::String *sValue; |
59 | VList *lValue; | ||
60 | VHash *hValue; | ||
34 | }; | 61 | }; |
35 | }; | 62 | }; |
36 | 63 | ||