diff -r a76af67a3a4b -r 7b156b764d11 sources/mystring.h --- a/sources/mystring.h Sat Jan 09 02:35:00 2016 +0200 +++ b/sources/mystring.h Sat Jan 09 17:41:21 2016 +0200 @@ -34,6 +34,7 @@ #include #include "basics.h" #include "list.h" +BEGIN_ZFC_NAMESPACE class String; class StringList; @@ -45,8 +46,11 @@ public: String() {} - explicit String (char a) : - m_string ({ a, '\0' }) {} + String (char a) + { + char buffer[2] = { a, '0' }; + m_string = buffer; + } String (const char* data) : m_string (data) {} @@ -57,8 +61,8 @@ String (const Vector& data) : m_string (data.data(), data.size()) {} - using Iterator = std::string::iterator; - using ConstIterator = std::string::const_iterator; + typedef std::string::iterator Iterator; + typedef std::string::const_iterator ConstIterator; ConstIterator begin() const { return m_string.cbegin(); } int compare (const String &other) const; @@ -73,6 +77,7 @@ bool mask_against (const String &pattern) const; String md5() const; String mid (long a, long b) const; + String right (int length) const; StringList split (const String &del) const; StringList split (char del) const; const std::string& std_string() const { return m_string; } @@ -94,8 +99,8 @@ void insert (int pos, char c) { m_string.insert (m_string.begin() + pos, c); } void insert (int pos, const char*c) { m_string.insert (pos, c); } void modify_index (int &a) { if (a < 0) { a = length() - a; } } - void normalize (int (*filter)(int) = &std::isspace); - String normalized (int (*filter)(int) = &std::isspace) const; + void normalize (int (*filter)(int) = &isspace); + String normalized (int (*filter)(int) = &isspace) const; void prepend (String a) { m_string = (a + m_string).std_string(); } void remove (int pos, int len) { m_string.replace (pos, len, ""); } void remove_at (int pos) { m_string.erase (m_string.begin() + pos); } @@ -126,6 +131,8 @@ String& operator+= (const char* data) { append (data); return *this; } String& operator+= (int num) { return operator+= (String::from_number (num)); } String& operator+= (char data) { append (data); return *this; } + char& operator[] (int i) { return m_string[i]; } + char operator[] (int i) const { return m_string[i]; } bool operator== (const String& other) const { return std_string() == other.std_string(); } bool operator== (const char* other) const { return m_string == other; } bool operator!= (const String& other) const { return std_string() != other.std_string(); } @@ -146,11 +153,13 @@ class StringList : public List { public: - using Super = List; - using Super::Super; + typedef List Super; StringList() {} + StringList (int numvalues) : + Super (numvalues) {} + StringList (const Super& other) : Super (other) {} @@ -170,3 +179,5 @@ { return String (a) + b; } + +END_ZFC_NAMESPACE