From f44dac145adabb580cc36b31079ae963bf59b096 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sun, 15 Feb 2015 14:54:35 +0100 Subject: Added "markAsMagic" function, autoformat --- src/core/common/Variant.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src') 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 @@ -883,6 +883,21 @@ public: return asObj(VariantType::FUNCTION); } + /** + * 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. * @@ -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 -- cgit v1.2.3