|
rllib
1
|
#include <rlstring.h>
Public Member Functions | |
| rlString (const char *text="") | |
| rlString (rlString &text) | |
| rlString (rlString *text) | |
| virtual | ~rlString () |
| rlString & | operator= (const char *s2) |
| rlString & | operator= (rlString &s2) |
| rlString & | operator+ (const char *s2) |
| rlString & | operator+ (rlString &s2) |
| rlString & | operator+= (const char *s2) |
| rlString & | operator+= (rlString &s2) |
| char * | text () |
| int | setText (const char *text) |
| int | printf (const char *format,...) |
| int | strcpy (const char *text) |
| 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) |
| int | removeQuotas (char c='"') |
Private Attributes | |
| char * | txt |
class for a simple ANSI-C like string.
Definition at line 25 of file rlstring.h.
| rlString::rlString | ( | const char * | text = "" | ) |
| rlString::rlString | ( | rlString & | text | ) |
Definition at line 27 of file rlstring.cpp.
| rlString::rlString | ( | rlString * | text | ) |
Definition at line 33 of file rlstring.cpp.
| rlString::~rlString | ( | ) | [virtual] |
| int rlString::cat | ( | const char * | text | ) |
| int rlString::lower | ( | ) |
converst string to upper case
Definition at line 142 of file rlstring.cpp.
{
return ::rllower(txt);
}
| rlString & rlString::operator+ | ( | const char * | s2 | ) |
Definition at line 56 of file rlstring.cpp.
{
this->cat(s2);
return *this;
}
Definition at line 62 of file rlstring.cpp.
| rlString & rlString::operator+= | ( | const char * | s2 | ) |
Definition at line 68 of file rlstring.cpp.
{
this->cat(s2);
return *this;
}
Definition at line 74 of file rlstring.cpp.
| rlString & rlString::operator= | ( | const char * | s2 | ) |
Definition at line 44 of file rlstring.cpp.
{
this->setText(s2);
return *this;
}
Definition at line 50 of file rlstring.cpp.
| int rlString::printf | ( | const char * | format, |
| ... | |||
| ) |
printf the text
Definition at line 94 of file rlstring.cpp.
{
int ret;
char mystring[rl_PRINTF_LENGTH]; // should be big enough
va_list ap;
va_start(ap,format);
ret = rlvsnprintf(mystring, rl_PRINTF_LENGTH - 1, format, ap);
va_end(ap);
if(ret < 0) return ret;
delete [] txt;
txt = new char [strlen(mystring)+1];
::strcpy(txt, mystring);
return ret;
}
| int rlString::removeQuotas | ( | char | c = '"' | ) |
Remove quotas around a string. This might be usefull together with CSV files.
Definition at line 182 of file rlstring.cpp.
{
char c;
int state=0, inquotas=0, j=0;
int len = strlen(txt);
for(int i=0;i<len;i++)
{
c = txt[i];
switch(state)
{
case 0: //START
if(c==q)
{
state=1;
inquotas=1;
break;
}
state=1;
case 1: // BODY
if(inquotas==1)
{
if(c==q)
{
inquotas=0;
break;
}
}
txt[j++]=c;
break;
default:
break;
}
}
txt[j++]=0;
return j;
}
| int rlString::setText | ( | const char * | text | ) |
| int rlString::startsWith | ( | const char * | startstr | ) |
test if string starts with startstr
Definition at line 147 of file rlstring.cpp.
{
return ::rlStartsWith(txt,startstr);
}
| char * rlString::strchr | ( | int | c | ) |
| int rlString::strcpy | ( | const char * | text | ) |
| int rlString::strnnocasecmp | ( | const char * | other, |
| int | n | ||
| ) |
| int rlString::strnocasecmp | ( | const char * | other | ) |
| char * rlString::strrchr | ( | int | c | ) |
| char * rlString::strstr | ( | const char * | substring | ) |
strstr()
Definition at line 131 of file rlstring.cpp.
{
if(substring == NULL) return NULL;
return ::strstr(txt,substring);
}
| char * rlString::text | ( | ) |
| int rlString::upper | ( | ) |
converst string to upper case
Definition at line 137 of file rlstring.cpp.
{
return ::rlupper(txt);
}
char* rlString::txt [private] |
Definition at line 121 of file rlstring.h.
1.7.5.1