summaryrefslogtreecommitdiffstats
path: root/akregator/src/mk4storage/metakit/src/univ.h
blob: 5558e8a4cba1f91a51661aa02e04548a4928c678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// univ.h --
// $Id$
// This is part of Metakit, the homepage is http://www.equi4.com/metakit/

/** @file
 * Definition of the container classes
 */

#define q4_UNIV 1

#include "mk4str.h"

/////////////////////////////////////////////////////////////////////////////

class c4_BaseArray
{
public:
  c4_BaseArray ();
  ~c4_BaseArray ();

  int GetLength() const;
  void SetLength(int nNewSize);

  const void* GetData(int nIndex) const;
  void* GetData(int nIndex);

  void Grow(int nIndex);

  void InsertAt(int nIndex, int nCount);
  void RemoveAt(int nIndex, int nCount);

private:
  char* _data;
  int _size;
//  char _buffer[4];
};

class c4_PtrArray
{
public:
  c4_PtrArray ();
  ~c4_PtrArray ();

  int GetSize() const;
  void SetSize(int nNewSize, int nGrowBy = -1);

  void* GetAt(int nIndex) const;
  void SetAt(int nIndex, const void* newElement);
  void*& ElementAt(int nIndex);

  int Add(void* newElement);

  void InsertAt(int nIndex, void* newElement, int nCount = 1);
  void RemoveAt(int nIndex, int nCount = 1);

private:
  static int Off(int n_);

  c4_BaseArray _vector;
};

class c4_DWordArray
{
public:
  c4_DWordArray ();
  ~c4_DWordArray ();

  int GetSize() const;
  void SetSize(int nNewSize, int nGrowBy = -1);

  t4_i32 GetAt(int nIndex) const;
  void SetAt(int nIndex, t4_i32 newElement);
  t4_i32& ElementAt(int nIndex);

  int Add(t4_i32 newElement);

  void InsertAt(int nIndex, t4_i32 newElement, int nCount = 1);
  void RemoveAt(int nIndex, int nCount = 1);

private:
  static int Off(int n_);

  c4_BaseArray _vector;
};

class c4_StringArray
{
public:
  c4_StringArray ();
  ~c4_StringArray ();

  int GetSize() const;
  void SetSize(int nNewSize, int nGrowBy = -1);

  const char* GetAt(int nIndex) const;
  void SetAt(int nIndex, const char* newElement);
//  c4_String& ElementAt(int nIndex);

  int Add(const char* newElement);

  void InsertAt(int nIndex, const char* newElement, int nCount = 1);
  void RemoveAt(int nIndex, int nCount = 1);

private:
  c4_PtrArray _ptrs;
};

/////////////////////////////////////////////////////////////////////////////

#if q4_INLINE
  #include "univ.inl"
#endif

/////////////////////////////////////////////////////////////////////////////