summaryrefslogtreecommitdiff
path: root/include/array.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 15:25:11 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-07 15:25:11 +0100
commit28e09660d30fc17969916673fdc8475ceeedbeb2 (patch)
tree4e511a09e30de37f9f154eb0760792f0d95bc696 /include/array.h
parent8c6652ae30202ba50f989a3b4d6c7255e4351251 (diff)
added constructor to Php::Array class to accept std::vector and std::map
Diffstat (limited to 'include/array.h')
-rw-r--r--include/array.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/array.h b/include/array.h
index 94d2824..3b92826 100644
--- a/include/array.h
+++ b/include/array.h
@@ -22,7 +22,7 @@ public:
/**
* Constructor
*/
- Array() : Value() { setType(Type::Array); }
+ Array() : Value(Type::Array) {}
/**
* Copy constructor from a value object
@@ -43,6 +43,20 @@ public:
// type must be valid
if (value.type() != Type::Array) throw Php::Exception("Moving a non-array to an array variable");
}
+
+ /**
+ * Constructors from a vector (this will create an array)
+ * @param value
+ */
+ template <typename T>
+ Array(const std::vector<T> &input) : Value(input) {}
+
+ /**
+ * Constructor from a map (this will create an associative array)
+ * @param value
+ */
+ template <typename T>
+ Array(const std::map<std::string,T> &value) : Value(value) {}
/**
* Destructor