jstring changes
This commit is contained in:
1 parent
8f8c14d7b2
commit
f39bdc98f6
9 files changed
+92
-19
No files matched your search
+34
-10
@@ -74,15 +74,15 @@ namespace coreutils {
|
||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) == 0);
|
||||
}
|
||||
|
||||
bool ZString::operator==(std::string value) {
|
||||
if(value.length() != length)
|
||||
return false;
|
||||
return (strncmp(data, value.c_str(), length) == 0);
|
||||
}
|
||||
// bool ZString::operator==(std::string value) {
|
||||
// if(value.length() != length)
|
||||
// return false;
|
||||
// return (strncmp(data, value.c_str(), length) == 0);
|
||||
// }
|
||||
|
||||
bool ZString::operator==(const char *valuex) const {
|
||||
return (strncmp(data, valuex, 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())
|
||||
@@ -205,11 +205,35 @@ namespace coreutils {
|
||||
++cursor;
|
||||
return ZString(start, cursor - start);
|
||||
}
|
||||
|
||||
|
||||
ZString ZString::getTokenExclude(std::string exclude) {
|
||||
return getTokenExclude(exclude.c_str());
|
||||
}
|
||||
|
||||
ZString ZString::getContainer() {
|
||||
char term = *cursor == '"' ? '"': *cursor == '(' ? ')': *cursor == '[' ? ']': *cursor == '{' ? '}': 0;
|
||||
if(!term)
|
||||
return ZString();
|
||||
char *start = cursor;
|
||||
char nest = *cursor;
|
||||
char *end = cursor + length;
|
||||
int level = 0;
|
||||
++cursor;
|
||||
while(cursor != end) {
|
||||
if(*cursor == term) {
|
||||
if(!level) {
|
||||
++cursor;
|
||||
return ZString(start, cursor - start);
|
||||
}
|
||||
--level;
|
||||
} else if(*cursor == nest) {
|
||||
++level;
|
||||
}
|
||||
++cursor;
|
||||
}
|
||||
return ZString();
|
||||
}
|
||||
|
||||
ZString &ZString::operator[](int index) {
|
||||
return list[index];
|
||||
}
|
||||
@@ -227,7 +251,7 @@ namespace coreutils {
|
||||
return false;
|
||||
return strncmp(data, value, length) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool ZString::equals(char *value) {
|
||||
if (strlen(value) != length)
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user