22 #include <string> |
22 #include <string> |
23 #include <stdarg.h> |
23 #include <stdarg.h> |
24 #include <QString> |
24 #include <QString> |
25 #include "types.h" |
25 #include "types.h" |
26 |
26 |
27 typedef class String { |
|
28 public: |
|
29 typedef typename std::string::iterator it; |
|
30 typedef typename std::string::const_iterator c_it; |
|
31 typedef vector<String> stringlist; |
|
32 |
|
33 String (); |
|
34 String (const char* data); |
|
35 String (const QString data); |
|
36 String (std::string data); |
|
37 |
|
38 void append (const char* data); |
|
39 void append (const char data); |
|
40 void append (const String data); |
|
41 it begin (); |
|
42 c_it begin () const; |
|
43 const char* c () const; |
|
44 size_t capacity () const; |
|
45 const char* chars () const; |
|
46 int compare (const char* other) const; |
|
47 int compare (String other) const; |
|
48 it end (); |
|
49 c_it end () const; |
|
50 void clear (); |
|
51 ushort count (const char needle) const; |
|
52 bool empty () const; |
|
53 void erase (size_t pos); |
|
54 int first (const char* c, int a = 0) const; |
|
55 void format (const char* fmtstr, ...); |
|
56 void insert (size_t pos, char c); |
|
57 int last (const char* c, int a = -1) const; |
|
58 size_t len () const; |
|
59 String lower () const; |
|
60 size_t maxSize () const; |
|
61 void replace (const char* a, const char* b); |
|
62 void resize (size_t n); |
|
63 void shrinkToFit (); |
|
64 stringlist split (String del) const; |
|
65 stringlist split (char del) const; |
|
66 String strip (char unwanted); |
|
67 String strip (std::initializer_list<char> unwanted); |
|
68 String substr (long a, long b) const; |
|
69 void trim (short n); |
|
70 String upper () const; |
|
71 |
|
72 String operator+ (const String data) const; |
|
73 String operator+ (const char* data) const; |
|
74 String& operator+= (const String data); |
|
75 String& operator+= (const char* data); |
|
76 String& operator+= (const char data); |
|
77 String operator+ () const; |
|
78 String operator- () const; |
|
79 String operator- (size_t n) const; |
|
80 String& operator-= (size_t n); |
|
81 size_t operator~ () const; |
|
82 vector<String> operator/ (String del) const; |
|
83 char& operator[] (size_t n); |
|
84 const char& operator[] (size_t n) const; |
|
85 bool operator== (const String other) const; |
|
86 bool operator== (const char* other) const; |
|
87 bool operator!= (const String other) const; |
|
88 bool operator!= (const char* other) const; |
|
89 bool operator! () const; |
|
90 operator const char* () const; |
|
91 operator QString (); |
|
92 operator const QString () const; |
|
93 |
|
94 static str join (const vector<str>& items, const str& delim); |
|
95 |
|
96 private: |
|
97 std::string m_string; |
|
98 } str; |
|
99 |
|
100 // Accessories |
|
101 char* dynafmt (const char* fmtstr, va_list va, ulong size); |
|
102 str fmt (const char* fmtstr, ...); |
|
103 |
27 |
104 #endif // STR_H |
28 #endif // STR_H |