Logo
~Sockets~
~Examples~
~Contact~


cstring Class Reference

ANSI color stl string. More...

#include <cstring.h>

List of all members.


Public Member Functions

 cstring ()
 cstring (const std::string &)
 ~cstring ()
void operator= (const char *)
void operator+= (const char *)
void operator+= (const std::string &)
bool operator== (const std::string &)
bool operator== (class cstring &)
bool operator== (const char *)
const char * c_str ()
const char * uc_str ()

Private Attributes

char * m_cstr
char * m_ucstr

Detailed Description

ANSI color stl string.

Definition at line 30 of file cstring.h.


Constructor & Destructor Documentation

cstring::cstring (  ) 

Definition at line 31 of file cstring.cpp.

00032 :string()
00033 ,m_cstr(NULL)
00034 ,m_ucstr(NULL)
00035 {
00036 }

cstring::cstring ( const std::string &   ) 

Definition at line 39 of file cstring.cpp.

00040 :string(p)
00041 ,m_cstr(NULL)
00042 ,m_ucstr(NULL)
00043 {
00044 }

cstring::~cstring (  ) 

Definition at line 47 of file cstring.cpp.

References m_cstr, and m_ucstr.

00048 {
00049         if (m_cstr)
00050                 delete m_cstr;
00051         if (m_ucstr)
00052                 delete m_ucstr;
00053 }


Member Function Documentation

void cstring::operator= ( const char *   ) 

Definition at line 288 of file cstring.cpp.

00289 {
00290 //      return 
00291         string::operator=(p);
00292 }

void cstring::operator+= ( const char *   ) 

Definition at line 295 of file cstring.cpp.

00296 {
00297         string::operator+=(p);
00298 }

void cstring::operator+= ( const std::string &   ) 

Definition at line 301 of file cstring.cpp.

00302 {
00303         string::operator+=(p);
00304 }

bool cstring::operator== ( const std::string &   ) 

Definition at line 269 of file cstring.cpp.

References uc_str().

00270 {
00271         return !strcmp(uc_str(),str.c_str());
00272 }

bool cstring::operator== ( class cstring  ) 

Definition at line 275 of file cstring.cpp.

References uc_str().

00276 {
00277         return !strcmp(uc_str(),str.uc_str());
00278 }

bool cstring::operator== ( const char *   ) 

Definition at line 281 of file cstring.cpp.

References uc_str().

00282 {
00283         return !strcmp(uc_str(),p);
00284 }

const char * cstring::c_str (  ) 

Definition at line 56 of file cstring.cpp.

References BBLK, BBLU, BCYN, BGRN, BKBLK, BKBLU, BKCYN, BKGRN, BKMAG, BKRED, BKWHT, BKYEL, BMAG, BRED, BWHT, BYEL, CBLK, CBLU, CCYN, CGRN, CMAG, CNRM, CRED, CWHT, CYEL, FLASH, m_cstr, and UNDER.

Referenced by SmallSocket::Send().

00057 {
00058         size_t n = size();
00059         std::string tmp;
00060 
00061         for (size_t i = 0; i < n; i++)
00062         {
00063                 if ((*this)[i] == '&')
00064                 {
00065                         i++;
00066                         switch ((*this)[i])
00067                         {
00068                         case 'n':
00069                                 tmp += CNRM;
00070                                 break;
00071                         case 'r':
00072                                 tmp += CRED;
00073                                 break;
00074                         case 'g':
00075                                 tmp += CGRN;
00076                                 break;
00077                         case 'y':
00078                                 tmp += CYEL;
00079                                 break;
00080                         case 'b':
00081                                 tmp += CBLU;
00082                                 break;
00083                         case 'm':
00084                                 tmp += CMAG;
00085                                 break;
00086                         case 'c':
00087                                 tmp += CCYN;
00088                                 break;
00089                         case 'w':
00090                                 tmp += CWHT;
00091                                 break;
00092                         case 'l':
00093                                 tmp += CBLK;
00094                                 break;
00095                         case 'R':
00096                                 tmp += BRED;
00097                                 break;
00098                         case 'G':
00099                                 tmp += BGRN;
00100                                 break;
00101                         case 'Y':
00102                                 tmp += BYEL;
00103                                 break;
00104                         case 'B':
00105                                 tmp += BBLU;
00106                                 break;
00107                         case 'M':
00108                                 tmp += BMAG;
00109                                 break;
00110                         case 'C':
00111                                 tmp += BCYN;
00112                                 break;
00113                         case 'W':
00114                                 tmp += BWHT;
00115                                 break;
00116                         case 'L':
00117                                 tmp += BBLK;
00118                                 break;
00119                         case 'e':
00120                                 tmp += BKRED;
00121                                 break;
00122                         case 'k':
00123                                 tmp += BKGRN;
00124                                 break;
00125                         case 'p':
00126                                 tmp += BKYEL;
00127                                 break;
00128                         case 'u':
00129                                 tmp += BKBLU;
00130                                 break;
00131                         case 'a':
00132                                 tmp += BKMAG;
00133                                 break;
00134                         case 'f':
00135                                 tmp += BKCYN;
00136                                 break;
00137                         case 'h':
00138                                 tmp += BKWHT;
00139                                 break;
00140                         case 'i':
00141                                 tmp += BKBLK;
00142                                 break;
00143                         case 'U':
00144                                 tmp += UNDER;
00145                                 break;
00146                         case 'F':
00147                                 tmp += FLASH;
00148                                 break;
00149                         case '&':
00150                                 tmp += (*this)[i];
00151                                 break;
00152                         default:
00153                                 i--;
00154                                 tmp += (*this)[i];
00155                                 break;
00156                         } // switch ((*this)[i])
00157                 }
00158                 else
00159                 if ((*this)[i] == '\n')
00160                 {
00161                         tmp += '\r';
00162                         tmp += (*this)[i];
00163                 }
00164                 else
00165                 {
00166                         tmp += (*this)[i];
00167                 }
00168         }
00169         if (m_cstr)
00170                 delete m_cstr;
00171         m_cstr = new char[tmp.size() + 1];
00172         memcpy(m_cstr,tmp.c_str(),tmp.size());
00173         m_cstr[tmp.size()] = 0;
00174 
00175         return m_cstr;
00176 }

const char * cstring::uc_str (  ) 

Definition at line 179 of file cstring.cpp.

References m_ucstr.

Referenced by operator==().

00180 {
00181         size_t n = size();
00182         std::string tmp;
00183 
00184         for (size_t i = 0; i < n; i++)
00185         {
00186                 if ((*this)[i] == '&')
00187                 {
00188                         i++;
00189                         switch ((*this)[i])
00190                         {
00191                         case 'n':
00192                                 break;
00193                         case 'r':
00194                                 break;
00195                         case 'g':
00196                                 break;
00197                         case 'y':
00198                                 break;
00199                         case 'b':
00200                                 break;
00201                         case 'm':
00202                                 break;
00203                         case 'c':
00204                                 break;
00205                         case 'w':
00206                                 break;
00207                         case 'l':
00208                                 break;
00209                         case 'R':
00210                                 break;
00211                         case 'G':
00212                                 break;
00213                         case 'Y':
00214                                 break;
00215                         case 'B':
00216                                 break;
00217                         case 'M':
00218                                 break;
00219                         case 'C':
00220                                 break;
00221                         case 'W':
00222                                 break;
00223                         case 'L':
00224                                 break;
00225                         case 'e':
00226                                 break;
00227                         case 'k':
00228                                 break;
00229                         case 'p':
00230                                 break;
00231                         case 'u':
00232                                 break;
00233                         case 'a':
00234                                 break;
00235                         case 'f':
00236                                 break;
00237                         case 'h':
00238                                 break;
00239                         case 'i':
00240                                 break;
00241                         case 'U':
00242                                 break;
00243                         case 'F':
00244                                 break;
00245                         case '&':
00246                                 tmp += (*this)[i];
00247                                 break;
00248                         default:
00249                                 i--;
00250                                 tmp += (*this)[i];
00251                                 break;
00252                         } // switch ((*this)[i])
00253                 }
00254                 else
00255                 {
00256                         tmp += (*this)[i];
00257                 }
00258         }
00259         if (m_ucstr)
00260                 delete m_ucstr;
00261         m_ucstr = new char[tmp.size() + 1];
00262         memcpy(m_ucstr,tmp.c_str(),tmp.size());
00263         m_ucstr[tmp.size()] = 0;
00264 
00265         return m_ucstr;
00266 }


Member Data Documentation

char* cstring::m_cstr [private]

Definition at line 50 of file cstring.h.

Referenced by c_str(), and ~cstring().

char* cstring::m_ucstr [private]

Definition at line 51 of file cstring.h.

Referenced by uc_str(), and ~cstring().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4