TOP --> libjdl

class CJdlString

Defines a simple string class.

This string class is used as the key for other classes in this library.

To tokenize strings use the jdlstringlist class.

     #include "jdlstring.h"

main(int argc,char* argv[]) { CJdlString str = "FOO"; str.lc(); // convert to lower case str.uc(); // convert to upper case str += " BAR"; // append more info. str.Format("This is my %d-th string.",10); // format it uint length = str.Length(); char ch = str[3]; // Get the 4-th character (0 based). CJdlString dnum(123.45); // Create a string from a double. if ( dnum == str ) { cout << "something strange is going on here..." << endl; } dnum = str; // Now they are equal. return 0; }

Author:
Joe Linoff

Version:
$Id: jdlstring.h,v 1.4 1999/06/12 18:26:00 jdl Exp $

Source:
../../libjdl/src/jdlstring.h:56

See Also:
CJdlStringList, CJdlStringListSorter

Constructors Index

CJdlString
[public] Default constructor.
CJdlString
[public] Copy constructor.
CJdlString
[public] Constructor that initializes from a "C" string.
CJdlString
[public] Constructor that initializes from a single character.
CJdlString
[public] Constructor that initializes from a decimal integer.
CJdlString
[public] Constructor that initializes from a floating point number.
~CJdlString
[public] Destructor.


Methods Index

Append
[public] Append another string onto this one.
Append
[public] Append another C style string onto this one.
Append
[public] Append a character.
Compare
[public] Compare two strings.
Compare
[public] Compare two strings.
Copy
[public] Copy a string object.
Copy
[public] Copy a "C" string.
Copy
[public] Copy a single character.
Copy
[public] Copy an int.
Copy
[public] Copy a double.
Format
[public] Format the string using the same rules that are available for sprintf.
lc
[public] Convert to lower case.
Length
[public] Returns the length of the string.
operator !=
[public] Logical "not equals" comparison operator.
operator !=
[public] Logical "not equals" comparison operator
operator +=
[public] Append operator.
operator +=
[public] Append operator for C style strings.
operator +=
[public] Append operator for single characters.
operator <
[public] Logical "less than" comparison operator.
operator <
[public] Logical "less than" comparison operator.
operator <=
[public] Logical "less than or equal to" comparison operator.
operator <=
[public] Logical "less than or equal to" comparison operator.
operator =
[public] Assignment operator.
operator =
[public] Assignment operator.
operator ==
[public] Logical "equals" comparison operator.
operator ==
[public] Logical "equals" comparison operator
operator >
[public] Logical "greater than" comparison operator.
operator >
[public] Logical "greater than" comparison operator.
operator >=
[public] Logical "greater than or equal to" comparison operator.
operator >=
[public] Logical "greater than or equal to" comparison operator.
operator []
[public] Return the character at the i-th position. This method does not do any bounds checking because it is safe. This allows programmers to do cool things without harming anything.
operator []
[public] Return the character at the i-th position. This method does not do any bounds checking because it is safe. This allows programmers to do cool things without harming anything.
operator constchar*
[public] Cast operator.
Resize
[public] Resize the internal buffer.
str
[public] Cast method.
uc
[public] Convert to upper case.


Constructors

CJdlString

public CJdlString ( ) ;

Default constructor.

CJdlString

public CJdlString ( const CJdlString & obj ) ;

Copy constructor.

Parameters:
obj Another CJdlString object.

CJdlString

public CJdlString ( const char * obj ) ;

Constructor that initializes from a "C" string.

Parameters:
obj A NULL terminated "C" string.

CJdlString

public CJdlString ( char val ) ;

Constructor that initializes from a single character.

Parameters:
obj A single character.

CJdlString

public CJdlString ( int val ) ;

Constructor that initializes from a decimal integer.

Parameters:
val An integer.

CJdlString

public CJdlString ( double val ) ;

Constructor that initializes from a floating point number.

Parameters:
val A floating point number.

CJdlString

public ~ CJdlString ( ) ;

Destructor.


Methods

Resize

public void Resize ( uint size ,
                     bool copyFlag = true ) ;

Resize the internal buffer.

Parameters:
size The new maximum length.
copyFlag If true, copy the old contents, otherwise init the string.

Copy

public void Copy ( const CJdlString & obj ) ;

Copy a string object.

Parameters:
obj Another string object.

Copy

public void Copy ( const char * obj ) ;

Copy a "C" string.

Parameters:
obj A NULL terminated "C" string.

Copy

public void Copy ( char obj ) ;

Copy a single character.

Parameters:
obj A single character.

Copy

public void Copy ( int obj ) ;

Copy an int.

Parameters:
obj An integer.

Copy

public void Copy ( double ) ;

Copy a double.

Parameters:
obj A double.

Format

public void Format ( const char * ,
                     . . . ) ;

Format the string using the same rules that are available for sprintf.

Parameters:
fmt The formatting strings.
... The optional paramters.

Length

public uint Length ( ) const ;

Returns the length of the string.

Return:
The length of the string.

Compare

public int Compare ( const CJdlString & obj ) const ;

Compare two strings.

Parameters:
obj Another string object.

Return:
0 if this == obj, <0 if this < obj, >0 if this > obj

Compare

public int Compare ( const char * ) const ;

Compare two strings.

Parameters:
obj A C style string.

Return:
0 if this == obj, <0 if this < obj, >0 if this > obj

operator =

public CJdlString & operator = ( const CJdlString & obj ) ;

Assignment operator.

Parameters:
obj Another string object.

operator =

public CJdlString & operator = ( const char * obj ) ;

Assignment operator.

Parameters:
obj A C style string object.

operator ==

public uint operator == ( const CJdlString & ) const ;

Logical "equals" comparison operator.

     CJdlString a("XXXX");
     CJdlString b(a);
     if( a == b ) cout << "EQUAL" << endl;
 

Parameters:
obj Another string object.

Return:
1 If these two strings are equal or 0 otherwise.

operator ==

public uint operator == ( const char * ) const ;

Logical "equals" comparison operator

Parameters:
obj Another string object.

Return:
1 If these two strings are equal or 0 otherwise.

operator !=

public uint operator != ( const CJdlString & ) const ;

Logical "not equals" comparison operator.

     CJdlString a("XXXX");
     CJdlString b(a);
     if( a != b ) cout << "EQUAL" << endl;
 

Parameters:
obj Another string object.

Return:
1 If these two strings are not equal or 0 otherwise.

operator !=

public uint operator != ( const char * ) const ;

Logical "not equals" comparison operator

Parameters:
obj Another string object.

Return:
1 If these two strings are not equal or 0 otherwise.

operator <=

public uint operator <= ( const CJdlString & ) const ;

Logical "less than or equal to" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is less than or equal obj.

operator <=

public uint operator <= ( const char * ) const ;

Logical "less than or equal to" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is less than or equal obj.

operator >=

public uint operator >= ( const CJdlString & ) const ;

Logical "greater than or equal to" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is greater than or equal obj.

operator >=

public uint operator >= ( const char * ) const ;

Logical "greater than or equal to" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is greater than or equal obj.

operator <

public uint operator < ( const CJdlString & ) const ;

Logical "less than" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is less than obj.

operator <

public uint operator < ( const char * ) const ;

Logical "less than" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is less than obj.

operator >

public uint operator > ( const CJdlString & ) const ;

Logical "greater than" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is greater than obj.

operator >

public uint operator > ( const char * ) const ;

Logical "greater than" comparison operator.

Parameters:
obj Another string object.

Return:
1 If this string is greater than obj.

operator constchar*

public operator const char * ( ) const ;

Cast operator.

Return:
A const char* pointer to a C style string.

str

public const char * str ( ) const ;

Cast method.

Return:
A const char* pointer to a C style string.

Append

public void Append ( const CJdlString & obj ) ;

Append another string onto this one.

Append

public void Append ( const char * obj ) ;

Append another C style string onto this one.

Append

public void Append ( char ch ) ;

Append a character.

operator +=

public CJdlString & operator += ( const CJdlString & obj ) ;

Append operator.

operator +=

public CJdlString & operator += ( const char * obj ) ;

Append operator for C style strings.

operator +=

public CJdlString & operator += ( char ch ) ;

Append operator for single characters.

uc

public void uc ( ) ;

Convert to upper case.

lc

public void lc ( ) ;

Convert to lower case.

operator []

public char operator [ ] ( int idx ) const ;

Return the character at the i-th position. This method does not do any bounds checking because it is safe. This allows programmers to do cool things without harming anything.

Parameters:
index Character index (it can be negative).

Return:
The character at the i-th position.

operator []

public char operator [ ] ( uint idx ) const ;

Return the character at the i-th position. This method does not do any bounds checking because it is safe. This allows programmers to do cool things without harming anything.

Parameters:
index Character index (it must be positive).

Return:
The character at the i-th position.

This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.

Click here to return to the top of the page.