OpenCurves  0.9
StringItems< CHAR > Class Template Reference

An array of string pointers (into another array) using the given character type. More...

#include <stringitems.h>

Public Member Functions

 StringItems ()
 Constructor.
 
 ~StringItems ()
 Destructor.
 
size_t size () const
 Return the number of items in the array. More...
 
size_t count () const
 Return the number of items in the array. More...
 
size_t capacity () const
 Return the current capacity of the array. More...
 
const CHAR * operator[] (size_t index) const
 Array accessor. More...
 
const CHAR * operator[] (int index) const
 
const CHAR * operator[] (int64_t index) const
 
void reset ()
 Resets the number of items to zero, leaving the capacity unchanged.
 
void resize (size_t size)
 Resizes such that the count matches size. More...
 
void reserve (size_t capacity)
 Ensures that the capacity is at least equal to capacity. More...
 
void push_back (const CHAR *item)
 Adds an item to the array, incrementing the count and adjusting the capacity if required. More...
 

Detailed Description

template<typename CHAR>
class StringItems< CHAR >

An array of string pointers (into another array) using the given character type.

Used in place of QVector because the latter deallocates on resize to zero. We want to reuse the memory.

Template Parameters
CHARThe character type. Generally char or wchar_t.

Member Function Documentation

template<typename CHAR >
size_t StringItems< CHAR >::capacity ( ) const
inline

Return the current capacity of the array.

Returns
The current capacity.
template<typename CHAR >
size_t StringItems< CHAR >::count ( ) const
inline

Return the number of items in the array.

Returns
The number of items.
template<typename CHAR >
const CHAR* StringItems< CHAR >::operator[] ( size_t  index) const
inline

Array accessor.

Returns the item at index.

Parameters
indexThe requested item index, in the range [0, count()). Out of range requests result in undefined behaviour.
Returns
The string at index.
template<typename CHAR >
const CHAR* StringItems< CHAR >::operator[] ( int  index) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename CHAR >
const CHAR* StringItems< CHAR >::operator[] ( int64_t  index) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename CHAR >
void StringItems< CHAR >::push_back ( const CHAR *  item)

Adds an item to the array, incrementing the count and adjusting the capacity if required.

Parameters
itemThe string to insert.
template<typename CHAR >
void StringItems< CHAR >::reserve ( size_t  capacity)

Ensures that the capacity is at least equal to capacity.

The capacity does not change if capacity is less than or equal to the current capaccity.

Parameters
capacityThe requested capacity.
template<typename CHAR >
void StringItems< CHAR >::resize ( size_t  size)

Resizes such that the count matches size.

The capacity is adjusted up if required, but not down.

Parameters
sizeThe requested size.
template<typename CHAR >
size_t StringItems< CHAR >::size ( ) const
inline

Return the number of items in the array.

Returns
The number of items.

The documentation for this class was generated from the following file: