summaryrefslogtreecommitdiff
path: root/hscript/key.hh
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 16:40:06 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 16:40:06 -0500
commite242f93977d28b8d645b53f28fe052071dcbf10d (patch)
tree31d1bf67c8adaff53ee22eb76349b9fe898443db /hscript/key.hh
parent48f192b9eddd8ea38a1850fa4e499401ca957339 (diff)
downloadhorizon-e242f93977d28b8d645b53f28fe052071dcbf10d.tar.gz
horizon-e242f93977d28b8d645b53f28fe052071dcbf10d.tar.bz2
horizon-e242f93977d28b8d645b53f28fe052071dcbf10d.tar.xz
horizon-e242f93977d28b8d645b53f28fe052071dcbf10d.zip
hscript: Code
Diffstat (limited to 'hscript/key.hh')
-rw-r--r--hscript/key.hh14
1 files changed, 10 insertions, 4 deletions
diff --git a/hscript/key.hh b/hscript/key.hh
index 9c7755b..1045592 100644
--- a/hscript/key.hh
+++ b/hscript/key.hh
@@ -23,6 +23,10 @@ namespace Keys {
* return a different type of data. For example, `network` may return `bool`.
*/
class Key {
+protected:
+ /*! The line number where this Key appeared. */
+ int line;
+ Key(int _line) : line(_line) {}
public:
virtual ~Key() {}
@@ -41,12 +45,14 @@ public:
#undef UNUSED
/*! Determines if the data associated with the Key is valid. */
- virtual bool validate() = 0;
+ virtual bool validate() const = 0;
/*! Executes the action associated with this Key.
* @note Will always return `false` if `validate` is `false`.
*/
- virtual bool execute() = 0;
+ virtual bool execute() const = 0;
+
+ int lineno() const { return this->line; }
};
@@ -58,7 +64,7 @@ public:
*/
class BooleanKey : public Key {
protected:
- BooleanKey(bool my_value) : value(my_value) {}
+ BooleanKey(int _line, bool my_value) : Key(_line), value(my_value) {}
bool value;
/*! Parse a string into a boolean.
@@ -77,7 +83,7 @@ public:
bool test() const { return this->value; }
/*! Key will fail to init if valid is invalid. */
- bool validate() override;
+ bool validate() const override;
};
}