diff --git a/MString.cpp b/MString.cpp index 9db15ad..3a3aa17 100644 --- a/MString.cpp +++ b/MString.cpp @@ -80,6 +80,13 @@ namespace coreutils { length = value.getLength(); return *this; } + + MString &MString::operator=(coreutils::ZString value) { + setSize(value.getLength()); + memcpy(data, value.getData(), value.getLength()); + length = value.getLength(); + return *this; + } MString &MString::operator=(const char *value) { int len = strlen(value); diff --git a/MString.h b/MString.h index defc8a5..dcb96d7 100644 --- a/MString.h +++ b/MString.h @@ -94,11 +94,10 @@ namespace coreutils /// /// Assignment operator will copy data to backing store. /// - - // MString& operator=(coreutils::ZString& data); - + MString &operator=(coreutils::MString data); - + MString &operator=(coreutils::ZString data); + /// /// Assignment operator will copy data to backing store. /// diff --git a/testing/jstring_test b/testing/jstring_test index 23fbe1d..17e2064 100755 Binary files a/testing/jstring_test and b/testing/jstring_test differ diff --git a/testing/mstring_test b/testing/mstring_test index 9ec153b..e2ffe30 100755 Binary files a/testing/mstring_test and b/testing/mstring_test differ diff --git a/testing/mstring_test.cpp b/testing/mstring_test.cpp index 49df49e..453c16c 100644 --- a/testing/mstring_test.cpp +++ b/testing/mstring_test.cpp @@ -57,7 +57,15 @@ int main(int argc, char **argv) { std::cout << ">" << test10 << "<" << std::endl; test10 = ""; std::cout << ">" << test10 << "<" << std::endl; - + + // Assign from ZString tests. + + coreutils::ZString test20("This is a zstring"); + coreutils::MString test21; + test21 = test20; + std::cout << "mstring = zstring: [" << test21 << "]" << std::endl; + + return 0; }