ULTIMA: Moving many string methods from Std::String to Common::String
This commit is contained in:
parent
b338b8993d
commit
a178952464
5 changed files with 147 additions and 184 deletions
51
common/str.h
51
common/str.h
|
@ -171,8 +171,6 @@ public:
|
|||
bool contains(const char *x) const;
|
||||
bool contains(char x) const;
|
||||
|
||||
uint32 find(const String &str, uint32 pos = 0) const;
|
||||
|
||||
/** Return uint64 corrensponding to String's contents. */
|
||||
uint64 asUint64() const;
|
||||
|
||||
|
@ -226,6 +224,9 @@ public:
|
|||
/** Remove all characters from position p to the p + len. If len = String::npos, removes all characters to the end */
|
||||
void erase(uint32 p, uint32 len = npos);
|
||||
|
||||
/** Erases the character at the given iterator location */
|
||||
iterator erase(iterator it);
|
||||
|
||||
/** Set character c at position p, replacing the previous character there. */
|
||||
void setChar(char c, uint32 p);
|
||||
|
||||
|
@ -306,6 +307,52 @@ public:
|
|||
*/
|
||||
static String vformat(const char *fmt, va_list args);
|
||||
|
||||
/** Finds the index of a character in the string */
|
||||
size_t find(char c, size_t pos = 0) const;
|
||||
|
||||
/** Does a find for the passed string */
|
||||
size_t find(const char *s) const;
|
||||
uint32 find(const String &str, uint32 pos = 0) const;
|
||||
|
||||
/** Does a reverse find for the passed string */
|
||||
size_t rfind(const char *s) const;
|
||||
size_t rfind(const String &s) const {
|
||||
return rfind(s.c_str());
|
||||
}
|
||||
|
||||
/** Does a reverse find for a passed character */
|
||||
size_t rfind(char c, size_t pos = npos) const;
|
||||
|
||||
/** Find first character in the string matching the passed character */
|
||||
size_t find_first_of(char c, size_t pos = 0) const;
|
||||
|
||||
/** Find first character in the string that's any character of the passed string */
|
||||
size_t find_first_of(const char *chars, size_t pos = 0) const;
|
||||
size_t find_first_of(const String &chars, size_t pos = 0) const {
|
||||
return find_first_of(chars.c_str(), pos);
|
||||
}
|
||||
|
||||
/** Find first character in the string that's not the specified character */
|
||||
size_t find_first_not_of(char c, size_t pos = 0) const;
|
||||
|
||||
/** Find first character in the string that's not any character of the passed string */
|
||||
size_t find_first_not_of(const char *chars, size_t pos = 0) const;
|
||||
size_t find_first_not_of(const String &chars, size_t pos = 0) const {
|
||||
return find_first_not_of(chars.c_str(), pos);
|
||||
}
|
||||
|
||||
/** Find the last character in the string that's not the specified character */
|
||||
size_t find_last_not_of(char c) const;
|
||||
|
||||
/** Find the last character in the string that's not in any of the passed characters */
|
||||
size_t find_last_not_of(const char *chars) const;
|
||||
size_t find_last_not_of(const String &chars) const {
|
||||
return find_last_not_of(chars.c_str());
|
||||
}
|
||||
|
||||
/** Return a substring of this string */
|
||||
String substr(size_t pos = 0, size_t len = npos) const;
|
||||
|
||||
public:
|
||||
|
||||
iterator begin() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue