Added char * << to MString for string assignment.

This commit is contained in:
Brad Arant committed 2022-07-21 19:39:47 -07:00
1 parent 287933f9ce
commit d8df083d6b
5 files changed
+73 -1

No files matched your search

+21 -1
View File
@@ -1,6 +1,5 @@
#include "MString.h"
#include "Log.h"
#include <iostream>
#include <stdlib.h>
#include <iomanip>
@@ -56,6 +55,27 @@ namespace coreutils {
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;
}
MString& MString::operator=(char value) {
int len = 1;
setSize(1);
*data = value;
return *this;
}
MString& MString::operator<<(const char *value) {
int len = strlen(value);
setSize(len);
memcpy(data, value, len);
return *this;
}
int MString::write(char ch) {
setSize(length + 1);