Added startsWithDouble() method on ZString.

This commit is contained in:
Brad Arant 2024-08-01 15:03:28 -07:00
parent 0db4be8a99
commit 39fd88cad9
3 changed files with 29 additions and 1 deletions

View File

@ -267,6 +267,15 @@ namespace coreutils {
return strncmp(cursor, value, strlen(value)) == 0;
}
bool ZString::startsWithDouble() {
push();
char *tempc = cursor;
double temp = strtod(cursor, &cursor);
int diff = cursor - tempc;
pop();
return diff != 0;
}
int ZString::compare(ZString zstring) {
char *end1 = data + length;
char *end2 = zstring.getData() + zstring.getLength();

View File

@ -248,6 +248,12 @@ namespace coreutils {
bool startsWith(const char *value);
///
///
///
bool startsWithDouble();
///
///
///
@ -392,9 +398,17 @@ namespace coreutils {
///
bool ifCRLF();
///
///
///
void nextChar();
///
///
///
bool boolValue();
protected:

View File

@ -81,5 +81,10 @@ int main(int argc, char **argv) {
coreutils::ZString test12("1");
coreutils::ZString test13("12");
std::cout << (test12 < test13) << ":" << (test13 < test12) << std::endl;
coreutils::ZString test14("25.5");
coreutils::ZString test15("xyx");
std::cout << test14.startsWithDouble() << ":" << test15.startsWithDouble() << std::endl;
}