HTM SpatialIndex Class Reference

class VarStr

Dynamic string

Public Methods

~VarStr ( void )
Destructor
VarStr ( size_t capacity = 0, size_t increment = 0 )
Default constructor
VarStr ( const char * )
Construct from a string
VarStr ( const VarStr& )
Copy constructor
char operator () ( size_t index ) const
Efficient array operator (const version): no bounds checking
char& operator () ( size_t index )
Efficient array operator (non-const version): no bounds checking
char operator [] ( size_t index ) const
Bounds-checking array operator (const version): throws sxBoundsError
char& operator [] ( size_t index )
Bounds-checking array operator (non-const version): throws sxBoundsError
operator char* () const
Char conversion
char& at ( size_t index )
Bounds-adjusting array operator
size_t length ( void ) const
Returns current occupied length of array
size_t append ( const char )
Append method
size_t append ( unsigned char *buf, const int len )
Append method for binary data
size_t insert ( size_t count, size_t offset = 0, char c = ' ' )
Insert new array elements
size_t cut ( size_t count, size_t offset = 0 )
Remove array elements
void remove ( size_t offset, size_t count = 1 )
Removes the element specified by offset
void write ( ostream& _out ) const
Write out the contents as a binary buffer
void clear ( void )
clear method
char* data () const
return the string itself
bool empty () const
return true if string is empty, false if not

Public


Assignment/copy operator
VarStr& operator = ( const char * )
VarStr& operator = ( const char )
VarStr& operator = ( const int )

Comparison operators
int operator == ( const char *) const
int operator != ( const VarStr &) const
int operator != ( const char *) const

String extension
friend VarStr& operator + ( const VarStr &, const char * )
friend VarStr& operator + ( const char *, const VarStr & )

String extension
VarStr& operator += ( const char *)
VarStr& operator += ( const char )
VarStr& operator += ( const int )

Binary string extension, represented by operator "*="
VarStr& operator *= ( const int16 )
VarStr& operator *= ( const uint16 )
VarStr& operator *= ( const int32 )
VarStr& operator *= ( const uint32 )
VarStr& operator *= ( const int64 )
VarStr& operator *= ( const uint64 )
VarStr& operator *= ( const float32 )
VarStr& operator *= ( const float64 )

Documentation

Dynamic string. This is a template for a general-purpose dynamic string. The array grows automatically as needed, but reallocation occurs only when the length exceeds the capacity. The capacity is increased in large blocks, the size of which may be optimized. The public data member, increment_, specifies the amount by which the capacity is increased during reallocation. By default, increment_ is zero, which causes the capacity to double upon each reallocation. A non-zero increment_ is simply added to the capacity upon each reallocation. The capacity is extended by this amount or by whatever greater amount is necessary to accommodate the new length of the array.
~VarStr( void )
Destructor

VarStr( size_t capacity = 0, size_t increment = 0 )
Default constructor. optionally specify initial capacity and reallocation increment.

VarStr( const char * )
Construct from a string

VarStr( const VarStr& )
Copy constructor. The initial capacity is the current capacity of the duplicated array.

Assignment/copy operator. does not decrease the capacity.

VarStr& operator =( const char * )

VarStr& operator =( const char )

VarStr& operator =( const int )

char operator ()( size_t index ) const
Efficient array operator (const version): no bounds checking

char& operator ()( size_t index )
Efficient array operator (non-const version): no bounds checking

char operator []( size_t index ) const
Bounds-checking array operator (const version): throws sxBoundsError

char& operator []( size_t index )
Bounds-checking array operator (non-const version): throws sxBoundsError

Comparison operators

int operator == ( const char *) const

int operator != ( const VarStr &) const

int operator != ( const char *) const

String extension

friend VarStr& operator + ( const VarStr &, const char * )

friend VarStr& operator + ( const char *, const VarStr & )

String extension

VarStr& operator += ( const char *)

VarStr& operator += ( const char )

VarStr& operator += ( const int )

Binary string extension, represented by operator "*="

VarStr& operator *= ( const int16 )

VarStr& operator *= ( const uint16 )

VarStr& operator *= ( const int32 )

VarStr& operator *= ( const uint32 )

VarStr& operator *= ( const int64 )

VarStr& operator *= ( const uint64 )

VarStr& operator *= ( const float32 )

VarStr& operator *= ( const float64 )

operator char* () const
Char conversion

char& at( size_t index )
Bounds-adjusting array operator. Returns the array element at the specified index, extending the array as necessary to bring it within bounds. The fill value, if defined, is the initializer for any new elements.

size_t length( void ) const
Returns current occupied length of array

size_t append( const char )
Append method. efficiently insert given element at end of array. Avoids redundant initialization of new array element, except for when a reallocation is required. Returns the new length.

size_t append( unsigned char *buf, const int len )
Append method for binary data. Adds the contents of the given buffer to the string byte by byte. Returns the new length.

size_t insert( size_t count, size_t offset = 0, char c = ' ' )
Insert new array elements. count specifies the number of new elements, and offset specifies where in the array to insert them. By default the new elements are appended. The fill value, if defined, is the initializer for the new elements. offset refers to the end of the array: the first new element is located at index (length - offset). Returns the new length. Throws sxBoundsError if offset is greater than length.

size_t cut( size_t count, size_t offset = 0 )
Remove array elements. count specifies the number of elements to remove, and offset specifies which elements to remove. By default elements are removed from the end of the array. The unused capacity grows by this amount. offset refers to the end of the array: the first removed element is located at index (length - offset - count). Returns the new length. Throws sxBoundsError if (offset+count) is greater than length.

void remove( size_t offset, size_t count = 1 )
Removes the element specified by offset. This is basically a wrapper for the cut method
cut(1, length-offset-1)

void write( ostream& _out ) const
Write out the contents as a binary buffer. Use the low-level stream write function.

void clear( void )
clear method

char* data() const
return the string itself

bool empty() const
return true if string is empty, false if not


This class has no child classes.

alphabetic index hierarchy of classes


© Copyright The Johns Hopkins University 1999, All Rights Reserved.
Peter Z. Kunszt,

generated by doc++