diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-08 06:52:21 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-08 06:52:21 (GMT) |
commit | 6659ad47b0b07b66b62ca79f3929d361733cc67a (patch) | |
tree | e4f0cbd7fa1e4b5dcb69daca43d3a7f33a1ed022 /src/value.cc | |
parent | 5ce3d4ff8df274bbbb1b5dbd272179ad5765ded1 (diff) |
Updated boolean handling of if/else
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc index 34566bd..53fd6dc 100644 --- a/src/value.cc +++ b/src/value.cc @@ -361,6 +361,30 @@ std::string Value::toString() const return stream.str(); } +bool Value::toBool() const +{ + switch (this->type) { + case STRING: + return this->text.size() > 0; + break; + case VECTOR: + return this->vec.size() > 0; + break; + case RANGE: + return true; + break; + case NUMBER: + return this->num != 0; + break; + case BOOL: + return this->b; + break; + default: + return false; + break; + } +} + /*! Append a value to this vector. This must be of type VECTOR. |