ZString modifications.

This commit is contained in:
barant committed 2021-07-31 11:15:07 -07:00
1 parent ff2c2b7432
commit 78cb2fdd10
2 files changed
+38 -5

No files matched your search

+22 -4
View File
@@ -8,6 +8,16 @@ namespace coreutils {
return os;
}
std::ostream& operator<<(std::ostream& os, const std::string& string) {
os << string;
return os;
}
std::ostream& operator+(std::ostream& os, const ZString& zstring) {
os << zstring;
return os;
}
ZString::ZString() {
data = NULL;
length = 0;
@@ -41,12 +51,16 @@ namespace coreutils {
std::string ZString::str(int len) {
return std::string(data, len);
}
std::vector<ZString> ZString::split(std::string &delimiter, size_t maxSize) {
return split(ZString(delimiter.c_str()), maxSize);
}
std::vector<ZString> ZString::split(ZString delimiter, size_t maxSize) {
list.clear();
if(length == 0) {
list.push_back(ZString((char *)""));
return list;
list.push_back(ZString((char *)""));
return list;
}
char *end = data + length;
@@ -94,9 +108,13 @@ namespace coreutils {
bool ZString::equals(ZString zstring) {
if(zstring.getLength() != getLength())
return false;
return false;
return strncmp(data, zstring.getData(), getLength()) == 0;
}
bool ZString::equals(std::string string) {
return strncmp(string.c_str(), getData(), getLength()) == 0;
}
bool ZString::ifNext(char *value) {
bool test = (strncmp(cursor, value, strlen(value)) == 0);