44 #ifndef CCXX_STRING_H_
45 #define CCXX_STRING_H_
47 #ifndef CCXX_MISSING_H_
51 #ifndef CCXX_STRCHAR_H_
55 #ifdef CCXX_NAMESPACES
105 char text[(
sizeof(
char *) + (
sizeof(
size_t) * 2) + 1)];
122 inline bool isBig(
void)
const
123 {
return content.ministring.big;};
133 const char *
set(
const char *str,
size_t len = 0);
141 void set(
const String &str);
151 const char *
set(
size_t size,
const char *format, ...);
160 void copy(
const String &str);
174 static char *getSpace(
size_t size);
183 size_t setSize(
size_t size);
190 void setLength(
size_t len);
202 virtual int compare(
const char *text,
size_t len = 0,
size_t index = 0)
const;
213 size_t search(
const char *text,
size_t clen = 0,
size_t offset = 0)
const;
244 String(std::string
string);
253 String(
const String &str,
size_t offset,
size_t len = npos);
262 String(
size_t size,
const char *format, ...);
271 String(
size_t count,
const char *str);
280 String(
size_t count,
const char fill =
' ');
294 const char *getIndex(
size_t index)
const;
301 char *getText(
void)
const;
308 long getValue(
long defvalue = 0l)
const;
315 bool getBool(
bool defbool =
false)
const;
322 const size_t getLength(
void)
const;
329 const size_t getSize(
void)
const;
336 bool isEmpty(
void)
const;
343 void resize(
size_t size);
355 char at(ssize_t offset)
const;
365 unsigned count(
const String &s,
size_t offset = 0)
const;
376 unsigned count(
const char *s,
size_t offset = 0,
size_t len = 0)
const;
385 String token(
const char *delim =
" \t\n\r",
size_t offset = 0);
395 size_t find(
const String &s,
size_t offset = 0,
unsigned instance = 1)
const;
404 size_t rfind(
const String &s,
size_t offset = 0)
const;
415 size_t find(
const char *s,
size_t offset = 0,
size_t len = 0,
unsigned count = 1)
const;
425 size_t rfind(
const char *s,
size_t offset = 0,
size_t len = 0)
const;
432 inline void trim(
const char *cs)
433 {setLength(
strtrim(cs, getText(), getLength()));};
440 inline void chop(
const char *cs)
441 {setLength(
strchop(cs, getText(), getLength()));};
448 void strip(
const char *cs);
455 inline void chop(
size_t chars)
463 void trim(
size_t count);
471 void erase(
size_t start,
size_t len = npos);
480 void insert(
size_t start,
const char *text,
size_t len = 0);
488 void insert(
size_t start,
const String &str);
499 void replace(
size_t start,
size_t len,
const char *text,
size_t count = 0);
509 void replace(
size_t start,
size_t len,
const String &
string);
520 inline size_t find(
unsigned instance,
const char *text,
size_t offset = 0,
size_t len = 0)
const
521 {
return find(text, offset, len, instance);};
531 inline size_t find(
unsigned instance,
const String &
string,
size_t offset = 0)
const
532 {
return find(
string, offset, instance);};
542 inline String substr(
size_t start,
size_t len)
const
543 {
return String(*
this, start, len);};
552 inline const char *(index)(
size_t ind)
const
553 {
return getIndex(ind);};
559 inline void compact(
void)
560 {resize(getLength() + 1);};
567 inline char *c_str(
void)
const
575 inline operator char *()
const
583 inline bool operator!(
void)
const
591 inline char *text(
void)
const
599 inline char *data(
void)
const
607 inline size_t length(
void)
const
608 {
return strlen(getText());};
615 inline size_t size(
void)
const
616 {
return getLength();};
623 inline size_t capacity(
void)
const
629 bool empty(
void)
const
638 void append(
const char *str,
size_t count = 0);
647 void append(
size_t size,
const char *format, ...);
657 void append(
const char *str,
size_t offset,
size_t count);
671 void append(
const String &str);
678 inline const char operator[](
unsigned ind)
const
684 inline const char *operator =(
const char *str)
704 {append(str);
return *
this;};
710 {add(c);
return *
this;};
715 inline String &operator+=(
const char *str)
716 {append(str);
return *
this;};
721 inline String &operator+=(
const std::string &str)
722 {append(str.c_str());
return *
this;};
734 friend __EXPORT std::istream &getline(std::istream &is,
String &str,
char delim =
'\n',
size_t size = 0);
745 inline friend std::istream &operator>>(std::istream &is,
String &str)
746 {
return getline(is, str);};
757 friend __EXPORT int strprintf(
String &str,
size_t size,
const char *format, ...);
760 bool operator<(
const String &str)
const;
761 bool operator<(
const char *str)
const;
762 bool operator>(
const String &str)
const;
763 bool operator>(
const char *str)
const;
764 bool operator<=(
const String &str)
const;
765 bool operator<=(
const char *str)
const;
766 bool operator>=(
const String &str)
const;
767 bool operator>=(
const char *str)
const;
768 bool operator==(
const String &str)
const;
769 bool operator==(
const char *str)
const;
770 bool operator!=(
const String &str)
const;
771 bool operator!=(
const char *str)
const;
779 {append(16,
"%d", i);
return *
this;};
781 inline String &operator+=(
unsigned int i)
782 {append(16,
"%u", i);
return *
this;};
785 {append(16,
"%l", l);
return *
this;};
787 inline String &operator+=(
unsigned long l)
788 {append(16,
"%ul", l);
return *
this;};
791 {append(32,
"%f", f);
return *
this;};
794 {append(32,
"%f", d);
return *
this;};
797 {append(8,
"%hd", s);
return *
this;};
799 inline String &operator+=(
unsigned short s)
800 {append(8,
"%hu", s);
return *
this;};
807 {
set(16,
"%d", i);
return *
this;};
810 {
set(16,
"%u", i);
return *
this;};
813 {
set(16,
"%l", l);
return *
this;};
815 inline String &operator=(
unsigned long l)
816 {
set(16,
"%ul", l);
return *
this;};
819 {
set(32,
"%f", f);
return *
this;};
822 {
set(32,
"%f", d);
return *
this;};
825 {
set(8,
"%hd", s);
return *
this;};
827 inline String &operator=(
unsigned short s)
828 {
set(8,
"%hu", s);
return *
this;};
832 {copy(original);
return *
this;};
837 bool operator*=(
const String &str)
const;
842 bool operator*=(
const char *str)
const;
892 void operator delete(
void *obj);
895 #ifdef CCXX_NAMESPACES