1// univ.h --
2// $Id: univ.h 1230 2007-03-09 15:58:53Z jcw $
3// This is part of Metakit, the homepage is http://www.equi4.com/metakit.html
4
5/** @file
6 * Definition of the container classes
7 */
8
9#define q4_UNIV 1
10
11#include "mk4str.h"
12
13/////////////////////////////////////////////////////////////////////////////
14
15class c4_BaseArray {
16  public:
17    c4_BaseArray();
18    ~c4_BaseArray();
19
20    int GetLength()const;
21    void SetLength(int nNewSize);
22
23    const void *GetData(int nIndex)const;
24    void *GetData(int nIndex);
25
26    void Grow(int nIndex);
27
28    void InsertAt(int nIndex, int nCount);
29    void RemoveAt(int nIndex, int nCount);
30
31  private:
32    char *_data;
33    int _size;
34    //  char _buffer[4];
35};
36
37class c4_PtrArray {
38  public:
39    c4_PtrArray();
40    ~c4_PtrArray();
41
42    int GetSize()const;
43    void SetSize(int nNewSize, int nGrowBy =  - 1);
44
45    void *GetAt(int nIndex)const;
46    void SetAt(int nIndex, const void *newElement);
47    void * &ElementAt(int nIndex);
48
49    int Add(void *newElement);
50
51    void InsertAt(int nIndex, void *newElement, int nCount = 1);
52    void RemoveAt(int nIndex, int nCount = 1);
53
54  private:
55    static int Off(int n_);
56
57    c4_BaseArray _vector;
58};
59
60class c4_DWordArray {
61  public:
62    c4_DWordArray();
63    ~c4_DWordArray();
64
65    int GetSize()const;
66    void SetSize(int nNewSize, int nGrowBy =  - 1);
67
68    t4_i32 GetAt(int nIndex)const;
69    void SetAt(int nIndex, t4_i32 newElement);
70    t4_i32 &ElementAt(int nIndex);
71
72    int Add(t4_i32 newElement);
73
74    void InsertAt(int nIndex, t4_i32 newElement, int nCount = 1);
75    void RemoveAt(int nIndex, int nCount = 1);
76
77  private:
78    static int Off(int n_);
79
80    c4_BaseArray _vector;
81};
82
83class c4_StringArray {
84  public:
85    c4_StringArray();
86    ~c4_StringArray();
87
88    int GetSize()const;
89    void SetSize(int nNewSize, int nGrowBy =  - 1);
90
91    const char *GetAt(int nIndex)const;
92    void SetAt(int nIndex, const char *newElement);
93    //  c4_String& ElementAt(int nIndex);
94
95    int Add(const char *newElement);
96
97    void InsertAt(int nIndex, const char *newElement, int nCount = 1);
98    void RemoveAt(int nIndex, int nCount = 1);
99
100  private:
101    c4_PtrArray _ptrs;
102};
103
104/////////////////////////////////////////////////////////////////////////////
105
106#if q4_INLINE
107#include "univ.inl"
108#endif
109
110/////////////////////////////////////////////////////////////////////////////
111