Added startsWithDouble() method on ZString.
This commit is contained in:
parent
0db4be8a99
commit
39fd88cad9
@ -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();
|
||||
|
16
ZString.h
16
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:
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user