Merge up with master branch.
This commit is contained in:
commit
f8bc2df133
23
MString.cpp
23
MString.cpp
@ -36,6 +36,12 @@ namespace coreutils {
|
|||||||
// Log(LOG_DEBUG_2) << "MString Copy Constructor: ";
|
// 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) {
|
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());
|
||||||
@ -61,6 +67,15 @@ namespace coreutils {
|
|||||||
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) {
|
MString& MString::operator=(const char *value) {
|
||||||
int len = strlen(value);
|
int len = strlen(value);
|
||||||
setSize(len);
|
setSize(len);
|
||||||
@ -106,17 +121,17 @@ namespace coreutils {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MString::write(char ch) {
|
MString& MString::write(char ch) {
|
||||||
setSize(length + 1);
|
setSize(length + 1);
|
||||||
*(data + length - 1) = ch;
|
*(data + length - 1) = ch;
|
||||||
return 1;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MString::write(ZString &value) {
|
MString& MString::write(ZString &value) {
|
||||||
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 value.getLength();
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MString::setSize(int size) {
|
void MString::setSize(int size) {
|
||||||
|
20
MString.h
20
MString.h
@ -42,13 +42,19 @@ namespace coreutils {
|
|||||||
/// Consructor providing a copy of a ZString.
|
/// Consructor providing a copy of a ZString.
|
||||||
///
|
///
|
||||||
|
|
||||||
MString(const MString &zstring);
|
MString(ZString &zstring);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Consructor providing a copy of a ZString.
|
||||||
|
///
|
||||||
|
|
||||||
|
MString(const MString &mstring);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Consructor from a string.
|
/// Consructor from a string.
|
||||||
///
|
///
|
||||||
|
|
||||||
MString(std::string string);
|
MString(std::string data);
|
||||||
|
|
||||||
~MString();
|
~MString();
|
||||||
|
|
||||||
@ -62,6 +68,12 @@ namespace coreutils {
|
|||||||
/// Assignment operator will copy data to backing store.
|
/// Assignment operator will copy data to backing store.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
MString& operator=(coreutils::MString& data);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Assignment operator will copy data to backing store.
|
||||||
|
///
|
||||||
|
|
||||||
MString& operator=(const char *data);
|
MString& operator=(const char *data);
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -86,13 +98,13 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
int write(char ch);
|
MString& write(char ch);
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
int write(ZString &value);
|
MString& write(ZString &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
|
@ -7,7 +7,7 @@ namespace coreutils {
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const ZString &zstring) {
|
std::ostream &operator<<(std::ostream &os, const ZString &zstring) {
|
||||||
for (char *ix = zstring.data; ix < (zstring.data + zstring.length); ++ix)
|
for (char *ix = zstring.data; ix < (zstring.data + zstring.length); ++ix)
|
||||||
os << *ix;
|
os << *ix;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +21,11 @@ namespace coreutils {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream &operator+(std::ostream &os, const char *value) {
|
||||||
|
os << value;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
ZString::ZString() {
|
ZString::ZString() {
|
||||||
data = NULL;
|
data = NULL;
|
||||||
length = 0;
|
length = 0;
|
||||||
|
@ -81,6 +81,7 @@ namespace coreutils {
|
|||||||
friend std::ostream& operator<<(std::ostream& os, const ZString& zstring);
|
friend std::ostream& operator<<(std::ostream& os, const ZString& zstring);
|
||||||
friend std::ostream& operator<<(std::ostream& os, const std::string& string);
|
friend std::ostream& operator<<(std::ostream& os, const std::string& string);
|
||||||
friend std::ostream& operator+(std::ostream& os, const ZString& zstring);
|
friend std::ostream& operator+(std::ostream& os, const ZString& zstring);
|
||||||
|
friend std::ostream& operator+(std::ostream& os, const char *value);
|
||||||
|
|
||||||
bool operator<(const ZString &valuex) const;
|
bool operator<(const ZString &valuex) const;
|
||||||
bool operator>(const ZString &valuex) const;
|
bool operator>(const ZString &valuex) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user