9 #include "ocurvesconfig.h"
20 template <
typename CHAR>
31 inline size_t size()
const {
return _count; }
35 inline size_t count()
const {
return _count; }
39 inline size_t capacity()
const {
return _capacity; }
45 const CHAR *
operator[](
size_t index)
const {
return _items[index]; }
47 const CHAR *
operator[](
int index)
const {
return _items[index]; }
49 const CHAR *
operator[](int64_t index)
const {
return _items[index]; }
52 inline void reset() { _count = 0; }
78 template <
typename CHAR>
87 template <
typename CHAR>
94 template <
typename CHAR>
102 template <
typename CHAR>
105 if (_capacity < capacity)
108 const CHAR **newItems =
new const CHAR *[capacity];
111 memcpy(newItems, _items,
sizeof(*newItems) * _count);
115 _capacity = capacity;
120 template <
typename CHAR>
123 if (_count == _capacity)
125 reserve((_capacity) ? _capacity << 1 : 8);
127 _items[_count++] = item;
131 #endif // STRINGITEMS_H
size_t capacity() const
Return the current capacity of the array.
Definition: stringitems.h:39
StringItems()
Constructor.
Definition: stringitems.h:79
size_t count() const
Return the number of items in the array.
Definition: stringitems.h:35
const CHAR * operator[](int index) const
Definition: stringitems.h:47
void resize(size_t size)
Resizes such that the count matches size.
Definition: stringitems.h:95
void reserve(size_t capacity)
Ensures that the capacity is at least equal to capacity.
Definition: stringitems.h:103
const CHAR * operator[](int64_t index) const
Definition: stringitems.h:49
const CHAR * operator[](size_t index) const
Array accessor.
Definition: stringitems.h:45
void reset()
Resets the number of items to zero, leaving the capacity unchanged.
Definition: stringitems.h:52
An array of string pointers (into another array) using the given character type.
Definition: stringitems.h:21
size_t size() const
Return the number of items in the array.
Definition: stringitems.h:31
~StringItems()
Destructor.
Definition: stringitems.h:88
void push_back(const CHAR *item)
Adds an item to the array, incrementing the count and adjusting the capacity if required.
Definition: stringitems.h:121