CharString Class Reference

The CharString class is derived from the SimpleArray<char> class. More...

#include <CharString.h>

Inheritance diagram for CharString::

SimpleArray< char > BasicArray< char > List of all members.

Public Methods

 CharString ()
 Null constructor.

 CharString (const size_type len, char *str=(char *) 0, const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the length and possibly data. More...

 CharString (char *str, const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the data using the array str. More...

 CharString (const char *str, const EnumDataOwned own=DataNotOwned)
 Constructor that initializes the data using the array str. More...

 CharString (const CharString &array)
 Copy constructor.

CharString & operator= (const CharString &str)
 Copy operator=.

size_type size () const
 Returns the length of the string.

int resize (const size_type)
 Resizes the string to the given, nonnegative, value.

int operator== (const char *array) const
 Checks to see if the current array equals array.

int operator!= (const char *array) const
 Checks to see if the current array is not equal to array.

int operator== (char *array) const
 Checks to see if the current array equals array.

int operator!= (char *array) const
 Checks to see if the current array is not equal to array.

int operator< (const CharString &array) const
 Checks to see if the current array is lexicographically less than array.

int operator> (const CharString &array) const
 Checks to see if the current array is lexicographically greater than array.

CharString & operator+= (const char *array)
 Appends the string with array.

CharString & operator+= (char *array)
 Appends the string with array.

CharString & operator+= (const int val)
 Appends the string with a string representation of val.

CharString & operator+= (const double val)
 Appends the string with a string representation of val.

CharString & set_subvec (const size_type start, const size_type len, const CharString &datavec, const size_type offset=0)
 Copy a substring from datavec. More...

int write (ostream &output) const
 Write the string to an output stream.

int write (PackBuffer &output) const
 Pack the array into a PackBuffer class.

int read (istream &input)
 Read a string from an input stream. More...

int read (UnPackBuffer &input)
 Unpack the string from an UnPackBuffer class.


Protected Methods

virtual void construct (const size_type len, char *d, const EnumDataOwned o=DataNotOwned)
 Method used by constructors to setup the CharString class.


Friends

int compare (const CharString &str1, const CharString &str2)

Detailed Description

The CharString class is derived from the SimpleArray<char> class.

However, it manipulates strings that contain a terminating null '\000' at the end, without requiring the user to explicitly know that this exists.

Potential bug: when a CharString is initialized with a const char*, the class does not explicitly prohibit the modification of the character array. This was done to keep all of the basic operations relatively efficient.


Constructor & Destructor Documentation

CharString::CharString const size_type    len,
char *    str = (char*)0,
const EnumDataOwned    own = DataNotOwned
[explicit]
 

Constructor that initializes the length and possibly data.

The len parameter specifies the length of the array. If the d parameter is not null, then this array is assumed to have length len. The initialization of the array then depends upon the value of the o parameter. If o is DataNotOwned (the default), then the data is copied from d. Otherwise, the internal point is set to d and the internal ownership flag is set to o.

CharString::CharString char *    str,
const EnumDataOwned    own = DataNotOwned
 

Constructor that initializes the data using the array str.

The length is determined by computing the length of str, and ownership is handled as above.

CharString::CharString const char *    str,
const EnumDataOwned    own = DataNotOwned
 

Constructor that initializes the data using the array str.

The length is determined by computing the length of str, and ownership is handled as above.


Member Function Documentation

int CharString::read istream &    input [virtual]
 

Read a string from an input stream.

This method operates like a normal stream operator would. Whitespace is ignored, and characters are read until a standard delimiter is read: whitespace, '\t' or '\n'.

Reimplemented from SimpleArray.

CharString& CharString::set_subvec const size_type    start,
const size_type    len,
const CharString &    datavec,
const size_type    offset = 0
 

Copy a substring from datavec.

The substring beginning at offset in datavec and ending at offset + len - 1 is copied to the substring in the current array beginning at start.


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