Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

PP_String Class Reference

A String Class for ParmParse. More...

#include <ParmParse.H>

Collaboration diagram for PP_String:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 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_Stringoperator= (const PP_String &rhs)
 : The assignment operator

PP_Stringoperator+= (const PP_String &right)
PP_Stringoperator+= (const char *right)
PP_Stringoperator+= (char c)
PP_StringtoUpper ()
PP_StringtoLower ()
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 Member Functions

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)

Detailed Description

A String Class for ParmParse.

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.


Constructor & Destructor Documentation

PP_String::PP_String  ) 
 

: Constructs an empty string.

PP_String::PP_String char  c  ) 
 

: Constructs an PP_String containing the single character c. If c is the null character then this will be the empty string.

PP_String::PP_String int  len  ) 
 

: 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.

PP_String::PP_String const char *  s  ) 
 

: Constructs an PP_String initialized to the character string s. It is an error is `s' is the null string.

PP_String::PP_String const PP_String rhs  ) 
 

: The copy constructor.


Member Function Documentation

const char * PP_String::c_str  )  const [inline]
 

: 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.

void PP_String::copyModify  )  [protected]
 

std::istream& PP_String::getline std::istream &  strm  ) 
 

: 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.

bool PP_String::isNull  )  const [inline]
 

: Returns true if this is the null string.

int PP_String::length  )  const [inline]
 

: Returns the number of characters stored in this PP_String. This does not include the terminating null character.

PP_String& PP_String::operator+= char  c  ) 
 

: 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.

PP_String& PP_String::operator+= const char *  right  ) 
 

: 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.

PP_String& PP_String::operator+= const PP_String right  ) 
 

: Catenate PP_String right onto end of this PP_String. Return a reference to self to allow for operator chaining.

PP_String& PP_String::operator= const PP_String rhs  ) 
 

: The assignment operator

char PP_String::operator[] int  k  )  const [inline]
 

: Returns kth character in the string. An error occurs if k < 0 or k >= length().

char& PP_String::operator[] int  k  ) 
 

: Returns a reference to the kth character in the string. An error occurs if k < 0 or k >= length().

double PP_String::toDouble  )  const [inline]
 

: 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())'.

int PP_String::toInteger  )  const [inline]
 

: 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())'.

long PP_String::toLong  )  const [inline]
 

: 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())'.

PP_String& PP_String::toLower  ) 
 

: Converts all characters in this PP_String to lower case. Returns a reference to self to allow for operator chaining.

PP_String& PP_String::toUpper  ) 
 

: Converts all characters in this PP_String to upper case. Returns a reference to self to allow for operator chaining.


Friends And Related Function Documentation

bool operator!= const char *  left,
const PP_String right
[friend]
 

bool operator!= const PP_String left,
const char *  right
[friend]
 

bool operator!= const PP_String left,
const PP_String right
[friend]
 

bool operator< const char *  left,
const PP_String right
[friend]
 

bool operator< const PP_String left,
const char *  right
[friend]
 

bool operator< const PP_String left,
const PP_String right
[friend]
 

std::ostream& operator<< std::ostream &  os,
const PP_String str
[friend]
 

: Write to an ostream in ASCII format.

bool operator<= const char *  left,
const PP_String right
[friend]
 

bool operator<= const PP_String left,
const char *  right
[friend]
 

bool operator<= const PP_String left,
const PP_String right
[friend]
 

bool operator== const char *  left,
const PP_String right
[friend]
 

bool operator== const PP_String left,
const char *  right
[friend]
 

bool operator== const PP_String left,
const PP_String right
[friend]
 

bool operator> const char *  left,
const PP_String right
[friend]
 

bool operator> const PP_String left,
const char *  right
[friend]
 

bool operator> const PP_String left,
const PP_String right
[friend]
 

bool operator>= const char *  left,
const PP_String right
[friend]
 

bool operator>= const PP_String left,
const char *  right
[friend]
 

bool operator>= const PP_String left,
const PP_String right
[friend]
 

std::istream& operator>> std::istream &  is,
PP_String str
[friend]
 

: 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.


The documentation for this class was generated from the following file:
Generated on Wed Jun 2 13:59:03 2004 for Chombo&INSwithParticles by doxygen 1.3.2