#include <ParmParse.H>
Collaboration diagram for PP_String:
Public Methods | |
PP_String () | |
: Constructs an empty string. | |
PP_String (char c) | |
PP_String (int len) | |
PP_String (const char *s) | |
PP_String (const PP_String &rhs) | |
: The copy constructor. | |
PP_String & | operator= (const PP_String &rhs) |
: The assignment operator | |
PP_String & | operator+= (const PP_String &right) |
PP_String & | operator+= (const char *right) |
PP_String & | operator+= (char c) |
PP_String & | toUpper () |
PP_String & | toLower () |
std::istream & | getline (std::istream &strm) |
int | length () const |
bool | isNull () const |
: Returns true if this is the null string. | |
char & | operator[] (int k) |
char | operator[] (int k) const |
const char * | c_str () const |
double | toDouble () const |
int | toInteger () const |
long | toLong () const |
Protected Methods | |
void | copyModify () |
Friends | |
std::ostream & | operator<< (std::ostream &os, const PP_String &str) |
: Write to an ostream in ASCII format. | |
std::istream & | operator>> (std::istream &is, PP_String &str) |
bool | operator< (const PP_String &left, const PP_String &right) |
bool | operator<= (const PP_String &left, const PP_String &right) |
bool | operator!= (const PP_String &left, const PP_String &right) |
bool | operator== (const PP_String &left, const PP_String &right) |
bool | operator>= (const PP_String &left, const PP_String &right) |
bool | operator> (const PP_String &left, const PP_String &right) |
bool | operator< (const PP_String &left, const char *right) |
bool | operator<= (const PP_String &left, const char *right) |
bool | operator!= (const PP_String &left, const char *right) |
bool | operator== (const PP_String &left, const char *right) |
bool | operator>= (const PP_String &left, const char *right) |
bool | operator> (const PP_String &left, const char *right) |
bool | operator< (const char *left, const PP_String &right) |
bool | operator<= (const char *left, const PP_String &right) |
bool | operator!= (const char *left, const PP_String &right) |
bool | operator== (const char *left, const PP_String &right) |
bool | operator>= (const char *left, const PP_String &right) |
bool | operator> (const char *left, const PP_String &right) |
The class PP_String is used to store and manipulate character strings. It has an efficient underlying storage mechanism and some useful string manipulation operations.
The PP_String class is implemented using a character array and reference count. Two PP_Strings may reference the same underlying character array with a reference count of two. When an PP_String copy constructor or copy operator is applied the reference count on the underlying character array is incremented but the actual string is not copied. That is, copying an PP_String is an inexpensive operation. When an PP_String is destructed, the reference count is decremented. The underlying character array is deleted only when the reference count goes to zero. Any operator that modifies an PP_String will make its own copy of the character array before the modification, unless it's the sole owner of the character array in the PP_String.
This is a convenience class for ParmParse and will not be in any way supported by anyone at ANAG.
|
: Constructs an empty string.
|
|
: Constructs an PP_String containing the single character c. If c is the null character then this will be the empty string. |
|
: Constructs an empty PP_String but allocates enough space to hold a character string of length len. This may be useful when reading in very long lines with the `getline' function; i.e. it may be slightly more efficient to allocate a very large PP_String once and then use `getline' than to use `getline' on an empty string. In general though, you won't notice any difference and you really shouldn't use this constructor. |
|
: Constructs an PP_String initialized to the character string s. It is an error is `s' is the null string. |
|
: The copy constructor.
|
|
: Convert an PP_String to a const char *. This allows an PP_String to be used in any context where a const char* type is needed. |
|
|
|
: Read the next line from the input stream strm and store it as the value of the string. The delimiter for a line of text is the newline character. The newline is extracted from the istream, but it is NOT stored in the PP_String. There is no limit to the length of string that can be extracted. |
|
: Returns true if this is the null string.
|
|
: Returns the number of characters stored in this PP_String. This does not include the terminating null character. |
|
: Catenate character c onto end of this PP_String. Returns a reference to self to allow for operator chaining. This does nothing if c is the null character. |
|
: Catenate character string right onto end of this PP_String. Returns a reference to self to allow for operator chaining. It is an error is `right' is the null string. |
|
: Catenate PP_String right onto end of this PP_String. Return a reference to self to allow for operator chaining. |
|
: The assignment operator
|
|
: Returns kth character in the string. An error occurs if k < 0 or k >= length(). |
|
: Returns a reference to the kth character in the string. An error occurs if k < 0 or k >= length(). |
|
: Returns the value of the string as a double. In the case when the string is empty or when the initial characters in the string are strictly alphabetic characters, this returns zero. It's equivalent to `atof(c_str())'. |
|
: Returns the value of the string as a integer. In the case when the string is empty or when the initial characters in the string are strictly alphabetic characters, this returns zero. It's equivalent to `atoi(c_str())'. |
|
: Returns the value of the string as a long. In the case when the string is empty or when the initial characters in the string are strictly alphabetic characters, this returns zero. It's equivalent to `atol(c_str())'. |
|
: Converts all characters in this PP_String to lower case. Returns a reference to self to allow for operator chaining. |
|
: Converts all characters in this PP_String to upper case. Returns a reference to self to allow for operator chaining. |
|
|
|
|
|
|
|
|
|
|
|
|
|
: Write to an ostream in ASCII format.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
: Read a whitespace delimited string from an istream. This function discards leading whitespace and then reads in non-whitespace character until the next whitespace character or end-of-file. Note that there is no limit, on the length of the character that can be read in, except that dictated by the resources of the machine. Note also that operator>> and operator<< are not completely symmetrical in the case where operator<< writes out a string that contains whitespace. If you're trying to read in a string that contains whitespace, you might want to use getline() instead. |