summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-08 13:51:08 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-08 13:51:08 +0100
commit2c484adbab9255498953739cb4d9751353cc804d (patch)
treedb306429c9b8b759279ce4d8c4774394e572e71f /include
parent2e6efbd587e88be19b0c8f34d1597448125e23cf (diff)
various fixes to make the function call example compilable
Diffstat (limited to 'include')
-rw-r--r--include/array.h6
-rw-r--r--include/classbase.h2
-rw-r--r--include/value.h29
3 files changed, 33 insertions, 4 deletions
diff --git a/include/array.h b/include/array.h
index 3b92826..dcd5e5f 100644
--- a/include/array.h
+++ b/include/array.h
@@ -59,6 +59,12 @@ public:
Array(const std::map<std::string,T> &value) : Value(value) {}
/**
+ * Constructor from an initializer list
+ * @param value
+ */
+ Array(const std::initializer_list<Value> &value) : Value(value) {}
+
+ /**
* Destructor
*/
virtual ~Array() {}
diff --git a/include/classbase.h b/include/classbase.h
index 05ab2f4..25d081f 100644
--- a/include/classbase.h
+++ b/include/classbase.h
@@ -240,7 +240,7 @@ private:
* @param count
* @return int
*/
- static int countElements(zval *object, long *count TSRMLS_DC);
+ static int countElements(struct _zval *object, long *count);
/**
* Retrieve pointer to our own object handlers
diff --git a/include/value.h b/include/value.h
index 5800c6a..72bd895 100644
--- a/include/value.h
+++ b/include/value.h
@@ -72,8 +72,25 @@ public:
template <typename T>
Value(const std::vector<T> &input) : Value(Type::Array)
{
+ // index
+ int i = 0;
+
+ // set all elements
+ for (auto &elem : input) setRaw(i++, elem);
+ }
+
+ /**
+ * Constructor from an initializer list
+ * @param value
+ */
+ template <typename T>
+ Value(const std::initializer_list<T> &value) : Value(Type::Array)
+ {
+ // index
+ int i = 0;
+
// set all elements
- for (size_t i=0; i<input.size(); i++) setRaw(i, input[i]);
+ for (auto &elem : value) setRaw(i++, elem);
}
/**
@@ -395,8 +412,14 @@ public:
// and fill the result vector
for (size_t i = 0; i<count; i++)
{
- // check if the index exists, then add it
- if (contains(i)) result.push_back((T)get(i));
+ // check if the index exists
+ if (!contains(i)) continue;
+
+ // get the value object
+ Value value(get(i));
+
+ // add it to the vector
+ result.push_back(value);
}
// done