Continues ZString and MString adjustments.

This commit is contained in:
Brad Arant 2022-07-30 18:04:27 -07:00
parent f8bc2df133
commit 963a0561e8
4 changed files with 43 additions and 14 deletions

View File

@ -42,6 +42,12 @@ namespace coreutils {
cursor = data; cursor = data;
} }
MString::MString(ZString zstring) {
setSize(zstring.getLength());
memcpy(data, zstring.getData(), zstring.getLength());
cursor = data;
}
MString::MString(std::string data) { MString::MString(std::string data) {
setSize(data.length()); setSize(data.length());
memcpy(this->data, (char *)data.c_str(), data.length()); memcpy(this->data, (char *)data.c_str(), data.length());
@ -58,16 +64,25 @@ namespace coreutils {
return 0; return 0;
} }
MString& MString::operator=(coreutils::ZString& value) { // MString& MString::operator=(coreutils::ZString& value) {
if(*this == value) // if(*this == value)
return *this; // return *this;
int len = length; // int len = length;
setSize(length + value.getLength()); // setSize(length + value.getLength());
memcpy(data + len, value.getData(), value.getLength()); // memcpy(data + len, value.getData(), value.getLength());
return *this; // return *this;
} // }
MString& MString::operator=(coreutils::MString& value) { // MString& MString::operator=(coreutils::ZString& value) {
// if(*this == value)
// return *this;
// int len = length;
// setSize(length + value.getLength());
// memcpy(data + len, value.getData(), value.getLength());
// return *this;
// }
MString& MString::operator=(coreutils::ZString value) {
if(*this == value) if(*this == value)
return *this; return *this;
int len = length; int len = length;
@ -105,7 +120,15 @@ namespace coreutils {
return *this; return *this;
} }
MString& MString::operator<<(coreutils::ZString &zstring) { // MString& MString::operator<<(coreutils::ZString &zstring) {
// int temp = length;
// int len = length + zstring.getLength();
// setSize(len);
// memcpy(data + temp, zstring.getData(), zstring.getLength());
// return *this;
// }
MString& MString::operator<<(coreutils::ZString zstring) {
int temp = length; int temp = length;
int len = length + zstring.getLength(); int len = length + zstring.getLength();
setSize(len); setSize(len);

View File

@ -44,6 +44,8 @@ namespace coreutils {
MString(ZString &zstring); MString(ZString &zstring);
MString(ZString zstring);
/// ///
/// Consructor providing a copy of a ZString. /// Consructor providing a copy of a ZString.
/// ///
@ -62,13 +64,15 @@ 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::ZString& data);
/// ///
/// Assignment operator will copy data to backing store. /// Assignment operator will copy data to backing store.
/// ///
MString& operator=(coreutils::MString& data); // MString& operator=(coreutils::ZString& data);
MString& operator=(coreutils::ZString data);
/// ///
/// Assignment operator will copy data to backing store. /// Assignment operator will copy data to backing store.
@ -90,7 +94,9 @@ namespace coreutils {
MString& operator<<(const int value); MString& operator<<(const int value);
MString& operator<<(coreutils::ZString &zstring); // MString& operator<<(coreutils::ZString &zstring);
MString& operator<<(coreutils::ZString zstring);
MString& operator<<(std::string value); MString& operator<<(std::string value);

Binary file not shown.