Added substring capability to ZString.

This commit is contained in:
Brad Arant committed 2022-08-07 17:21:37 -07:00
1 parent 36348aba17
commit d0d5172afa
5 files changed
+69 -6

No files matched your search

+19 -3
View File
@@ -68,6 +68,10 @@ namespace coreutils {
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) == 0);
}
bool ZString::operator==(const char *valuex) const {
return (strncmp(data, valuex, length) == 0);
}
bool ZString::operator!=(const ZString &valuex) const {
// if(length != valuex.getLength())
// return false;
@@ -75,9 +79,8 @@ namespace coreutils {
}
bool ZString::operator!=(const char *valuex) const {
size_t len = strlen(valuex);
if(length != len)
return true;
if(strlen(valuex) != length)
return true;
return (strncmp(data, valuex, length) != 0);
}
@@ -124,6 +127,19 @@ namespace coreutils {
cdata[length] = '\0';
return cdata;
}
ZString ZString::substring(int start) {
char *end = data + length;
char *startChar = data + start;
if(startChar < end) {
return ZString(startChar, end - startChar);
}
return ZString();
}
ZString ZString::substring(int start, int len) {
return ZString();
}
std::vector<ZString> &ZString::split(std::string delimiter, size_t maxSize) {
coreutils::ZString zDelimiter((char *)delimiter.c_str(), delimiter.size());