21 #ifndef ELM_GENSTRUCT_TABLE_H
22 #define ELM_GENSTRUCT_TABLE_H
24 #include <elm/assert.h>
25 #include <elm/deprecated.h>
26 #include <elm/util/IndexedIterator.h>
27 #include <elm/util/array.h>
29 namespace elm {
namespace genstruct {
39 { ASSERTP(count == 0 || (count > 0 && table),
"null pointer for table"); }
43 inline int size(
void)
const {
return cnt; }
44 inline const T&
get(
int index)
const
45 { ASSERTP(index >= 0 && index <
cnt,
"index out of bounds");
return tab[index]; }
46 inline T&
get(
int index)
47 { ASSERTP(index >= 0 && index <
cnt,
"index out of bounds");
return tab[index]; }
49 { ASSERTP(index >= 0 && index <
cnt,
"index out of bounds");
tab[index] =
value; }
56 inline const T&
operator[](
int index)
const {
return get(index); }
59 inline operator bool(
void)
const {
return !
isEmpty(); }
72 inline const T *
table(
void)
const { ELM_DEPRECATED;
return tab; }
73 inline T *
table(
void) { ELM_DEPRECATED
return tab; }
90 {
copy(table);
return *
this; }
102 :
Table<T>(new T[count], count) { }
104 { copyItems(*table); }
113 { *
this = (
const Table<T>&)table;
return *
this; }
115 {
allocate(table.
count()); copyItems(*table);
return *
this; }
118 inline void copyItems(
const T *
tab)
119 {
for(
int i = 0; i < Table<T>::cnt; i++) (*
this)[i] = tab[i]; }
125 Table<T> Table<T>::EMPTY;
144 #endif // ELM_GENSTRUCT_TABLE_H
void copy(T *target, const T *source, int size)
Definition: array.h:59
void clear(void)
Definition: Table.h:93
AllocatedTable(const Table< T > &table)
Definition: Table.h:103
void copy(const Table< T > &t)
Definition: Table.h:91
~DeletableTable(void)
Definition: Table.h:86
T * operator*(void)
Definition: Table.h:61
const T * table(void) const
Definition: Table.h:72
Table(T *table, int count)
Definition: Table.h:38
table(const genstruct::Table< T > &table)
Definition: Table.h:133
Table(void)
Definition: Table.h:37
int size(void) const
Definition: Table.h:43
table(T *table, int count)
Definition: Table.h:132
AllocatedTable< T > & operator=(const AllocatedTable< T > &table)
Definition: Table.h:112
const T * operator*(void) const
Definition: Table.h:60
T * tab
Definition: Table.h:76
DeletableTable(const Table< T > &table)
Definition: Table.h:85
value_t value(CString name, int value)
Definition: rtti.h:40
const T & operator[](int index) const
Definition: Table.h:56
void copy(const Table< T > &table)
Definition: Table.h:53
AllocatedTable(void)
Definition: Table.h:100
void allocate(int count)
Definition: Table.h:107
DeletableTable(T *table, int count)
Definition: Table.h:84
DeletableTable< T > & operator=(const Table< T > &table)
Definition: Table.h:87
~AllocatedTable(void)
Definition: Table.h:105
int count(void) const
Definition: Table.h:71
table(void)
Definition: Table.h:131
Table< T > & operator=(const Table &table)
Definition: Table.h:58
dtable(void)
Definition: Table.h:137
int cnt
Definition: Table.h:77
Iterator(const Table< T > &table)
Definition: Table.h:66
dtable(T *table, int count)
Definition: Table.h:138
DeletableTable(void)
Definition: Table.h:83
DeletableTable< T > & operator=(const DeletableTable< T > &table)
Definition: Table.h:89
T & operator[](int index)
Definition: Table.h:57
void free(void)
Definition: Table.h:109
bool isEmpty(void) const
Definition: Table.h:50
Table(const Table< T > &table)
Definition: Table.h:40
dtable(const genstruct::Table< T > &table)
Definition: Table.h:139
Iterator(const Iterator &iter)
Definition: Table.h:67
AllocatedTable(int count)
Definition: Table.h:101
static Table< T > EMPTY
Definition: Table.h:35
AllocatedTable< T > & operator=(const Table< T > &table)
Definition: Table.h:114
T * table(void)
Definition: Table.h:73
Definition: IndexedIterator.h:31
void set(int index, const T &value)
Definition: Table.h:48