Added char * << to MString for string assignment.
This commit is contained in:
1 parent
287933f9ce
commit
d8df083d6b
5 files changed
+73
-1
No files matched your search
+21
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user