diff options
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. |