summaryrefslogtreecommitdiff
path: root/include/super.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-13 22:47:44 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-13 22:47:44 +0100
commite14d8c6f985aeaeb247387b51d6ec027655efb99 (patch)
treeaf2baf1e73668fe994bb6254a35b507b664f2fc0 /include/super.h
parent75944e3e755053bc2ebe9a2a8c55575941f79a56 (diff)
in response to issue #156: the super-global arrays Php::POST, Php::SERVER, etcetera can now be iterated over, and they can be assigned to a regular Php::Value variable
Diffstat (limited to 'include/super.h')
-rw-r--r--include/super.h49
1 files changed, 47 insertions, 2 deletions
diff --git a/include/super.h b/include/super.h
index 97ba6b8..7b568e0 100644
--- a/include/super.h
+++ b/include/super.h
@@ -41,7 +41,11 @@ public:
* @param key
* @return Value
*/
- Value operator[](const std::string &key);
+ Value operator[](const std::string &key)
+ {
+ // convert object to a value object, and retrieve the key
+ return value()[key];
+ }
/**
* Array access operator
@@ -49,7 +53,41 @@ public:
* @param key
* @return Value
*/
- Value operator[](const char *key);
+ Value operator[](const char *key)
+ {
+ // convert object to a value object, and retrieve the key
+ return value()[key];
+ }
+
+ /**
+ * Casting operator to cast to a value object
+ * @return Value
+ */
+ operator Value ()
+ {
+ // we have a private function for this
+ return value();
+ }
+
+ /**
+ * Return an iterator for iterating over the variables
+ * @return iterator
+ */
+ ValueIterator begin()
+ {
+ // convert to value, and call begin on the value object
+ return value().begin();
+ }
+
+ /**
+ * Return an iterator for iterating over the variables
+ * @return iterator
+ */
+ ValueIterator end()
+ {
+ // convert to value, and call end on that object
+ return value().end();
+ }
private:
/**
@@ -63,6 +101,13 @@ private:
* @var name
*/
const char *_name;
+
+ /**
+ * Turn the object into a value object
+ * @return Value
+ */
+ Value value();
+
};
/**