summaryrefslogtreecommitdiff
path: root/hscript/key.hh
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:07:48 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:07:48 -0500
commita621e6b86adfe8278d2e9c110eb8ef54e58c6abe (patch)
tree793d373d4cc40575cf74284e29032fb37c0948b4 /hscript/key.hh
parent794d2bd7e8472d6fad1ebb385240c1838e6325fc (diff)
downloadhorizon-a621e6b86adfe8278d2e9c110eb8ef54e58c6abe.tar.gz
horizon-a621e6b86adfe8278d2e9c110eb8ef54e58c6abe.tar.bz2
horizon-a621e6b86adfe8278d2e9c110eb8ef54e58c6abe.tar.xz
horizon-a621e6b86adfe8278d2e9c110eb8ef54e58c6abe.zip
hscript: Add StringKey helper class
Diffstat (limited to 'hscript/key.hh')
-rw-r--r--hscript/key.hh19
1 files changed, 18 insertions, 1 deletions
diff --git a/hscript/key.hh b/hscript/key.hh
index 1045592..44cbdf2 100644
--- a/hscript/key.hh
+++ b/hscript/key.hh
@@ -64,8 +64,8 @@ public:
*/
class BooleanKey : public Key {
protected:
- BooleanKey(int _line, bool my_value) : Key(_line), value(my_value) {}
bool value;
+ BooleanKey(int _line, bool my_value) : Key(_line), value(my_value) {}
/*! Parse a string into a boolean.
* @param what The string to attempt parsing.
@@ -86,6 +86,23 @@ public:
bool validate() const override;
};
+
+/*! Base Key class that parses and handles single string values. */
+class StringKey : public Key {
+protected:
+ std::string _value;
+ StringKey(int _line, std::string my_str) : Key(_line), _value(my_str) {}
+
+public:
+ /*! Retrieve the value of this key. */
+ const std::string value() const { return this->_value; }
+
+ /*! By default, key will be considered valid since it parsed.
+ * This method should be overridden when further consideration is needed.
+ */
+ bool validate() const override;
+};
+
}
}