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

String Class Reference

Class implementing string. More...

#include <string.h>

List of all members.

Public Methods

 String (const char *str="")
 Constructor. More...

 String (const String &s)
 Copy constructor. More...

 ~String ()
 Destructor. It unallocates memory used by a private copy of C string.

int length () const
 Length of string. More...

 operator const char * () const
 Type-cast. More...

String operator= (const char *s)
 Assignment. More...

String operator= (const String &s)
 Assignment. More...

int operator== (const char *s) const
 Equality. More...

int operator!= (const char *s) const
 Inequality. More...

String operator+= (const char *s)
 Addition assignment. More...

String operator+ (const char *s)
 Addition. More...

String cutRight ()
 White spaces removing. More...

String cutLeft ()
 White spaces removing. More...


Private Attributes

char * _str
 pointer to the beginning of C string.


Detailed Description

Class implementing string.

This class implements a C string in such a way it looks like primitive type. It is only a stupid implementation without reference counting etc.

Author:
Marek Przeczek

Definition at line 46 of file string.h.


Constructor & Destructor Documentation

String::String const char *    str = ""
 

Constructor.

This constructor allocates needed place for new C string and copies the string 'str' to the new just allocated location (makes its own private copy of the string). Constructor can be used as a default constructor when used with no agruments.

Parameters:
str  C string

Definition at line 37 of file string.cpp.

Referenced by operator+(), operator+=(), and operator=().

String::String const String &    s
 

Copy constructor.

It takes a reference to another String object and makes a copy of it.

Parameters:
s  reference to another String object

Definition at line 44 of file string.cpp.


Member Function Documentation

String String::cutLeft  
 

White spaces removing.

This method removes white spaces (regular spaces and tabulators) from the left side of the C string managed by instance of this String class. New cutted value is stored instead of the old one.

Note: modified object is returned as a return value, no temporal object. It is because of the modified object can be then easily modified (or used) by other methods without the need of explicit assignment.

Returns:
this object
See also:
cutRight()

Definition at line 100 of file string.cpp.

String String::cutRight  
 

White spaces removing.

This method removes white spaces (regular spaces and tabulators) from the right side of the C string managed by instance of this String class. New cutted value is stored instead of the old one.

Note: modified object is returned as a return value, no temporal object. It is because of the modified object can be then easily modified (or used) by other methods without the need of explicit assignment.

Returns:
this object
See also:
cutLeft()

Definition at line 81 of file string.cpp.

int String::length   const [inline]
 

Length of string.

This method returns an actual lenght of a string.

Returns:
length of string

Definition at line 76 of file string.h.

Referenced by String(), and Buffer::operator+=().

String::operator const char *   const [inline]
 

Type-cast.

This operator type-casts String object to const char*. It can be used eg. when using String object as an argument in calls to standard functions with const char* arguments.

Returns:
pointer to private copy of the string

Definition at line 85 of file string.h.

int String::operator!= const char *    s const [inline]
 

Inequality.

This operator is a negation of == operator.

Parameters:
s  pointer to a C string
Returns:
<>0 (not equal); 0 (equal)
See also:
operator==()

Definition at line 133 of file string.h.

String String::operator+ const char *    s [inline]
 

Addition.

This operator adds the right-side value to the left-side value. New value is returned only, it is not stored somewhere.

Parameters:
s  pointer to a C string
Returns:
temporal copy of String object with new value
See also:
operator+(), operator=()

Definition at line 157 of file string.h.

String String::operator+= const char *    s
 

Addition assignment.

This operator adds the right-side value to the left-side operand. New value is stored in the left-side operand.

Parameters:
s  pointer to a C string
Returns:
temporal copy of String object with new value
See also:
operator+(), operator=()

Definition at line 68 of file string.cpp.

String String::operator= const String &    s [inline]
 

Assignment.

See the help to operator=() above.

Parameters:
s  reference to another String object
Returns:
temporal copy of String object with new value
See also:
String

Definition at line 108 of file string.h.

String String::operator= const char *    s
 

Assignment.

This operator is used to assign a value to String object. There are two versions of this operator, they differ in an argument type. The first one uses const char* argument type, the second one the reference to another String object.

Parameters:
s  pointer to a C string
Returns:
temporal copy of String object with new value
See also:
String

Definition at line 55 of file string.cpp.

int String::operator== const char *    s const [inline]
 

Equality.

This operator compares String object value with a C string (on the right side of the operator). Because type-cast operator exists, it can be used to compare two String objects, too.

Parameters:
s  pointer to a C string
Returns:
<>0 (equal); 0 (not equal)
See also:
operator!=(), operator const char *() const

Definition at line 122 of file string.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:30 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001