diff --git a/ZString.cpp b/ZString.cpp index 99074b9..e7ac35e 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -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(); diff --git a/ZString.h b/ZString.h index 330e5a2..5ec2844 100644 --- a/ZString.h +++ b/ZString.h @@ -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: diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index 16257e7..904bacb 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -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; + }