summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/array.h16
-rw-r--r--include/object.h2
2 files changed, 16 insertions, 2 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
diff --git a/include/object.h b/include/object.h
index a4d3c5a..1445943 100644
--- a/include/object.h
+++ b/include/object.h
@@ -22,7 +22,7 @@ public:
/**
* Constructor for an empty stdClass object
*/
- Object() : Value() { setType(Type::Object); }
+ Object() : Value(Type::Object) {}
/**
* Move constructor is passed to the parent