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;
|
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) {
|
int ZString::compare(ZString zstring) {
|
||||||
char *end1 = data + length;
|
char *end1 = data + length;
|
||||||
char *end2 = zstring.getData() + zstring.getLength();
|
char *end2 = zstring.getData() + zstring.getLength();
|
||||||
|
14
ZString.h
14
ZString.h
@ -252,6 +252,12 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
|
bool startsWithDouble();
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
int compare(ZString zstring);
|
int compare(ZString zstring);
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -393,8 +399,16 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool ifCRLF();
|
bool ifCRLF();
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
void nextChar();
|
void nextChar();
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
bool boolValue();
|
bool boolValue();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -82,4 +82,9 @@ int main(int argc, char **argv) {
|
|||||||
coreutils::ZString test13("12");
|
coreutils::ZString test13("12");
|
||||||
std::cout << (test12 < test13) << ":" << (test13 < test12) << std::endl;
|
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