43 #ifndef CCXX_STRING_H_
44 #define CCXX_STRING_H_
46 #ifndef CCXX_MISSING_H_
50 #ifndef CCXX_STRCHAR_H_
54 #ifdef CCXX_NAMESPACES
104 char text[(
sizeof(
char *) + (
sizeof(
size_t) * 2) + 1)];
121 inline bool isBig(
void)
const
122 {
return content.ministring.big;};
132 const char *
set(
const char *str,
size_t len = 0);
140 void set(
const String &str);
150 const char *
set(
size_t size,
const char *format, ...);
159 void copy(
const String &str);
173 static char *getSpace(
size_t size);
182 size_t setSize(
size_t size);
189 void setLength(
size_t len);
201 virtual int compare(
const char *text,
size_t len = 0,
size_t index = 0)
const;
212 size_t search(
const char *text,
size_t clen = 0,
size_t offset = 0)
const;
243 String(std::string
string);
252 String(
const String &str,
size_t offset,
size_t len = npos);
261 String(
size_t size,
const char *format, ...);
270 String(
size_t count,
const char *str);
279 String(
size_t count,
const char fill =
' ');
293 const char *getIndex(
size_t index)
const;
300 char *getText(
void)
const;
307 long getValue(
long defvalue = 0l)
const;
314 bool getBool(
bool defbool =
false)
const;
321 const size_t getLength(
void)
const;
328 const size_t getSize(
void)
const;
335 bool isEmpty(
void)
const;
342 void resize(
size_t size);
354 char at(ssize_t offset)
const;
364 unsigned count(
const String &s,
size_t offset = 0)
const;
375 unsigned count(
const char *s,
size_t offset = 0,
size_t len = 0)
const;
384 String token(
const char *delim =
" \t\n\r",
size_t offset = 0);
394 size_t find(
const String &s,
size_t offset = 0,
unsigned instance = 1)
const;
403 size_t rfind(
const String &s,
size_t offset = 0)
const;
414 size_t find(
const char *s,
size_t offset = 0,
size_t len = 0,
unsigned count = 1)
const;
424 size_t rfind(
const char *s,
size_t offset = 0,
size_t len = 0)
const;
431 inline void trim(
const char *cs)
432 {setLength(
strtrim(cs, getText(), getLength()));};
439 inline void chop(
const char *cs)
440 {setLength(
strchop(cs, getText(), getLength()));};
447 void strip(
const char *cs);
454 inline void chop(
size_t chars)
462 void trim(
size_t count);
470 void erase(
size_t start,
size_t len = npos);
479 void insert(
size_t start,
const char *text,
size_t len = 0);
487 void insert(
size_t start,
const String &str);
498 void replace(
size_t start,
size_t len,
const char *text,
size_t count = 0);
508 void replace(
size_t start,
size_t len,
const String &
string);
519 inline size_t find(
unsigned instance,
const char *text,
size_t offset = 0,
size_t len = 0)
const
520 {
return find(text, offset, len, instance);};
530 inline size_t find(
unsigned instance,
const String &
string,
size_t offset = 0)
const
531 {
return find(
string, offset, instance);};
541 inline String substr(
size_t start,
size_t len)
const
542 {
return String(*
this, start, len);};
551 inline const char *(index)(
size_t ind)
const
552 {
return getIndex(ind);};
558 inline void compact(
void)
559 {resize(getLength() + 1);};
566 inline char *c_str(
void)
const
574 inline operator char *()
const
582 inline bool operator!(
void)
const
590 inline char *text(
void)
const
598 inline char *data(
void)
const
606 inline size_t length(
void)
const
607 {
return strlen(getText());};
614 inline size_t size(
void)
const
615 {
return getLength();};
622 inline size_t capacity(
void)
const
628 bool empty(
void)
const
637 void append(
const char *str,
size_t count = 0);
646 void append(
size_t size,
const char *format, ...);
656 void append(
const char *str,
size_t offset,
size_t count);
670 void append(
const String &str);
677 inline const char operator[](
unsigned ind)
const
683 inline const char *operator =(
const char *str)
703 {append(str);
return *
this;};
709 {add(c);
return *
this;};
714 inline String &operator+=(
const char *str)
715 {append(str);
return *
this;};
720 inline String &operator+=(
const std::string &str)
721 {append(str.c_str());
return *
this;};
733 friend __EXPORT std::istream &getline(std::istream &is,
String &str,
char delim =
'\n',
size_t size = 0);
744 inline friend std::istream &operator>>(std::istream &is,
String &str)
745 {
return getline(is, str);};
756 friend __EXPORT int strprintf(
String &str,
size_t size,
const char *format, ...);
759 bool operator<(
const String &str)
const;
760 bool operator<(
const char *str)
const;
761 bool operator>(
const String &str)
const;
762 bool operator>(
const char *str)
const;
763 bool operator<=(
const String &str)
const;
764 bool operator<=(
const char *str)
const;
765 bool operator>=(
const String &str)
const;
766 bool operator>=(
const char *str)
const;
767 bool operator==(
const String &str)
const;
768 bool operator==(
const char *str)
const;
769 bool operator!=(
const String &str)
const;
770 bool operator!=(
const char *str)
const;
778 {append(16,
"%d", i);
return *
this;};
780 inline String &operator+=(
unsigned int i)
781 {append(16,
"%u", i);
return *
this;};
784 {append(16,
"%l", l);
return *
this;};
786 inline String &operator+=(
unsigned long l)
787 {append(16,
"%ul", l);
return *
this;};
790 {append(32,
"%f", f);
return *
this;};
793 {append(32,
"%f", d);
return *
this;};
796 {append(8,
"%hd", s);
return *
this;};
798 inline String &operator+=(
unsigned short s)
799 {append(8,
"%hu", s);
return *
this;};
806 {
set(16,
"%d", i);
return *
this;};
809 {
set(16,
"%u", i);
return *
this;};
812 {
set(16,
"%l", l);
return *
this;};
814 inline String &operator=(
unsigned long l)
815 {
set(16,
"%ul", l);
return *
this;};
818 {
set(32,
"%f", f);
return *
this;};
821 {
set(32,
"%f", d);
return *
this;};
824 {
set(8,
"%hd", s);
return *
this;};
826 inline String &operator=(
unsigned short s)
827 {
set(8,
"%hu", s);
return *
this;};
831 {copy(original);
return *
this;};
836 bool operator*=(
const String &str)
const;
841 bool operator*=(
const char *str)
const;
891 void operator delete(
void *obj);
894 #ifdef CCXX_NAMESPACES