Added assignment to MString from ZString operator=.

This commit is contained in:
Brad Arant 2023-10-08 07:26:26 -07:00
parent 61d9f8015e
commit 7b333a3984
5 changed files with 19 additions and 5 deletions

View File

@ -81,6 +81,13 @@ namespace coreutils {
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);
setSize(len);

View File

@ -95,9 +95,8 @@ 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.

Binary file not shown.

Binary file not shown.

View File

@ -58,6 +58,14 @@ int main(int argc, char **argv) {
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;
}