BALL::String Class Reference
[String]

#include <BALL/DATATYPE/string.h>

Inheritance diagram for BALL::String:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void * create (bool=true, bool empty=false) const
Constructors and Destructors

 String ()
 Default Constructor.
 String (const string &string)
 STL string copy constructor.
 String (const QString &string)
 QString copy constructor.
 String (const QByteArray &string)
 QByteArray copy constructor.
 String (const String &s, Index from, Size len=EndPos) throw (Exception::IndexUnderflow, Exception::IndexOverflow)
 String (const char *char_ptr, Index from=0, Size len=EndPos) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
 String (Size buffer_size, const char *format,...) throw (Exception::IndexUnderflow, Exception::NullPointer)
 String (std::strstream &s)
 String (const char c, Size len=1)
 String (const unsigned char uc)
 Creates a string just containing an unsigned character.
 String (short s)
 Construct a String from a short.
 String (unsigned short us)
 Construct a String from an unsigned short.
 String (int i)
 Construct a String from an int.
 String (unsigned int ui)
 Construct a String from an unsigned int.
 String (long l)
 Construct a String from a long.
 String (unsigned long)
 Construct a String from an unsigned long.
 String (float f)
 Construct a String from a float value.
 String (double d)
 Construct a String from a double value.
virtual ~String ()
 Destructor.
void destroy ()
 Clear the string (reset to the empty string).
virtual void clear ()
 Clears the string (same as destroy).
Assignment methods

void set (const String &s)
void set (const String &string, Index from, Size len=EndPos) throw (Exception::IndexUnderflow, Exception::IndexOverflow)
void set (const char *char_ptr, Index from=0, Size len=EndPos) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
void set (Size buffer_size, const char *format,...) throw (Exception::IndexUnderflow, Exception::NullPointer)
void set (std::strstream &s)
void set (char c, Size len=1)
 Assign a String from the result of repeating c len times.
void set (unsigned char uc)
 Assign a String from an unsigned char.
void set (short s)
 Assign a String from a short.
void set (unsigned short us)
 Assign a String from an unsigned short.
void set (int i)
 Assign a String from an int.
void set (unsigned int ui)
 Assign a String from an unsigned int.
void set (long l)
 Assign a String from a long.
void set (unsigned long ul)
 Assign a String from an unsigned long.
void set (float f)
 Assign a String from a float value.
void set (double d)
 Assign a String from a double value.
void get (char *char_ptr, Index from=0, Size len=EndPos) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
 Assign to a C type string.
const Stringoperator= (const String &s)
 Assign a String from another String.
const Stringoperator= (const char *pc) throw (Exception::NullPointer)
 Assign a String from a C type string.
const Stringoperator= (std::strstream &s)
const Stringoperator= (char c)
 Assign a String from a single char.
const Stringoperator= (unsigned char uc)
 Assign a String from an unsigned char.
const Stringoperator= (short s)
 Assign a String from a short.
const Stringoperator= (unsigned short us)
 Assign a String from an unsigned short.
const Stringoperator= (int i)
 Assign a String from an int.
const Stringoperator= (unsigned int ui)
 Assign a String from an unsigned int.
const Stringoperator= (long l)
 Assign a String from a long.
const Stringoperator= (unsigned long ul)
 Assign a String from an unsigned long.
const Stringoperator= (float f)
 Assign a String from a float.
const Stringoperator= (double d)
 Assign a String from a double.
Converters

bool toBool () const
char toChar () const
 Return the first character of the string.
unsigned char toUnsignedChar () const
 Return the first character of the string converted to an unsigned char.
short toShort () const throw (Exception::InvalidFormat)
 Convert the string to a short.
unsigned short toUnsignedShort () const throw (Exception::InvalidFormat)
 Convert the string to an unsigned short.
int toInt () const throw (Exception::InvalidFormat)
 Convert the string to an int.
unsigned int toUnsignedInt () const throw (Exception::InvalidFormat)
 Convert the string to an unsigned int.
long toLong () const throw (Exception::InvalidFormat)
 Convert the string to a long.
unsigned long toUnsignedLong () const throw (Exception::InvalidFormat)
 Convert the string to an unsigned long.
float toFloat () const throw (Exception::InvalidFormat)
 Convert the string to a float.
double toDouble () const throw (Exception::InvalidFormat)
 Convert the string to a double.
Case Conversion

void toLower (Index from=0, Size len=EndPos) throw (Exception::IndexUnderflow, Exception::IndexOverflow)
 Convert all characters in the given range to lower case.
void toUpper (Index from=0, Size len=EndPos) throw (Exception::IndexUnderflow, Exception::IndexOverflow)
 Convert all characters in the given range to upper case.
Substring Definition

Substring getSubstring (Index from=0, Size len=EndPos) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
 Return a substring.
Substring operator() (Index from, Size len=EndPos) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
 Return a substring.
Substring before (const String &s, Index from=0) const
Substring through (const String &s, Index from=0) const
Substring from (const String &s, Index from=0) const
Substring after (const String &s, Index from=0) const
AWK style field operations

Size countFields (const char *delimiters=CHARACTER_CLASS__WHITESPACE) const throw (Exception::NullPointer)
 Count the fields that are separated by a defined set of delimiters.
Size countFieldsQuoted (const char *delimiters=CHARACTER_CLASS__WHITESPACE, const char *quotes=CHARACTER_CLASS__QUOTES) const throw (Exception::NullPointer)
 Count the fields and respect quote characters.
String getField (Index index, const char *delimiters=CHARACTER_CLASS__WHITESPACE, Index *from=0) const throw (Exception::IndexUnderflow, Exception::NullPointer)
 Return a given field as a substring.
String getFieldQuoted (Index index, const char *delimiters=CHARACTER_CLASS__WHITESPACE, const char *quotes=CHARACTER_CLASS__QUOTES, Index *from=0) const throw (Exception::IndexUnderflow, Exception::NullPointer)
 Return a given field and respect quote characters.
Size split (String string_array[], Size array_size, const char *delimiters=CHARACTER_CLASS__WHITESPACE, Index from=0) const throw (Exception::IndexUnderflow, Exception::NullPointer)
Size split (std::vector< String > &strings, const char *delimiters=CHARACTER_CLASS__WHITESPACE, Index from=0) const throw (Exception::IndexUnderflow, Exception::NullPointer)
Size splitQuoted (std::vector< String > &strings, const char *delimiters=CHARACTER_CLASS__WHITESPACE, const char *quotes=CHARACTER_CLASS__QUOTES, Index from=0) const throw (Exception::IndexUnderflow, Exception::NullPointer)
BASIC style string operations

StringtrimLeft (const char *trimmed=CHARACTER_CLASS__WHITESPACE)
StringtrimRight (const char *trimmed=CHARACTER_CLASS__WHITESPACE)
Stringtrim (const char *trimmed=CHARACTER_CLASS__WHITESPACE)
String trim (const char *trimmed=CHARACTER_CLASS__WHITESPACE) const
Stringtruncate (Size size)
 Truncate the string to length size
Substring left (Size len) const
 Return a substring containing the len leftmost characters of the string.
Substring right (Size len) const
 Return a substring containing the len rightmost characters of the string.
Substring instr (const String &pattern, Index from=0) const
Base64 String methods

String encodeBase64 ()
 Convert a string to a base 64 string.
String decodeBase64 ()
Debugging and Diagnostics

bool isValid () const
void dump (std::ostream &s=std::cout, Size depth=0) const

Static Public Member Functions

Compare mode-related methods.

All string comparisons can be made case-sensitive or case insensitive. The behavior can be toggled globally for all strings.

static void setCompareMode (CompareMode compare_mode)
 Set the compareison mode for all string comparisons.
static CompareMode getCompareMode ()
 Return the current comparison mode.

Static Public Attributes

static const String EMPTY
 Constant empty string.
Predefined character classes

There exist several predefined character classes, that may be used in several functions (e.g. trim methods) to represent a set of characters.

static const char * CHARACTER_CLASS__ASCII_ALPHA
 Character class containing all letters (lower and upper case).
static const char * CHARACTER_CLASS__ASCII_ALPHANUMERIC
 Character class containing all letters and digits.
static const char * CHARACTER_CLASS__ASCII_LOWER
 Character class containing all lower case letters.
static const char * CHARACTER_CLASS__ASCII_UPPER
 Character class containing all upper case letters.
static const char * CHARACTER_CLASS__ASCII_NUMERIC
 Character class containing the digits from 0 to 9.
static const char * CHARACTER_CLASS__ASCII_FLOAT
 Character class containing the digits from 0 to 9 and a dot.
static const char * CHARACTER_CLASS__WHITESPACE
static const char * CHARACTER_CLASS__QUOTES

Protected Member Functions

void validateIndex_ (Index &index) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
void validateRange_ (Index &from, Size &len) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Static Protected Member Functions

static void validateCharPtrRange_ (Index &from, Size &len, const char *char_ptr) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
static void valudateCharPtrIndex_ (Index &index)

Static Private Member Functions

static int compareAscendingly_ (const char *a, const char *b)
static int compareDescendingly_ (const char *a, const char *b)

Static Private Attributes

static CompareMode compare_mode_
static char B64Chars_ [64]
static int Index_64_ [128]

Friends

class Substring

Enums and Constants



enum  CompareMode { CASE_SENSITIVE = 0, CASE_INSENSITIVE = 1 }
static const Size EndPos

String Operations



BALL_EXPORT friend String operator+ (const String &s1, const string &s2)
 Concatenates two strings.
BALL_EXPORT friend String operator+ (const string &s1, const String &s2)
 Concatenates two strings.
BALL_EXPORT friend String operator+ (const String &s1, const String &s2)
 Concatenates two strings.
BALL_EXPORT friend String operator+ (const String &s1, const char *char_ptr)
 Concatenates a string and a C type string.
BALL_EXPORT friend String operator+ (const char *char_ptr, const String &s)
 Concatenates a C type string and a string.
BALL_EXPORT friend String operator+ (const String &s, char c)
 Concatenates a string and a character.
BALL_EXPORT friend String operator+ (char c, const String &s)
 Concatenates a character and a string.
void swap (String &s)
 Swaps the contents with another String.
Stringreverse (Index from=0, Size len=EndPos) throw (Exception::IndexUnderflow, Exception::IndexOverflow)
Size substitute (const String &to_replace, const String &replacing)

Comparators



BALL_EXPORT friend bool operator== (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator!= (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator< (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator<= (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator> (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator>= (const char *char_ptr, const String &string) throw (Exception::NullPointer)
BALL_EXPORT friend bool operator== (char c, const String &string)
BALL_EXPORT friend bool operator!= (char c, const String &string)
BALL_EXPORT friend bool operator< (char c, const String &string)
BALL_EXPORT friend bool operator<= (char c, const String &string)
BALL_EXPORT friend bool operator> (char c, const String &string)
bool operator>= (char c, const String &string)
int compare (const String &string, Index from=0) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
int compare (const String &string, Index from, Size len) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
int compare (const char *char_ptr, Index from=0) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
int compare (const char *char_ptr, Index from, Size len) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
int compare (char c, Index from=0) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
bool operator== (const String &string) const
bool operator!= (const String &string) const
bool operator< (const String &string) const
bool operator<= (const String &string) const
bool operator>= (const String &string) const
bool operator> (const String &string) const
bool operator== (const char *char_ptr) const throw (Exception::NullPointer)
bool operator!= (const char *char_ptr) const throw (Exception::NullPointer)
bool operator< (const char *char_ptr) const throw (Exception::NullPointer)
bool operator<= (const char *char_ptr) const throw (Exception::NullPointer)
bool operator> (const char *char_ptr) const throw (Exception::NullPointer)
bool operator>= (const char *char_ptr) const throw (Exception::NullPointer)
bool operator== (char c) const
bool operator!= (char c) const
bool operator< (char c) const
bool operator<= (char c) const
bool operator> (char c) const
bool operator>= (char c) const

Stream Operations



BALL_EXPORT friend std::istream & getline (std::istream &s, String &string, char delimiter= '\n')
std::istream & getline (std::istream &s=std::cin, char delimiter= '\n')

Predicates



bool has (char c) const
 True, if the string contains character c
bool hasSubstring (const String &s, Index from=0) const
 True, if the string contains the substring s after index from
bool hasPrefix (const String &s) const
 True, if the string starts with s
bool hasSuffix (const String &s) const
 True, if the string ends with s
bool isEmpty () const
 True, if the string has size 0.
bool isAlpha () const
bool isAlnum () const
bool isDigit () const
bool isFloat () const
bool isSpace () const
bool isWhitespace () const
static bool isAlpha (char c)
 True, if the character is a letter (any case).
static bool isAlnum (char c)
 True, if the character is a letter or a digit.
static bool isDigit (char c)
 True, if the character is a digit.
static bool isSpace (char c)
 True, if the character is a space.
static bool isWhitespace (char c)

Detailed Description

Extended String class.

Definition at line 63 of file string.h.


Member Enumeration Documentation

Constants to set the compare mode. Use one of these constants to set the mode you need. These modes affect all compare methods. As these methods are also used in the implementation of comparison operators, all comparison operations will get affected from a change.

You may change the comparison mode by invoking setCompareMode.
Enumerator:
CASE_SENSITIVE 

Constant to set to case sensitive comparisons (default).

CASE_INSENSITIVE 

Constant to set to case insensitive comparisons.

Definition at line 88 of file string.h.


Constructor & Destructor Documentation

BALL::String::String (  ) 

Default Constructor.

BALL::String::String ( const string &  string  ) 

STL string copy constructor.

BALL::String::String ( const QString &  string  )  [explicit]

QString copy constructor.

BALL::String::String ( const QByteArray &  string  )  [explicit]

QByteArray copy constructor.

BALL::String::String ( const String s,
Index  from,
Size  len = EndPos 
) throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Creates a new string from a given range of another string.

See also:
String:Indices
Exceptions:
Exception::IndexUnderflow if from < 0
Exception::IndexOverflow if from >= size()
BALL::String::String ( const char *  char_ptr,
Index  from = 0,
Size  len = EndPos 
) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)

Creates a new string from a C type string. The new string contains the contents of s until it has reached a length of len or contains a zero character (whichever comes first). Default value for len is EndPos, meaning as long as possible.

BALL::String::String ( Size  buffer_size,
const char *  format,
  ... 
) throw (Exception::IndexUnderflow, Exception::NullPointer)

Creates a string using sprintf. This constructor creates a new string and sets its content to the result of a call to sprintf using format as a format string and all additional parameters as arguments.

The result of the sprintf call is intermediately written to a buffer of a maximum size of buffer_size characters, so choose an appropriate size for this variables.
Exceptions:
IndexUnderflow,if the buffer size specified is not larger than 0
NullPointer,if format == 0
BALL::String::String ( std::strstream &  s  ) 

Create a new string from the contents of a stringstream. The contents of the stringstream are not modified, i.e. successive construction of multiple strings from the same stringstream object leads to identical copies.

BALL::String::String ( const char  c,
Size  len = 1 
)

Creates a new string from len copies of c.

BALL::String::String ( const unsigned char  uc  ) 

Creates a string just containing an unsigned character.

BALL::String::String ( short  s  ) 

Construct a String from a short.

BALL::String::String ( unsigned short  us  ) 

Construct a String from an unsigned short.

BALL::String::String ( int  i  ) 

Construct a String from an int.

BALL::String::String ( unsigned int  ui  ) 

Construct a String from an unsigned int.

BALL::String::String ( long  l  ) 

Construct a String from a long.

BALL::String::String ( unsigned  long  ) 

Construct a String from an unsigned long.

BALL::String::String ( float  f  ) 

Construct a String from a float value.

BALL::String::String ( double  d  ) 

Construct a String from a double value.

virtual BALL::String::~String (  )  [virtual]

Destructor.


Member Function Documentation

Substring BALL::String::after ( const String s,
Index  from = 0 
) const

Return a substring containing the string after the first occurence of s.

Substring BALL::String::before ( const String s,
Index  from = 0 
) const

Return a substring containing the string before the first occurence of s

virtual void BALL::String::clear (  )  [virtual]

Clears the string (same as destroy).

int BALL::String::compare ( char  c,
Index  from = 0 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
int BALL::String::compare ( const char *  char_ptr,
Index  from,
Size  len 
) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
int BALL::String::compare ( const char *  char_ptr,
Index  from = 0 
) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)
int BALL::String::compare ( const String string,
Index  from,
Size  len 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
int BALL::String::compare ( const String string,
Index  from = 0 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)
static int BALL::String::compareAscendingly_ ( const char *  a,
const char *  b 
) [static, private]
static int BALL::String::compareDescendingly_ ( const char *  a,
const char *  b 
) [static, private]
Size BALL::String::countFields ( const char *  delimiters = CHARACTER_CLASS__WHITESPACE  )  const throw (Exception::NullPointer)

Count the fields that are separated by a defined set of delimiters.

Size BALL::String::countFieldsQuoted ( const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
const char *  quotes = CHARACTER_CLASS__QUOTES 
) const throw (Exception::NullPointer)

Count the fields and respect quote characters.

virtual void* BALL::String::create ( bool  = true,
bool  empty = false 
) const [virtual]
String BALL::String::decodeBase64 (  ) 

Decode a base 64 string. Return an empty string, if base64 string is not right encoded.

void BALL::String::destroy (  ) 

Clear the string (reset to the empty string).

void BALL::String::dump ( std::ostream &  s = std::cout,
Size  depth = 0 
) const
String BALL::String::encodeBase64 (  ) 

Convert a string to a base 64 string.

Substring BALL::String::from ( const String s,
Index  from = 0 
) const

Return a substring containing the string from the first occurence of s on

void BALL::String::get ( char *  char_ptr,
Index  from = 0,
Size  len = EndPos 
) const throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)

Assign to a C type string.

static CompareMode BALL::String::getCompareMode (  )  [static]

Return the current comparison mode.

String BALL::String::getField ( Index  index,
const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
Index from = 0 
) const throw (Exception::IndexUnderflow, Exception::NullPointer)

Return a given field as a substring.

String BALL::String::getFieldQuoted ( Index  index,
const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
const char *  quotes = CHARACTER_CLASS__QUOTES,
Index from = 0 
) const throw (Exception::IndexUnderflow, Exception::NullPointer)

Return a given field and respect quote characters.

std::istream& BALL::String::getline ( std::istream &  s = std::cin,
char  delimiter = '\n' 
)
Substring BALL::String::getSubstring ( Index  from = 0,
Size  len = EndPos 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Return a substring.

bool BALL::String::has ( char  c  )  const

True, if the string contains character c

bool BALL::String::hasPrefix ( const String s  )  const

True, if the string starts with s

bool BALL::String::hasSubstring ( const String s,
Index  from = 0 
) const

True, if the string contains the substring s after index from

bool BALL::String::hasSuffix ( const String s  )  const

True, if the string ends with s

Substring BALL::String::instr ( const String pattern,
Index  from = 0 
) const

Return a substring containing the first occurence of pattern in the string. If the pattern is not contained in the string, an empty Substring is returned. The search for the pattern may also start from an index different from zero, allowing incremental search.

Returns:
Substring containing the search pattern, empty if not found
Parameters:
pattern the search pattern
from the index in the string to start the search from
static bool BALL::String::isAlnum ( char  c  )  [static]

True, if the character is a letter or a digit.

bool BALL::String::isAlnum (  )  const

True, if the string only contains letters and digits. It returns also true, if called for an empty string.

static bool BALL::String::isAlpha ( char  c  )  [static]

True, if the character is a letter (any case).

bool BALL::String::isAlpha (  )  const

True, if the string only contains letters (any case). It returns also true, if called for an empty string.

static bool BALL::String::isDigit ( char  c  )  [static]

True, if the character is a digit.

bool BALL::String::isDigit (  )  const

True, if the string only contains digits. It returns also true, if called for an empty string.

bool BALL::String::isEmpty (  )  const

True, if the string has size 0.

bool BALL::String::isFloat (  )  const

True, if the string is a floating number. (It contains only numbers and maybe a dot). It returns also true, if called for an empty string.

static bool BALL::String::isSpace ( char  c  )  [static]

True, if the character is a space.

bool BALL::String::isSpace (  )  const

True, if the string only contains spaces. It returns also true, if called for an empty string.

bool BALL::String::isValid (  )  const
static bool BALL::String::isWhitespace ( char  c  )  [static]

True, if the character is any whitespace character. Whitespaces are defined in CHARACTER_CLASS__WHITESPACE

bool BALL::String::isWhitespace (  )  const

True, if the string only contains whitespace characters. Whitespaces are defined in CHARACTER_CLASS__WHITESPACE. It returns also true, if called for an empty string.

Substring BALL::String::left ( Size  len  )  const

Return a substring containing the len leftmost characters of the string.

bool BALL::String::operator!= ( char  c  )  const
bool BALL::String::operator!= ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator!= ( const String string  )  const
Substring BALL::String::operator() ( Index  from,
Size  len = EndPos 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Return a substring.

bool BALL::String::operator< ( char  c  )  const
bool BALL::String::operator< ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator< ( const String string  )  const
bool BALL::String::operator<= ( char  c  )  const
bool BALL::String::operator<= ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator<= ( const String string  )  const
const String& BALL::String::operator= ( double  d  ) 

Assign a String from a double.

const String& BALL::String::operator= ( float  f  ) 

Assign a String from a float.

const String& BALL::String::operator= ( unsigned long  ul  ) 

Assign a String from an unsigned long.

const String& BALL::String::operator= ( long  l  ) 

Assign a String from a long.

const String& BALL::String::operator= ( unsigned int  ui  ) 

Assign a String from an unsigned int.

const String& BALL::String::operator= ( int  i  ) 

Assign a String from an int.

const String& BALL::String::operator= ( unsigned short  us  ) 

Assign a String from an unsigned short.

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

Assign a String from a short.

const String& BALL::String::operator= ( unsigned char  uc  ) 

Assign a String from an unsigned char.

const String& BALL::String::operator= ( char  c  ) 

Assign a String from a single char.

const String& BALL::String::operator= ( std::strstream &  s  ) 

Assign a string from a stringstream. The contents of the stringstream object are not modified.

const String& BALL::String::operator= ( const char *  pc  )  throw (Exception::NullPointer)

Assign a String from a C type string.

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

Assign a String from another String.

bool BALL::String::operator== ( char  c  )  const
bool BALL::String::operator== ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator== ( const String string  )  const
bool BALL::String::operator> ( char  c  )  const
bool BALL::String::operator> ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator> ( const String string  )  const
bool BALL::String::operator>= ( char  c  )  const
bool BALL::String::operator>= ( const char *  char_ptr  )  const throw (Exception::NullPointer)
bool BALL::String::operator>= ( const String string  )  const
String& BALL::String::reverse ( Index  from = 0,
Size  len = EndPos 
) throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Reverses the string. If called without arguments, this method simply reverses the character sequence of the string. By giving arguments for the indices, only a subsequence of the string may be reversed.

Parameters:
from first index of the sequence to be reversed
to last index of the sequence to be reversed
See also:
String:Indices
Substring BALL::String::right ( Size  len  )  const

Return a substring containing the len rightmost characters of the string.

void BALL::String::set ( double  d  ) 

Assign a String from a double value.

void BALL::String::set ( float  f  ) 

Assign a String from a float value.

void BALL::String::set ( unsigned long  ul  ) 

Assign a String from an unsigned long.

void BALL::String::set ( long  l  ) 

Assign a String from a long.

void BALL::String::set ( unsigned int  ui  ) 

Assign a String from an unsigned int.

void BALL::String::set ( int  i  ) 

Assign a String from an int.

void BALL::String::set ( unsigned short  us  ) 

Assign a String from an unsigned short.

void BALL::String::set ( short  s  ) 

Assign a String from a short.

void BALL::String::set ( unsigned char  uc  ) 

Assign a String from an unsigned char.

void BALL::String::set ( char  c,
Size  len = 1 
)

Assign a String from the result of repeating c len times.

void BALL::String::set ( std::strstream &  s  ) 

Assign a String from a stringstream. The contents of the stringstream object are not modified.

void BALL::String::set ( Size  buffer_size,
const char *  format,
  ... 
) throw (Exception::IndexUnderflow, Exception::NullPointer)

Assign a string to the result of a sprintf call

Exceptions:
Exception::IndexUnderflow,if the buffer size is zero
Exception::NullPointer,<tt>format</tt> is a NULL pointer
void BALL::String::set ( const char *  char_ptr,
Index  from = 0,
Size  len = EndPos 
) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow)

Assign a String from a C type string

Exceptions:
Exception::IndexUnderflow if from < 0
Exception::IndexOverflow if from >= size()
void BALL::String::set ( const String string,
Index  from,
Size  len = EndPos 
) throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Assign a String from a range of another string

Exceptions:
Exception::IndexOverflow if from < 0
Exception::IndexUnderflow if from >= size()
void BALL::String::set ( const String s  ) 

Assign a string

static void BALL::String::setCompareMode ( CompareMode  compare_mode  )  [static]

Set the compareison mode for all string comparisons.

Size BALL::String::split ( std::vector< String > &  strings,
const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
Index  from = 0 
) const throw (Exception::IndexUnderflow, Exception::NullPointer)

Split the string into fields and assign these field to a vector of strings. The vector of strings is cleared in any case. Its final size is returned.

Exceptions:
IndexOverflow if from < 0
NullPointer if delimiters == 0
Size BALL::String::split ( String  string_array[],
Size  array_size,
const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
Index  from = 0 
) const throw (Exception::IndexUnderflow, Exception::NullPointer)

Split the string into fields and assign these field to an array of strings

Size BALL::String::splitQuoted ( std::vector< String > &  strings,
const char *  delimiters = CHARACTER_CLASS__WHITESPACE,
const char *  quotes = CHARACTER_CLASS__QUOTES,
Index  from = 0 
) const throw (Exception::IndexUnderflow, Exception::NullPointer)

Split the string into fields and respect quote characters. Similar to split , but delimiters that are inside quote characters (default is CHARACTER_CLASS__QUOTES ) are not considered to split the string. The vector of strings is cleared in any case. Its final size is returned.

Exceptions:
IndexOverflow if from < 0
NullPointer if delimiters == 0
Size BALL::String::substitute ( const String to_replace,
const String replacing 
)

Substitute the first occurence of to_replace by the content of replacing.

Returns:
the first position of the substitution or EndPos if to_replace is not found
void BALL::String::swap ( String s  ) 

Swaps the contents with another String.

Substring BALL::String::through ( const String s,
Index  from = 0 
) const

Return a substring containing the beginning of the string including the first occurence of s

bool BALL::String::toBool (  )  const

Converts the string to a bool value. This method returns false, if the string contains the string false (may be surrounded by whitespaces), or true otherwise.

char BALL::String::toChar (  )  const

Return the first character of the string.

double BALL::String::toDouble (  )  const throw (Exception::InvalidFormat)

Convert the string to a double.

float BALL::String::toFloat (  )  const throw (Exception::InvalidFormat)

Convert the string to a float.

int BALL::String::toInt (  )  const throw (Exception::InvalidFormat)

Convert the string to an int.

long BALL::String::toLong (  )  const throw (Exception::InvalidFormat)

Convert the string to a long.

void BALL::String::toLower ( Index  from = 0,
Size  len = EndPos 
) throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Convert all characters in the given range to lower case.

short BALL::String::toShort (  )  const throw (Exception::InvalidFormat)

Convert the string to a short.

unsigned char BALL::String::toUnsignedChar (  )  const

Return the first character of the string converted to an unsigned char.

unsigned int BALL::String::toUnsignedInt (  )  const throw (Exception::InvalidFormat)

Convert the string to an unsigned int.

unsigned long BALL::String::toUnsignedLong (  )  const throw (Exception::InvalidFormat)

Convert the string to an unsigned long.

unsigned short BALL::String::toUnsignedShort (  )  const throw (Exception::InvalidFormat)

Convert the string to an unsigned short.

void BALL::String::toUpper ( Index  from = 0,
Size  len = EndPos 
) throw (Exception::IndexUnderflow, Exception::IndexOverflow)

Convert all characters in the given range to upper case.

String BALL::String::trim ( const char *  trimmed = CHARACTER_CLASS__WHITESPACE  )  const

Strips all characters in trimmed from both sides of the string. trim calls trimRight(trimmed).trimLeft(trimmed).

String& BALL::String::trim ( const char *  trimmed = CHARACTER_CLASS__WHITESPACE  ) 

Strips all characters in trimmed from both sides of the string. trim calls trimRight(trimmed).trimLeft(trimmed).

String& BALL::String::trimLeft ( const char *  trimmed = CHARACTER_CLASS__WHITESPACE  ) 

Strips all characters in trimmed from the left of the string. trimLeft stops at the first character encountered that is not in trimmed. Using its default parameter CHARACTER_CLASS__WHITESPACE, it is usually handy to remove blanks from the beginning of a string. Strings consisting of character from trimmed only yield an empty string.

String& BALL::String::trimRight ( const char *  trimmed = CHARACTER_CLASS__WHITESPACE  ) 

Strips all characters in trimmed from the right of the string. trimRight stops at the first character encountered that is not in trimmed. Using its default parameter CHARACTER_CLASS__WHITESPACE, it is usually handy to remove blanks from the end of a string. Strings consisting of character from trimmed only yield an empty string.

String& BALL::String::truncate ( Size  size  ) 

Truncate the string to length size

static void BALL::String::validateCharPtrRange_ ( Index from,
Size len,
const char *  char_ptr 
) throw (Exception::NullPointer, Exception::IndexUnderflow, Exception::IndexOverflow) [static, protected]
void BALL::String::validateIndex_ ( Index index  )  const throw (Exception::IndexUnderflow, Exception::IndexOverflow) [protected]
void BALL::String::validateRange_ ( Index from,
Size len 
) const throw (Exception::IndexUnderflow, Exception::IndexOverflow) [protected]
static void BALL::String::valudateCharPtrIndex_ ( Index index  )  [static, protected]

Friends And Related Function Documentation

BALL_EXPORT friend std::istream& getline ( std::istream &  s,
String string,
char  delimiter = '\n' 
) [friend]
BALL_EXPORT friend bool operator!= ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator!= ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
BALL_EXPORT friend String operator+ ( char  c,
const String s 
) [friend]

Concatenates a character and a string.

BALL_EXPORT friend String operator+ ( const String s,
char  c 
) [friend]

Concatenates a string and a character.

BALL_EXPORT friend String operator+ ( const char *  char_ptr,
const String s 
) [friend]

Concatenates a C type string and a string.

BALL_EXPORT friend String operator+ ( const String s1,
const char *  char_ptr 
) [friend]

Concatenates a string and a C type string.

BALL_EXPORT friend String operator+ ( const String s1,
const String s2 
) [friend]

Concatenates two strings.

BALL_EXPORT friend String operator+ ( const string &  s1,
const String s2 
) [friend]

Concatenates two strings.

BALL_EXPORT friend String operator+ ( const String s1,
const string &  s2 
) [friend]

Concatenates two strings.

BALL_EXPORT friend bool operator< ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator< ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
BALL_EXPORT friend bool operator<= ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator<= ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
BALL_EXPORT friend bool operator== ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator== ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
BALL_EXPORT friend bool operator> ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator> ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
bool operator>= ( char  c,
const String string 
) [friend]
BALL_EXPORT friend bool operator>= ( const char *  char_ptr,
const String string 
) throw (Exception::NullPointer) [friend]
friend class Substring [friend]

Definition at line 67 of file string.h.


Member Data Documentation

char BALL::String::B64Chars_[64] [static, private]

Definition at line 947 of file string.h.

Character class containing all letters (lower and upper case).

Definition at line 113 of file string.h.

Character class containing all letters and digits.

Definition at line 116 of file string.h.

Character class containing the digits from 0 to 9 and a dot.

Definition at line 128 of file string.h.

Character class containing all lower case letters.

Definition at line 119 of file string.h.

Character class containing the digits from 0 to 9.

Definition at line 125 of file string.h.

Character class containing all upper case letters.

Definition at line 122 of file string.h.

Character class containing double quotes.

Definition at line 145 of file string.h.

Character class containing all whitespace characters. Whitespace characters are:

  • blank " "
  • horizontal tab $ "\backslash t" $
  • new-line $ "\backslash n" $
  • line-feed $ "\backslash r" $
  • vertical tab $ "\backslash v" $
  • form-feed $ "\backslash f" $

Definition at line 141 of file string.h.

Definition at line 945 of file string.h.

const String BALL::String::EMPTY [static]

Constant empty string.

Definition at line 918 of file string.h.

const Size BALL::String::EndPos [static]

Constant indicating the end of the string. Use this constant instead of string::npos to indicate an invalid position inside the string or the end of the string in those methods requiring indices.

Definition at line 102 of file string.h.

int BALL::String::Index_64_[128] [static, private]

Definition at line 949 of file string.h.

Generated by  doxygen 1.6.3