diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-12-29 13:06:40 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-12-29 13:06:40 -0700 |
commit | 1bc10d1408eb29b0675a030e029155dd046b1dd8 (patch) | |
tree | 6d649015bdfa69df9de1cb964906fd396b9db82b /src/variable.cpp | |
parent | 79dce6268850fb1b0d76c15d5399d66bcd286e5f (diff) | |
download | stage-1bc10d1408eb29b0675a030e029155dd046b1dd8.tar.gz stage-1bc10d1408eb29b0675a030e029155dd046b1dd8.tar.bz2 stage-1bc10d1408eb29b0675a030e029155dd046b1dd8.tar.xz stage-1bc10d1408eb29b0675a030e029155dd046b1dd8.zip |
Functions can be called now, at least manually.
A little more work needs to be done before they're being called from
code correctly.
Diffstat (limited to 'src/variable.cpp')
-rw-r--r-- | src/variable.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/variable.cpp b/src/variable.cpp index adf1511..b7899f1 100644 --- a/src/variable.cpp +++ b/src/variable.cpp | |||
@@ -62,6 +62,33 @@ Variable Variable::newSituationName( const Bu::String &s ) | |||
62 | return v; | 62 | return v; |
63 | } | 63 | } |
64 | 64 | ||
65 | Variable Variable::newVariableName( const Bu::String &s ) | ||
66 | { | ||
67 | Variable v( tVariable ); | ||
68 | (*v.sValue) = s; | ||
69 | return v; | ||
70 | } | ||
71 | |||
72 | bool Variable::getBool() const | ||
73 | { | ||
74 | return bValue; | ||
75 | } | ||
76 | |||
77 | int64_t Variable::getInt() const | ||
78 | { | ||
79 | return iValue; | ||
80 | } | ||
81 | |||
82 | double Variable::getFloat() const | ||
83 | { | ||
84 | return fValue; | ||
85 | } | ||
86 | |||
87 | Bu::String Variable::getString() const | ||
88 | { | ||
89 | return *sValue; | ||
90 | } | ||
91 | |||
65 | Variable Variable::to( Type e ) const | 92 | Variable Variable::to( Type e ) const |
66 | { | 93 | { |
67 | if( e == eType ) | 94 | if( e == eType ) |
@@ -195,6 +222,7 @@ Variable &Variable::operator=( const Variable &rhs ) | |||
195 | 222 | ||
196 | case tString: | 223 | case tString: |
197 | case tSituation: | 224 | case tSituation: |
225 | case tVariable: | ||
198 | (*sValue) = *rhs.sValue; | 226 | (*sValue) = *rhs.sValue; |
199 | break; | 227 | break; |
200 | 228 | ||
@@ -261,6 +289,10 @@ Variable &Variable::operator+=( const Variable &rhs ) | |||
261 | case tSituation: | 289 | case tSituation: |
262 | throw VariableException("You cannot add situations."); | 290 | throw VariableException("You cannot add situations."); |
263 | break; | 291 | break; |
292 | |||
293 | case tVariable: | ||
294 | throw VariableException("You cannot add variable names."); | ||
295 | break; | ||
264 | } | 296 | } |
265 | 297 | ||
266 | return *this; | 298 | return *this; |
@@ -310,6 +342,9 @@ Variable Variable::operator+( const Variable &rhs ) const | |||
310 | 342 | ||
311 | case tSituation: | 343 | case tSituation: |
312 | throw VariableException("You cannot add situations."); | 344 | throw VariableException("You cannot add situations."); |
345 | |||
346 | case tVariable: | ||
347 | throw VariableException("You cannot add variables."); | ||
313 | } | 348 | } |
314 | } | 349 | } |
315 | } | 350 | } |
@@ -341,6 +376,7 @@ bool Variable::operator==( const Variable &rhs ) const | |||
341 | 376 | ||
342 | case tString: | 377 | case tString: |
343 | case tSituation: | 378 | case tSituation: |
379 | case tVariable: | ||
344 | return (*sValue) == (*rhs.sValue); | 380 | return (*sValue) == (*rhs.sValue); |
345 | 381 | ||
346 | case tList: | 382 | case tList: |
@@ -369,6 +405,7 @@ void Variable::initType() | |||
369 | { | 405 | { |
370 | case tString: | 406 | case tString: |
371 | case tSituation: | 407 | case tSituation: |
408 | case tVariable: | ||
372 | sValue = new Bu::String(); | 409 | sValue = new Bu::String(); |
373 | break; | 410 | break; |
374 | 411 | ||
@@ -388,6 +425,7 @@ void Variable::deinitType() | |||
388 | { | 425 | { |
389 | case tString: | 426 | case tString: |
390 | case tSituation: | 427 | case tSituation: |
428 | case tVariable: | ||
391 | delete sValue; | 429 | delete sValue; |
392 | break; | 430 | break; |
393 | 431 | ||
@@ -418,6 +456,7 @@ template<> uint32_t Bu::__calcHashCode<Variable>( const Variable &k ) | |||
418 | 456 | ||
419 | case Variable::tString: | 457 | case Variable::tString: |
420 | case Variable::tSituation: | 458 | case Variable::tSituation: |
459 | case Variable::tVariable: | ||
421 | return Bu::__calcHashCode( *k.sValue ); | 460 | return Bu::__calcHashCode( *k.sValue ); |
422 | 461 | ||
423 | case Variable::tList: | 462 | case Variable::tList: |
@@ -453,6 +492,9 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v ) | |||
453 | 492 | ||
454 | case Variable::tSituation: | 493 | case Variable::tSituation: |
455 | return f << "<<" << *v.sValue << ">>"; | 494 | return f << "<<" << *v.sValue << ">>"; |
495 | |||
496 | case Variable::tVariable: | ||
497 | return f << "(varref:\"" << *v.sValue << "\")"; | ||
456 | 498 | ||
457 | case Variable::tList: | 499 | case Variable::tList: |
458 | return f << *v.lValue; | 500 | return f << *v.lValue; |