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

String Class Reference

Strings are represented as possibly shared segment lists. More...

#include <MString.h>

List of all members.

Public Methods

 String ()
 Construct an empty string.

 String (const char *text)
 Construct a string from text.

 String (const char *text,int len)
 Construct a string from the first len characters of text.

 String (int size,int expand)
 Construct an empty string with a buffer of given size. More...

 String (const String &x,const String &y)
 Construct a concatenation of the two strings.

 String (const String &x, char ch)
 Construct a concatenation of the string and a character.

 String (const String &x)
 Copy constructor (very fast - no text copying required).

 String (int i)
 Construct a string as base 10 representation of an int.

 String (size_t i)
 Construct a string as base 10 representation of an int.

 String (bool b)
 Construct a string from a bool (true or false).

 String (long l)
 Construct a string as base 10 representation of a long.

 String (double d)
 Construct a string as base 10 representation of double.

 String (const LString &x)
 Construct a String from an LString.

String& operator= (const String &x)
 Assignment and concatenate and assign operators.

String& operator= (const char *x)
String& operator+= (const String &x)
String& operator+= (const char *x)
String& operator+= (char x)
String& operator+= (const LString &x)
char& operator[] (int i)
 Index into string. More...

void append (const String &x)
 append a String or char *. More...

void append (const char *x)
void push (char x)
 Push a character onto a string. More...

String operator+ (const String &x) const
 Add a String or a single char.

String operator+ (const char *x) const
String operator+ (const LString &x) const
String operator+ (char x) const
void set_value (const char *text,int len)
 set the value of a string to the left most len characters of a char *. More...

 ~String ()
int compare (const String &x) const
 compare a string. More...

bool operator== (const String &x) const
 The usual comparison operators.

bool operator!= (const String &x) const
bool operator< (const String &x) const
bool operator<= (const String &x) const
bool operator> (const String &x) const
bool operator>= (const String &x) const
 operator const char * () const
 Access the string as a const char *. More...

const char* c_str () const
bool truncate_to_last (char marker)
 Truncate the string the the last instance of the character the matching character is removed. More...

bool trim_to_first (char marker)
 Trim the prefix finishing with the first instance of the characeter The character is trimmed.

bool truncate_at_pos (int pos)
 Truncate to a given position The new length will be equal to the parameter value.

bool is_empty () const
int size () const
int length () const
String Left (int len) const
 Basic like string functions Left(len) - get String of left "len" chars Right(len) - get String of right "len" characters Mid(left_pos,len) - extract middle part of string Repeat(int times) - return this string repeated times times NOTE: for Left and Right, the length can be negative, in which case, the length of the string is added to the parameter - in other words, it is the number of characters to chop off.

String Right (int len) const
String Mid (int left_pos,int len) const
String substr (int left_pos,int len) const
String Repeat (int times)
bool ends_in (const String &s) const
 Does the string end in or start with the comparison string?

bool starts_with (const String &s) const
int find (const String &x) const
 Find a substring. More...

void make_empty ()
 Clear a string.


Detailed Description

Strings are represented as possibly shared segment lists.


Constructor & Destructor Documentation

String::String ()

Construct an empty string.

String::String ( const char * text)

Construct a string from text.

String::String ( const char * text,
int len)

Construct a string from the first len characters of text.

String::String ( int size,
int expand)

Construct an empty string with a buffer of given size.

Parameters:
-   size in bytes (rounded up to modulo 8)
-   ignored. Must be present or what you will get is a string containing size as text

String::String ( const String & x,
const String & y)

Construct a concatenation of the two strings.

String::String ( const String & x,
char ch)

Construct a concatenation of the string and a character.

String::String ( const String & x)

Copy constructor (very fast - no text copying required).

String::String ( int i)

Construct a string as base 10 representation of an int.

String::String ( size_t i)

Construct a string as base 10 representation of an int.

String::String ( bool b)

Construct a string from a bool (true or false).

String::String ( long l)

Construct a string as base 10 representation of a long.

String::String ( double d)

Construct a string as base 10 representation of double.

String::String ( const LString & x)

Construct a String from an LString.

String::~String ()


Member Function Documentation

String String::Left ( int len) const

Basic like string functions Left(len) - get String of left "len" chars Right(len) - get String of right "len" characters Mid(left_pos,len) - extract middle part of string Repeat(int times) - return this string repeated times times NOTE: for Left and Right, the length can be negative, in which case, the length of the string is added to the parameter - in other words, it is the number of characters to chop off.

String String::Mid ( int left_pos,
int t_len) const

String String::Repeat ( int times)

String String::Right ( int t_len) const

void String::append ( const char * x)

void String::append ( const String & x)

append a String or char *.

Equivalent to +=

const char * String::c_str () const

int String::compare ( const String & x) const

compare a string.

Parameters:
-   string to compare
Returns:
- -ve if "this" < param string, 0 if equal, +ve if greater Very strcmp like.

bool String::ends_in ( const String & s) const

Does the string end in or start with the comparison string?

int String::find ( const String & x) const

Find a substring.

Returns index of first character of substring, or -1 if not found

bool String::is_empty () const [inline]

int String::length () const [inline]

void String::make_empty ()

Clear a string.

String::operator const char * () const

Access the string as a const char *.

Two forms, as a cast and as a function

bool String::operator!= ( const String & x) const

String String::operator+ ( char x) const

String String::operator+ ( const LString & x) const

String String::operator+ ( const char * x) const

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

Add a String or a single char.

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

String & String::operator+= ( char x)

String & String::operator+= ( const char * x)

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

bool String::operator< ( const String & x) const

bool String::operator<= ( const String & x) const

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

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

Assignment and concatenate and assign operators.

bool String::operator== ( const String & x) const

The usual comparison operators.

bool String::operator> ( const String & x) const

bool String::operator>= ( const String & x) const

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

Index into string.

Warning:
does no bounds checking

void String::push ( char x)

Push a character onto a string.

Present for hystorical reasons. Use += operator by preference

void String::set_value ( const char * text,
int len)

set the value of a string to the left most len characters of a char *.

Parameters:
-   text to set
-   no of characters to take

int String::size () const [inline]

bool String::starts_with ( const String & s) const

String String::substr ( int left_pos,
int t_len) const

bool String::trim_to_first ( char marker)

Trim the prefix finishing with the first instance of the characeter The character is trimmed.

bool String::truncate_at_pos ( int pos)

Truncate to a given position The new length will be equal to the parameter value.

bool String::truncate_to_last ( char marker)

Truncate the string the the last instance of the character the matching character is removed.

Hence, fullpathname.truncate_to_last('/') will give you the directory name.


The documentation for this class was generated from the following files:
Generated at Mon Jul 31 13:44:35 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000