summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 14:54:35 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-15 14:54:35 +0100
commitf44dac145adabb580cc36b31079ae963bf59b096 (patch)
tree5b7ffa421f537567ffcbb61b91eaf76997d35cc4
parent53c92aea125a439858d03245a914e20f55e5bcba (diff)
Added "markAsMagic" function, autoformat
-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