sources/mystring.h

changeset 107
ca10837a2a9e
parent 105
b4466472aecd
child 108
5900be70c619
child 109
e4966d7e615d
equal deleted inserted replaced
105:b4466472aecd 107:ca10837a2a9e
98 int index_difference (int a, int b) { modify_index (a); modify_index (b); return b - a; } 98 int index_difference (int a, int b) { modify_index (a); modify_index (b); return b - a; }
99 void insert (int pos, char c) { m_string.insert (m_string.begin() + pos, c); } 99 void insert (int pos, char c) { m_string.insert (m_string.begin() + pos, c); }
100 void insert (int pos, const char*c) { m_string.insert (pos, c); } 100 void insert (int pos, const char*c) { m_string.insert (pos, c); }
101 void modify_index (int &a) { if (a < 0) { a = length() - a; } } 101 void modify_index (int &a) { if (a < 0) { a = length() - a; } }
102 void normalize (int (*filter)(int) = &isspace); 102 void normalize (int (*filter)(int) = &isspace);
103 String normalized (int (*filter)(int) = &isspace) const;
103 void prepend (String a) { m_string = (a + m_string).std_string(); } 104 void prepend (String a) { m_string = (a + m_string).std_string(); }
104 void remove (int pos, int len) { m_string.replace (pos, len, ""); } 105 void remove (int pos, int len) { m_string.replace (pos, len, ""); }
105 void remove_at (int pos) { m_string.erase (m_string.begin() + pos); } 106 void remove_at (int pos) { m_string.erase (m_string.begin() + pos); }
106 void remove_from_end (int len) { remove (length() - len, len); } 107 void remove_from_end (int len) { remove (length() - len, len); }
107 void remove_from_start (int len) { remove (0, len); } 108 void remove_from_start (int len) { remove (0, len); }
108 void replace (const char* a, const char* b); 109 void replace (const char* a, const char* b);
109 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); } 110 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); }
110 void shrink_to_fit() { m_string.shrink_to_fit(); } 111 void shrink_to_fit() { m_string.shrink_to_fit(); }
111 void __cdecl sprintf (const char* fmtstr, ...); 112 void __cdecl sprintf (const char* fmtstr, ...);
112 void vsprintf (const char* fmtstr, va_list args); 113 void vsprintf (const char* fmtstr, va_list args);
113 bool starts_with (const String &other); 114 bool starts_with (const String &other) const;
114 String strip (const List<char>& unwanted); 115 String strip (char unwanted) { return strip ({unwanted}); }
116 String strip (const List<char> &unwanted);
115 void trim (int n); 117 void trim (int n);
116 118
117 static String from_number (short int a); 119 static String from_number (short int a);
118 static String from_number (int a); 120 static String from_number (int a);
119 static String from_number (long int a); 121 static String from_number (long int a);

mercurial