diff options
Diffstat (limited to 'akregator/src/mk4storage/metakit/src/std.h')
-rw-r--r-- | akregator/src/mk4storage/metakit/src/std.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/akregator/src/mk4storage/metakit/src/std.h b/akregator/src/mk4storage/metakit/src/std.h new file mode 100644 index 000000000..1d1937be3 --- /dev/null +++ b/akregator/src/mk4storage/metakit/src/std.h @@ -0,0 +1,63 @@ +// std.h -- +// $Id$ +// This is part of Metakit, see http://www.equi4.com/metakit/ + +/** @file + * Configuration header for STL-based builds + */ + +#define q4_STD 1 + +#include "mk4str.h" + +#include <vector> + +///////////////////////////////////////////////////////////////////////////// + +template<class T> +class c4_ArrayT +{ +#ifdef _MSC_VER + d4_std::vector< T, d4_std::allocator<T> > _vector; +#else + d4_std::vector< T, d4_std::alloc > _vector; +#endif + +public: + c4_ArrayT () { } + ~c4_ArrayT () { } + + int GetSize() const { return _vector.size(); } + void SetSize(int nNewSize, int =-1) { _vector.resize(nNewSize); } + + T GetAt(int nIndex) const { return _vector[nIndex]; } + T& ElementAt(int nIndex) { return _vector[nIndex]; } + + void SetAt(int nIndex, const T& newElement) + { + _vector[nIndex] = newElement; + } + + int Add(const T& newElement) + { + int n = _vector.size(); + _vector.push_back(newElement); + return n; + } + + void InsertAt(int nIndex, const T& newElement, int nCount =1) + { + _vector.insert(&_vector[nIndex], nCount, newElement); + } + + void RemoveAt(int nIndex, int nCount =1) + { + _vector.erase(&_vector[nIndex], &_vector[nIndex+nCount]); + } +}; + +typedef c4_ArrayT<t4_i32> c4_DWordArray; +typedef c4_ArrayT<void*> c4_PtrArray; +typedef c4_ArrayT<c4_String> c4_StringArray; + +///////////////////////////////////////////////////////////////////////////// |