diff options
Diffstat (limited to 'src/Array.cpp')
-rw-r--r-- | src/Array.cpp | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/src/Array.cpp b/src/Array.cpp index d5d9d7c..bc448d3 100644 --- a/src/Array.cpp +++ b/src/Array.cpp @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdlib.h> -#include <plist/Array.h> - +#include <cstdlib> #include <algorithm> -#include <limits.h> +#include <climits> +#include "plist.h" +#include <plist/Array.h> namespace PList { @@ -32,7 +32,7 @@ Array::Array(Node* parent) : Structure(PLIST_ARRAY, parent) _array.clear(); } -static void array_fill(Array *_this, std::vector<Node*> array, plist_t node) +static void array_fill(Array *_this, std::vector<Node*> &array, plist_t node) { plist_array_iter iter = NULL; plist_array_new_iter(node, &iter); @@ -51,18 +51,17 @@ Array::Array(plist_t node, Node* parent) : Structure(parent) array_fill(this, _array, _node); } -Array::Array(const PList::Array& a) : Structure() +Array::Array(const PList::Array& a) { _array.clear(); _node = plist_copy(a.GetPlist()); array_fill(this, _array, _node); } -Array& Array::operator=(PList::Array& a) +Array& Array::operator=(const PList::Array& a) { plist_free(_node); - for (unsigned int it = 0; it < _array.size(); it++) - { + for (size_t it = 0; it < _array.size(); it++) { delete _array.at(it); } _array.clear(); @@ -73,8 +72,7 @@ Array& Array::operator=(PList::Array& a) Array::~Array() { - for (unsigned int it = 0; it < _array.size(); it++) - { + for (size_t it = 0; it < _array.size(); it++) { delete (_array.at(it)); } _array.clear(); @@ -90,6 +88,50 @@ Node* Array::operator[](unsigned int array_index) return _array.at(array_index); } +Array::iterator Array::Begin() +{ + return _array.begin(); +} + +Array::iterator Array::begin() +{ + return _array.begin(); +} + +Array::iterator Array::End() +{ + return _array.end(); +} + +Array::iterator Array::end() +{ + return _array.end(); +} + +Array::const_iterator Array::Begin() const +{ + return _array.begin(); +} + +Array::const_iterator Array::begin() const +{ + return _array.begin(); +} + +Array::const_iterator Array::End() const +{ + return _array.end(); +} + +Array::const_iterator Array::end() const +{ + return _array.end(); +} + +size_t Array::size() const { + return _array.size(); +} + void Array::Append(Node* node) { if (node) @@ -145,4 +187,4 @@ unsigned int Array::GetNodeIndex(Node* node) const return std::distance (_array.begin(), it); } -}; +} // namespace PList |