rlString Class Reference

#include <rlstring.h>

List of all members.

Public Member Functions

 rlString (const char *text="")
 rlString (rlString &text)
 rlString (rlString *text)
virtual ~rlString ()
rlStringoperator= (const char *s2)
rlStringoperator= (rlString &s2)
rlStringoperator+ (const char *s2)
rlStringoperator+ (rlString &s2)
rlStringoperator+= (const char *s2)
rlStringoperator+= (rlString &s2)
char * text ()
int setText (const char *text)
int printf (const char *format,...)
int cat (const char *text)
int upper ()
int lower ()
int startsWith (const char *startstr)
int strnocasecmp (const char *other)
int strnnocasecmp (const char *other, int n)
char * strstr (const char *substring)
char * strchr (int c)
char * strrchr (int c)

Private Attributes

char * txt


Detailed Description

class for a simple ANSI-C like string.

Definition at line 25 of file rlstring.h.


Constructor & Destructor Documentation

rlString::rlString ( const char *  text = ""  ) 

  construct the string
  

Definition at line 21 of file rlstring.cpp.

00022 {
00023   txt = new char [strlen(text)+1];
00024   ::strcpy(txt, text);
00025 }

rlString::rlString ( rlString text  ) 

Definition at line 27 of file rlstring.cpp.

00028 {
00029   txt = new char [strlen(s2.text())+1];
00030   ::strcpy(txt,s2.text());
00031 }

rlString::rlString ( rlString text  ) 

Definition at line 33 of file rlstring.cpp.

00034 {
00035   txt = new char [strlen(s2->text())+1];
00036   ::strcpy(txt,s2->text());
00037 }

rlString::~rlString (  )  [virtual]

  destruct the string
  

Definition at line 39 of file rlstring.cpp.

00040 {
00041   delete [] txt;
00042 }


Member Function Documentation

int rlString::cat ( const char *  text  ) 

  append text
  

Definition at line 110 of file rlstring.cpp.

00111 {
00112   char *cptr = txt;
00113   int  len = strlen(txt) + strlen(text);
00114   txt = new char [len+1];
00115   ::strcpy(txt, cptr);
00116   ::strcat(txt, text);
00117   delete [] cptr;
00118   return len;
00119 }

int rlString::lower (  ) 

  converst string to upper case
  

Definition at line 132 of file rlstring.cpp.

00133 {
00134   return ::rllower(txt);
00135 }

rlString & rlString::operator+ ( rlString s2  ) 

Definition at line 62 of file rlstring.cpp.

00063 {
00064   this->cat(s2.text());
00065   return *this;
00066 }

rlString & rlString::operator+ ( const char *  s2  ) 

Definition at line 56 of file rlstring.cpp.

00057 {
00058   this->cat(s2);
00059   return *this;
00060 }

rlString & rlString::operator+= ( rlString s2  ) 

Definition at line 74 of file rlstring.cpp.

00075 {
00076   this->cat(s2.text());
00077   return *this;
00078 }

rlString & rlString::operator+= ( const char *  s2  ) 

Definition at line 68 of file rlstring.cpp.

00069 {
00070   this->cat(s2);
00071   return *this;
00072 }

rlString & rlString::operator= ( rlString s2  ) 

Definition at line 50 of file rlstring.cpp.

00051 {
00052   this->setText(s2.text());
00053   return *this;
00054 }

rlString & rlString::operator= ( const char *  s2  ) 

Definition at line 44 of file rlstring.cpp.

00045 {
00046   this->setText(s2);
00047   return *this;
00048 }

int rlString::printf ( const char *  format,
  ... 
)

  printf the text
  

Definition at line 94 of file rlstring.cpp.

00095 {
00096   int ret;
00097   char mystring[rl_PRINTF_LENGTH]; // should be big enough
00098 
00099   va_list ap;
00100   va_start(ap,format);
00101   ret = rlvsnprintf(mystring, rl_PRINTF_LENGTH - 1, format, ap);
00102   va_end(ap);
00103   if(ret < 0) return ret;
00104   delete [] txt;
00105   txt = new char [strlen(mystring)+1];
00106   ::strcpy(txt, mystring);
00107   return ret;
00108 }

int rlString::setText ( const char *  text  ) 

  set the text
  

Definition at line 85 of file rlstring.cpp.

00086 {
00087   int ret = strlen(text);
00088   delete [] txt;
00089   txt = new char [ret+1];
00090   ::strcpy(txt, text);
00091   return ret;
00092 }

int rlString::startsWith ( const char *  startstr  ) 

  test if string starts with startstr
  

Definition at line 137 of file rlstring.cpp.

00138 {
00139   return ::rlStartsWith(txt,startstr);
00140 }

char * rlString::strchr ( int  c  ) 

  strchr()
  

Definition at line 162 of file rlstring.cpp.

00163 {
00164   return ::strchr(txt,c);
00165 }

int rlString::strnnocasecmp ( const char *  other,
int  n 
)

  case insensitive string compare starting n characters
  

Definition at line 152 of file rlstring.cpp.

00153 {
00154   rlString my,o;
00155   my.setText(txt);
00156   my.lower();
00157   o.setText(other);
00158   o.lower();
00159   return ::strncmp(my.text(),o.text(),n);
00160 }

int rlString::strnocasecmp ( const char *  other  ) 

  case insensitive string compare
  

Definition at line 142 of file rlstring.cpp.

00143 {
00144   rlString my,o;
00145   my.setText(txt);
00146   my.lower();
00147   o.setText(other);
00148   o.lower();
00149   return ::strcmp(my.text(),o.text());
00150 }

char * rlString::strrchr ( int  c  ) 

  strchr()
  

Definition at line 167 of file rlstring.cpp.

00168 {
00169   return ::strrchr(txt,c);
00170 }

char * rlString::strstr ( const char *  substring  ) 

  strstr()
  

Definition at line 121 of file rlstring.cpp.

00122 {
00123   if(substring == NULL) return NULL;
00124   return ::strstr(txt,substring);
00125 }

char * rlString::text (  ) 

  get the text
  

Definition at line 80 of file rlstring.cpp.

00081 {
00082   return txt;
00083 }

int rlString::upper (  ) 

  converst string to upper case
  

Definition at line 127 of file rlstring.cpp.

00128 {
00129   return ::rlupper(txt);
00130 }


Member Data Documentation

char* rlString::txt [private]

Definition at line 110 of file rlstring.h.


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

doxygen