--- a/sources/mystring.h Thu Jul 23 00:16:47 2015 +0300 +++ b/sources/mystring.h Thu Jul 23 01:52:04 2015 +0300 @@ -34,6 +34,7 @@ #include <stdarg.h> #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<char>& 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; @@ -106,8 +110,7 @@ void __cdecl sprintf (const char* fmtstr, ...); void vsprintf (const char* fmtstr, va_list args); bool starts_with (const String &other); - String strip (char unwanted) { return strip ({unwanted}); } - String strip (const List<char> &unwanted); + String strip (const List<char>& unwanted); void trim (int n); static String from_number (short int a); @@ -125,6 +128,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(); } @@ -171,3 +176,5 @@ { return String (a) + b; } + +END_ZFC_NAMESPACE