Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends

alize::String Class Reference

#include <alizeString.h>

Inheritance diagram for alize::String:
Inheritance graph
[legend]
Collaboration diagram for alize::String:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 String (const char *="")
 String (const String &)
Stringduplicate () const
const Stringoperator= (const String &)
const Stringoperator= (const char *)
Stringoperator+= (const String &)
Stringoperator+= (const char *)
bool operator== (const String &) const
bool operator!= (const String &) const
bool operator== (const char *) const
bool operator!= (const char *) const
bool operator< (const String &) const
bool operator<= (const String &) const
bool operator> (const String &) const
bool operator>= (const String &) const
String operator+ (const String &) const
String operator+ (const char *) const
String operator[] (unsigned long index) const
virtual ~String ()
double toDouble () const
bool toBool () const
long toLong () const
unsigned long toULong () const
unsigned long length () const
void reset ()
bool isEmpty () const
bool endsWith (const String &) const
bool beginsWith (const String &) const
String getToken (unsigned long index, const String &sep=" ") const
long find (const String &s, unsigned long start=0) const
const char * c_str () const
virtual String getClassName () const
virtual String toString () const

Static Public Member Functions

static String valueOf (unsigned long v)
static String valueOf (long v)
static String valueOf (unsigned int v)
static String valueOf (int v)
static String valueOf (double v)
static String valueOf (bool v)

Private Member Functions

void create (unsigned long length, unsigned long capacity, const char *)

Private Attributes

char * _string
 Internal c-style string (an array of char ended by a 0).
unsigned long _capacity
unsigned long _length

Friends

class TestString

Detailed Description

The String class represents character strings.

Author:
Frederic Wils frederic.wils@lia.univ-avignon.fr
Version:
1.0
Date:
2003

Definition at line 79 of file alizeString.h.


Constructor & Destructor Documentation

S::String ( const char *  c = "" )

Definition at line 74 of file alizeString.cpp.

References create(), and length().

S::String ( const String s )

Definition at line 81 of file alizeString.cpp.

References _length, _string, and create().

S::~String (  ) [virtual]

Definition at line 434 of file alizeString.cpp.

References NULL.


Member Function Documentation

bool S::beginsWith ( const String s ) const

Tests whether this string begins with the specified prefix

Returns:
true if the character sequence represented by the argument is a prefix of the character sequence represented by this object; return false otherwise. Note that the result will be true if the argument is the empty string.

Definition at line 323 of file alizeString.cpp.

References _length, and _string.

Referenced by alize::AudioFileReader::getExt(), alize::FeatureFileWriter::getFullFileName(), alize::AudioFileReader::getPath(), and alize::AudioFileReader::readParams().

const char * String::c_str (  ) const
void S::create ( unsigned long  length,
unsigned long  capacity,
const char *  c 
) [private]

Definition at line 424 of file alizeString.cpp.

Referenced by String().

S & S::duplicate (  ) const
bool S::endsWith ( const String s ) const

Tests whether this string ends with the specified suffix

Returns:
true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; return false otherwise. Note that the result will be true if the argument is the empty string.

Definition at line 312 of file alizeString.cpp.

References _length, and _string.

Referenced by alize::ConfigFileReaderXml::eventClosingElement(), alize::ConfigFileReaderXml::eventOpeningElement(), alize::SegServer::load(), alize::Config::load(), and alize::ConfigFileWriter::writeConfig().

long S::find ( const String s,
unsigned long  start = 0 
) const

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

Parameters:
sthe substring to find
startthe position from which to start the search.
Returns:
the position of the first occurence of the substring. If not found, return -1;

Definition at line 334 of file alizeString.cpp.

References _length, and _string.

String S::getClassName (  ) const [virtual]

Returns the name of the class

Returns:
the name of the class of the object as a String

Implements alize::Object.

Definition at line 417 of file alizeString.cpp.

S S::getToken ( unsigned long  index,
const String sep = " " 
) const

Finds the token number 'index' in this string
Example : string = " aaa bbb ccc "
getToken(0) will return "aaa"
getToken(1) will return "bbb"
getToken(2) will return "ccc"
getToken(3 and more) will return ""

Parameters:
indexindex of the token to return
sepSeparator. A single character. Default is " ".
Returns:
a string with the token if it exists; return an empty string otherwise

Definition at line 353 of file alizeString.cpp.

References c_str(), and length().

Referenced by alize::ConfigChecker::check(), alize::ConfigChecker::checkName(), alize::ConfigFileReaderXml::eventClosingElement(), alize::ConfigFileReaderRaw::readConfig(), alize::XListFileReader::readList(), alize::AudioFileReader::readParams(), and alize::Config::setParam().

bool S::isEmpty (  ) const

Tests whether this string is equal to ""

Returns:
true or false

Definition at line 310 of file alizeString.cpp.

Referenced by alize::FileWriter::open(), alize::ConfigFileReaderRaw::readConfig(), and alize::Config::setParam().

unsigned long String::length (  ) const

Returns the length of this string

Returns:
the number of characters of the string

Definition at line 297 of file alizeString.cpp.

References _length.

Referenced by alize::ConfigChecker::getParamList(), getToken(), alize::XListFileReader::readList(), alize::Config::setParam(), and String().

bool S::operator!= ( const char *  s ) const

Definition at line 272 of file alizeString.cpp.

bool S::operator!= ( const String s ) const

Definition at line 262 of file alizeString.cpp.

References _string.

S S::operator+ ( const String s ) const

Definition at line 243 of file alizeString.cpp.

S S::operator+ ( const char *  s ) const

Definition at line 250 of file alizeString.cpp.

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

Definition at line 215 of file alizeString.cpp.

References _length, and _string.

S & S::operator+= ( const char *  s )

Definition at line 229 of file alizeString.cpp.

bool S::operator< ( const String s ) const

Definition at line 277 of file alizeString.cpp.

References _string.

bool S::operator<= ( const String s ) const

Definition at line 282 of file alizeString.cpp.

References _string.

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

Definition at line 176 of file alizeString.cpp.

References _length, and _string.

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

Definition at line 195 of file alizeString.cpp.

bool S::operator== ( const char *  s ) const

Definition at line 267 of file alizeString.cpp.

bool S::operator== ( const String s ) const

Definition at line 257 of file alizeString.cpp.

References _string.

bool S::operator> ( const String s ) const

Definition at line 287 of file alizeString.cpp.

References _string.

bool S::operator>= ( const String s ) const

Definition at line 292 of file alizeString.cpp.

References _string.

S S::operator[] ( unsigned long  index ) const

Definition at line 299 of file alizeString.cpp.

void S::reset (  )

The string becomes empty

Definition at line 308 of file alizeString.cpp.

Referenced by alize::Label::reset().

bool S::toBool (  ) const

Converts this string into a boolean value

Returns:
the value

Definition at line 143 of file alizeString.cpp.

Referenced by alize::ConfigChecker::check(), alize::Config::getBooleanParam(), and alize::Config::setParam().

double S::toDouble (  ) const

Converts this string into a double value

Returns:
the value or 0.0 if it cannot convert

Definition at line 131 of file alizeString.cpp.

Referenced by alize::ConfigChecker::check(), alize::Config::getFloatParam(), alize::Matrix< T >::loadDT(), and alize::Config::setParam().

long S::toLong (  ) const

Converts this string into a long value

Returns:
the value or 0 if it cannot convert

Definition at line 154 of file alizeString.cpp.

Referenced by alize::ConfigChecker::check(), alize::Config::getIntegerParam(), alize::Matrix< T >::loadDT(), and alize::AudioFileReader::readParams().

String S::toString (  ) const [virtual]

This method is frequently overridden in the derived classes. If it is not, it returns the name of the class of the object and the address of the object

Returns:
a description of the object

Reimplemented from alize::Object.

Definition at line 419 of file alizeString.cpp.

References alize::Object::toString().

unsigned long S::toULong (  ) const

Converts this string into an unsigned long value

Returns:
the value or 0 if it cannot convert

Definition at line 165 of file alizeString.cpp.

Referenced by alize::Config::setParam().

S S::valueOf ( bool  v ) [static]

Definition at line 129 of file alizeString.cpp.

S S::valueOf ( double  v ) [static]

Definition at line 108 of file alizeString.cpp.

References c_str().

S S::valueOf ( unsigned int  v ) [static]

Definition at line 115 of file alizeString.cpp.

References c_str().

S S::valueOf ( long  v ) [static]

Definition at line 101 of file alizeString.cpp.

References c_str().

S S::valueOf ( int  v ) [static]

Definition at line 122 of file alizeString.cpp.

References c_str().

S S::valueOf ( unsigned long  v ) [static]

Friends And Related Function Documentation

friend class TestString [friend]

Definition at line 81 of file alizeString.h.


Member Data Documentation

unsigned long alize::String::_capacity [private]

Definition at line 204 of file alizeString.h.

unsigned long alize::String::_length [private]

Definition at line 205 of file alizeString.h.

Referenced by beginsWith(), endsWith(), find(), length(), operator+=(), operator=(), and String().

char* alize::String::_string [private]

Internal c-style string (an array of char ended by a 0).

Definition at line 203 of file alizeString.h.

Referenced by beginsWith(), c_str(), endsWith(), find(), operator!=(), operator+=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), and String().


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