sources/mystring.h

branch
protocol5
changeset 103
b78c0ca832a9
parent 84
3bd32eec3d57
child 106
7b156b764d11
equal deleted inserted replaced
84:3bd32eec3d57 103:b78c0ca832a9
93 int index_difference (int a, int b) { modify_index (a); modify_index (b); return b - a; } 93 int index_difference (int a, int b) { modify_index (a); modify_index (b); return b - a; }
94 void insert (int pos, char c) { m_string.insert (m_string.begin() + pos, c); } 94 void insert (int pos, char c) { m_string.insert (m_string.begin() + pos, c); }
95 void insert (int pos, const char*c) { m_string.insert (pos, c); } 95 void insert (int pos, const char*c) { m_string.insert (pos, c); }
96 void modify_index (int &a) { if (a < 0) { a = length() - a; } } 96 void modify_index (int &a) { if (a < 0) { a = length() - a; } }
97 void normalize (int (*filter)(int) = &std::isspace); 97 void normalize (int (*filter)(int) = &std::isspace);
98 String normalized (int (*filter)(int) = &std::isspace) const;
98 void prepend (String a) { m_string = (a + m_string).std_string(); } 99 void prepend (String a) { m_string = (a + m_string).std_string(); }
99 void remove (int pos, int len) { m_string.replace (pos, len, ""); } 100 void remove (int pos, int len) { m_string.replace (pos, len, ""); }
100 void remove_at (int pos) { m_string.erase (m_string.begin() + pos); } 101 void remove_at (int pos) { m_string.erase (m_string.begin() + pos); }
101 void remove_from_end (int len) { remove (length() - len, len); } 102 void remove_from_end (int len) { remove (length() - len, len); }
102 void remove_from_start (int len) { remove (0, len); } 103 void remove_from_start (int len) { remove (0, len); }
103 void replace (const char* a, const char* b); 104 void replace (const char* a, const char* b);
104 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); } 105 void replace (int pos, int n, const String &a) { m_string.replace (pos, n, a.chars()); }
105 void shrink_to_fit() { m_string.shrink_to_fit(); } 106 void shrink_to_fit() { m_string.shrink_to_fit(); }
106 void __cdecl sprintf (const char* fmtstr, ...); 107 void __cdecl sprintf (const char* fmtstr, ...);
107 void sprintf (const char* fmtstr, ...);
108 void vsprintf (const char* fmtstr, va_list args); 108 void vsprintf (const char* fmtstr, va_list args);
109 bool starts_with (const String &other) const; 109 bool starts_with (const String &other) const;
110 String strip (char unwanted) { return strip ({unwanted}); } 110 String strip (char unwanted) { return strip ({unwanted}); }
111 String strip (const List<char> &unwanted); 111 String strip (const List<char> &unwanted);
112 void trim (int n); 112 void trim (int n);

mercurial