summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
Diffstat (limited to 'hscript')
-rw-r--r--hscript/key.hh27
-rw-r--r--hscript/keymanager.hh8
-rw-r--r--hscript/script.hh6
3 files changed, 30 insertions, 11 deletions
diff --git a/hscript/key.hh b/hscript/key.hh
index 06d34f8..7c398ca 100644
--- a/hscript/key.hh
+++ b/hscript/key.hh
@@ -28,18 +28,31 @@ public:
void setData(std::string data);
/*! Determines if the data associated with the Key is valid. */
- bool isValid();
+ bool validate();
+ /*! Executes the action associated with this Key.
+ * Will always return `false` if `validate` is `false`.
+ */
+ bool execute();
+};
+
+/*! Describes a Key class. */
+typedef struct KeyDesc {
+ /*! The name of the Key. */
+ std::string name;
/*! Determines if the Key is required to be present for the HorizonScript
* to be considered valid. */
- static bool isRequired();
-
+ bool required;
/*! Determines how many times this Key can be repeated.
- * If this function returns 0, it can be repeated an unlimited number of times.
- * If this function returns 1, it can only be present once per HorizonScript.
+ * If this value is 0, it can be repeated an unlimited number of times.
+ * If this value is 1, it can only be present once per HorizonScript.
*/
- static int maxCount();
-};
+ int repeat;
+ /*! Order of the Key. Determines when the Key will be executed. */
+ int order;
+ /*! The function used to create a new Key of this type. */
+ Key*(*key_create_fn)(void);
+} key_desc_t;
}
}
diff --git a/hscript/keymanager.hh b/hscript/keymanager.hh
index b3cd109..347f5c2 100644
--- a/hscript/keymanager.hh
+++ b/hscript/keymanager.hh
@@ -12,6 +12,7 @@
#include <vector>
#include <string>
+#include <memory>
#include "key.hh"
namespace Horizon {
@@ -20,6 +21,11 @@ namespace Keys {
/*! Manages the Key classes. */
class KeyManager {
private:
+ /*! Internal data class used by the KeyManager. */
+ struct ManagerPrivate;
+ /*! Internal data. */
+ const std::unique_ptr<ManagerPrivate> internal;
+
/*! Create the key manager */
KeyManager();
public:
@@ -27,7 +33,7 @@ public:
static const KeyManager *getKeyManager();
/*! Add a new Key to the key manager. */
- void addKey(std::string name, bool required, int max, Key*(*key_create_fn)(void));
+ void addKey(key_desc_t description);
/*! Determines if a Key is recognised. */
void hasKey(std::string name);
diff --git a/hscript/script.hh b/hscript/script.hh
index feee23b..98f79af 100644
--- a/hscript/script.hh
+++ b/hscript/script.hh
@@ -12,11 +12,10 @@
#include <string>
#include <vector>
+#include <memory>
namespace Horizon {
-struct ScriptPrivate;
-
/*! Defines the Script class, which represents a HorizonScript. */
class Script {
public:
@@ -34,8 +33,9 @@ public:
std::vector<std::string> scriptErrors();
private:
+ struct ScriptPrivate;
/*! Internal data. */
- ScriptPrivate *internal;
+ const std::unique_ptr<ScriptPrivate> internal;
};
}