Added assignment to MString from ZString operator=.
This commit is contained in:
parent
61d9f8015e
commit
7b333a3984
@ -81,6 +81,13 @@ namespace coreutils {
|
|||||||
return *this;
|
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) {
|
MString &MString::operator=(const char *value) {
|
||||||
int len = strlen(value);
|
int len = strlen(value);
|
||||||
setSize(len);
|
setSize(len);
|
||||||
|
@ -95,9 +95,8 @@ namespace coreutils
|
|||||||
/// Assignment operator will copy data to backing store.
|
/// Assignment operator will copy data to backing store.
|
||||||
///
|
///
|
||||||
|
|
||||||
// MString& operator=(coreutils::ZString& data);
|
|
||||||
|
|
||||||
MString &operator=(coreutils::MString data);
|
MString &operator=(coreutils::MString data);
|
||||||
|
MString &operator=(coreutils::ZString data);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Assignment operator will copy data to backing store.
|
/// Assignment operator will copy data to backing store.
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -58,6 +58,14 @@ int main(int argc, char **argv) {
|
|||||||
test10 = "";
|
test10 = "";
|
||||||
std::cout << ">" << test10 << "<" << std::endl;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user