Gave cv::String appropriate += operators.
authorRoman Donchenko <roman.donchenko@itseez.com>
Thu, 21 Nov 2013 14:26:38 +0000 (18:26 +0400)
committerRoman Donchenko <roman.donchenko@itseez.com>
Fri, 22 Nov 2013 13:58:40 +0000 (17:58 +0400)
Note that since String is a reference to an immutable string,
this doesn't actually change the string; it just replaces *this
with a reference to the concatenated string.

modules/core/include/opencv2/core/cvstd.hpp
modules/core/include/opencv2/core/cvstd.inl.hpp

index afdeb25..f15e6a9 100644 (file)
@@ -364,6 +364,10 @@ public:
     String& operator=(const char* s);
     String& operator=(char c);
 
+    String& operator+=(const String& str);
+    String& operator+=(const char* s);
+    String& operator+=(char c);
+
     size_t size() const;
     size_t length() const;
 
@@ -416,6 +420,7 @@ public:
     String(const std::string& str);
     String(const std::string& str, size_t pos, size_t len = npos);
     String& operator=(const std::string& str);
+    String& operator+=(const std::string& str);
     operator std::string() const;
 
     friend String operator+ (const String& lhs, const std::string& rhs);
@@ -545,6 +550,27 @@ String& String::operator=(char c)
 }
 
 inline
+String& String::operator+=(const String& str)
+{
+    *this = *this + str;
+    return *this;
+}
+
+inline
+String& String::operator+=(const char* s)
+{
+    *this = *this + s;
+    return *this;
+}
+
+inline
+String& String::operator+=(char c)
+{
+    *this = *this + c;
+    return *this;
+}
+
+inline
 size_t String::size() const
 {
     return len_;
index 8642b74..ce18da3 100644 (file)
@@ -104,6 +104,13 @@ String& String::operator = (const std::string& str)
 }
 
 inline
+String& String::operator += (const std::string& str)
+{
+    *this = *this + str;
+    return *this;
+}
+
+inline
 String::operator std::string() const
 {
     return std::string(cstr_, len_);