summaryrefslogtreecommitdiff
path: root/src/core/common/Variant.hpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-15 21:56:04 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-15 21:56:04 +0100
commitd2f99e4b43ed93ef0fa8e138e0c3afc79775b77c (patch)
tree8e7cdb894b7036b3ca01499ee9432d2e62930477 /src/core/common/Variant.hpp
parent40f7df390f00f85c17bd0e6527ec4ba19cbce4fc (diff)
parent4f2872d9968aec93bebff90d1238347c8a364949 (diff)
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/common/Variant.hpp')
-rw-r--r--src/core/common/Variant.hpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/core/common/Variant.hpp b/src/core/common/Variant.hpp
index 6eae7e1..ddd17d7 100644
--- a/src/core/common/Variant.hpp
+++ b/src/core/common/Variant.hpp
@@ -884,6 +884,21 @@ public:
}
/**
+ * If the value of the variant already is a string, the markAsMagic function
+ * marks this string as a "magic" value (a variant which might also be an
+ * identifier). Throws an exception if the variant is not a string or magic
+ * value.
+ */
+ void markAsMagic()
+ {
+ if (getType() == VariantType::STRING) {
+ meta.setType(VariantType::MAGIC);
+ return;
+ }
+ throw TypeException{getType(), VariantType::STRING};
+ }
+
+ /**
* Returns the value of the Variant as boolean, performs type conversion.
*
* @return the Variant value converted to a boolean value.
@@ -1146,10 +1161,7 @@ public:
*
* @retun true if the
*/
- bool hasLocation() const
- {
- return meta.hasLocation();
- }
+ bool hasLocation() const { return meta.hasLocation(); }
/**
* Unpacks ans returns the stored source location. Note that the returned
@@ -1158,10 +1170,7 @@ public:
*
* @return the stored SourceLocation.
*/
- SourceLocation getLocation() const
- {
- return meta.getLocation();
- }
+ SourceLocation getLocation() const { return meta.getLocation(); }
/**
* Packs the given source location and stores it in the metadata. Not all