Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

String Class Reference

safe interface to strings represented as char arrays. More...

#include <DpString.h>

List of all members.

Public Methods

 String ()
 String (char *buffer, int length)
 String (const char *s)
 String (const String &s)
 String (int nchars)
 String (char c)
void redim (int nchars)
String pureCopy () const
String subString (int startpos, int length) const
String& operator= (const char *s)
String& operator= (const String &s)
String& operator= (char c)
 ~String ()
void strip ()
const char* c_str () const
char* c_str ()
const char* chars () const
char* chars ()
char& operator[] (int i)
char operator[] (int i) const
int size () const
int length () const
int len () const
char firstchar () const
char lastchar () const
bool empty () const
bool ok () const
int getInt () const
real getReal () const
bool getBool () const
bool getToken (String &token, const char *delimiters="\n\t")
bool getToken (String &token, int token_no, const char *delimiters="\n\t")
int getNoTokens (const char *delimiters)
void replace (char from, char to)
int search (int startpos, char c) const
int search (int startpos, const String &substring) const
int match (int startpos, int exact, const String &substring) const
void del (int startpos, int length)
void del (const String &y, int startpos=0)
void del (char c, int startpos=0)
bool contains (char c) const
bool contains (const String &y) const
bool contains (const String &y, int startpos) const
bool matches (const String &y, int startpos=0) const
int index (char c, int startpos=0) const
int index (const String &t, int startpos=0) const
String at (int first, int len) const
String operator() (int first, int len) const
String before (int pos) const
String through (int pos) const
String after (int pos) const
String from (int pos) const
String at (const String &y, int startpos=0) const
String at (char c, int startpos=0) const
String before (const String &y, int startpos=0) const
String before (char c, int startpos=0) const
String through (const String &y, int startpos=0) const
String through (char c, int startpos=0) const
String after (const String &y, int startpos=0) const
String after (char c, int startpos=0) const
String from (const String &y, int startpos=0) const
String from (char c, int startpos=0) const
void operator+= (const String &x)
void operator+= (char c)
void print (const String &s) const

Static Public Methods

void defineOutputOfEmptyString (char *s)

Friends

bool operator== (const String &x, const char *s)
bool operator== (const String &x, const String &y)
bool operator!= (const String &x, const char *s)
bool operator!= (const String &x, const String &y)
bool operator< (const String &x, const String &y)
bool operator< (const String &x, const char *s)
bool operator<= (const String &x, const String &y)
bool operator<= (const String &x, const char *s)
bool operator> (const String &x, const String &y)
bool operator> (const String &x, const char *s)
bool operator>= (const String &x, const String &y)
bool operator>= (const String &x, const char *s)
String operator+ (const String &x, const String &y)
ostream& operator<< (ostream &out, const String &s)
istream& operator>> (istream &in, String &s)


Detailed Description

safe interface to strings represented as char arrays.

NAME: String - safe interface to strings represented as char arrays

DESCRIPTION:

The class implements strings with reference counting. The implementation is inspired by Stroustrup's example in his C++ textbook. Additional functions are added here. The class was developed as a consequence of problems with "alloca" with the GNU String class.


Constructor & Destructor Documentation

String::String ( )
 

The constructors offer initializations of empty strings, initialization by a character array, initialization of a buffer of specified length etc.

String::String ( char * buffer,
int length )
 

See documentation of one of the overloaded constructor.

String::String ( const char * s )
 

See documentation of one of the overloaded constructor.

String::String ( const String & s )
 

See documentation of one of the overloaded constructor.

String::String ( int nchars )
 

See documentation of one of the overloaded constructor.

String::String ( char c )
 

See documentation of one of the overloaded constructor.

String::~String ( )
 


Member Function Documentation

String String::after ( char c,
int startpos = 0 ) const
 

String String::after ( const String & y,
int startpos = 0 ) const
 

String String::after ( int pos ) const
 

String String::at ( char c,
int startpos = 0 ) const
 

String String::at ( const String & y,
int startpos = 0 ) const
 

String String::at ( int first,
int len ) const
 

String String::before ( char c,
int startpos = 0 ) const
 

String String::before ( const String & y,
int startpos = 0 ) const
 

String String::before ( int pos ) const
 

char * String::c_str ( )
 

const char * String::c_str ( ) const
 

char * String::chars ( ) [inline]
 

const char * String::chars ( ) const [inline]
 

bool String::contains ( const String & y,
int startpos ) const
 

bool String::contains ( const String & y ) const
 

bool String::contains ( char c ) const
 

void String::defineOutputOfEmptyString ( char * s ) [inline, static]
 

void String::del ( char c,
int startpos = 0 )
 

void String::del ( const String & y,
int startpos = 0 )
 

void String::del ( int startpos,
int length )
 

bool String::empty ( ) const
 

returns "true" is the string is the empty string (no characters except for the termination character).

char String::firstchar ( ) const
 

String String::from ( char c,
int startpos = 0 ) const
 

String String::from ( const String & y,
int startpos = 0 ) const
 

String String::from ( int pos ) const
 

bool String::getBool ( ) const
 

int String::getInt ( ) const [inline]
 

int String::getNoTokens ( const char * delimiters )
 

real String::getReal ( ) const [inline]
 

bool String::getToken ( String & token,
int token_no,
const char * delimiters = " \n\t" )
 

bool String::getToken ( String & token,
const char * delimiters = " \n\t" )
 

int String::index ( const String & t,
int startpos = 0 ) const
 

int String::index ( char c,
int startpos = 0 ) const
 

char String::lastchar ( ) const
 

int String::len ( ) const [inline]
 

int String::length ( ) const [inline]
 

int String::match ( int startpos,
int exact,
const String & substring ) const
 

bool String::matches ( const String & y,
int startpos = 0 ) const
 

bool String::ok ( ) const
 

returns the opposite of "empty", that is, a true value if the string is different from the empty string """". Recall that a declaration "String s;" leads to "s" being set equal to the empty string and not a NULL character pointer.

String String::operator() ( int first,
int len ) const
 

void String::operator+= ( char c )
 

void String::operator+= ( const String & x )
 

String & String::operator= ( char c )
 

String & String::operator= ( const String & s )
 

String & String::operator= ( const char * s )
 

char String::operator[] ( int i ) const
 

char & String::operator[] ( int i )
 

void String::print ( const String & s ) const
 

String String::pureCopy ( ) const
 

void String::redim ( int no_algdofs )
 

void String::replace ( char from,
char to )
 

int String::search ( int startpos,
const String & substring ) const
 

int String::search ( int startpos,
char c ) const
 

int String::size ( ) const
 

void String::strip ( )
 

String String::subString ( int startpos,
int length ) const
 

String String::through ( char c,
int startpos = 0 ) const
 

String String::through ( const String & y,
int startpos = 0 ) const
 

String String::through ( int pos ) const
 


Friends And Related Function Documentation

bool operator!= ( const String & x,
const String & y ) [friend]
 

bool operator!= ( const String & x,
const char * s ) [friend]
 

String operator+ ( const String & x,
const String & y ) [friend]
 

bool operator< ( const String & x,
const char * s ) [friend]
 

bool operator< ( const String & x,
const String & y ) [friend]
 

ostream & operator<< ( ostream & out,
const String & s ) [friend]
 

bool operator<= ( const String & x,
const char * s ) [friend]
 

bool operator<= ( const String & x,
const String & y ) [friend]
 

bool operator== ( const String & x,
const String & y ) [friend]
 

bool operator== ( const String & x,
const char * s ) [friend]
 

bool operator> ( const String & x,
const char * s ) [friend]
 

bool operator> ( const String & x,
const String & y ) [friend]
 

bool operator>= ( const String & x,
const char * s ) [friend]
 

bool operator>= ( const String & x,
const String & y ) [friend]
 

istream & operator>> ( istream & in,
String & s ) [friend]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.