Merge up with master branch.

This commit is contained in:
Brad Arant committed 2022-07-28 18:52:30 -07:00
commit f8bc2df133
5 files changed
+68 -35

No files matched your search

+27 -12
View File
@@ -24,7 +24,7 @@ namespace coreutils {
}
MString::MString(const char *data, size_t length) {
setSize(length);
setSize(length);
memcpy(this->data, data, length);
cursor = this->data;
}
@@ -36,6 +36,12 @@ namespace coreutils {
// Log(LOG_DEBUG_2) << "MString Copy Constructor: ";
}
MString::MString(ZString &zstring) {
setSize(zstring.getLength());
memcpy(data, zstring.getData(), zstring.getLength());
cursor = data;
}
MString::MString(std::string data) {
setSize(data.length());
memcpy(this->data, (char *)data.c_str(), data.length());
@@ -58,21 +64,30 @@ namespace coreutils {
int len = length;
setSize(length + value.getLength());
memcpy(data + len, value.getData(), value.getLength());
return *this;
return *this;
}
MString& MString::operator=(coreutils::MString& 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=(const char *value) {
int len = strlen(value);
setSize(len);
memcpy(data, value, len);
return *this;
return *this;
}
MString& MString::operator=(char value) {
int len = 1;
setSize(1);
*data = value;
return *this;
return *this;
}
MString& MString::operator<<(const char *value) {
@@ -105,18 +120,18 @@ namespace coreutils {
memcpy(data + temp, value.c_str(), value.length());
return *this;
}
int MString::write(char ch) {
MString& MString::write(char ch) {
setSize(length + 1);
*(data + length - 1) = ch;
return 1;
return *this;
}
int MString::write(ZString &value) {
MString& MString::write(ZString &value) {
int len = length;
setSize(length + value.getLength());
memcpy(data + len, value.getData(), value.getLength());
return value.getLength();
return *this;
}
void MString::setSize(int size) {
@@ -124,10 +139,10 @@ namespace coreutils {
int newBufferSize = ((size / 256) + 1) * 256;
if(bufferSize != newBufferSize) {
bufferSize = newBufferSize;
data = (char *)realloc(data, bufferSize);
data = (char *)realloc(data, bufferSize);
cursor = data + cursorOffset;
}
length = size;
}
}