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

@ -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);

View File

@ -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.
///

Binary file not shown.

Binary file not shown.

View File

@ -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;
}