summaryrefslogtreecommitdiff
path: root/include
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
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')
-rw-r--r--include/super.h49
-rw-r--r--include/value.h2
2 files changed, 48 insertions, 3 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();
+
};
/**
diff --git a/include/value.h b/include/value.h
index 363779d..c3de4d5 100644
--- a/include/value.h
+++ b/include/value.h
@@ -1144,7 +1144,7 @@ protected:
void setRaw(const char *key, int size, const Value &value);
/**
- * Internal helper method to create an iterator
+ * Internal helper method to create an `
* @param begin Should the iterator start at the begin?
* @return iterator
*/