Added lineIsWhitespace function.
This commit is contained in:
parent
81829f15f5
commit
d5bdfe8ca3
13
ZString.cpp
13
ZString.cpp
@ -311,6 +311,19 @@ namespace coreutils {
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZString::lineIsWhitespace() {
|
||||||
|
char *end = data + length;
|
||||||
|
char *temp = cursor;
|
||||||
|
while(temp < end) {
|
||||||
|
if(*temp == '\n')
|
||||||
|
return true;
|
||||||
|
if((*temp != ' ') && (*temp != '\t'))
|
||||||
|
return false;
|
||||||
|
++temp;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ZString ZString::goeol() {
|
ZString ZString::goeol() {
|
||||||
bool set = false;
|
bool set = false;
|
||||||
char *temp = cursor;
|
char *temp = cursor;
|
||||||
|
@ -298,6 +298,12 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|
||||||
|
bool lineIsWhitespace();
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
ZString goeol();
|
ZString goeol();
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -64,4 +64,11 @@ int main(int argc, char **argv) {
|
|||||||
coreutils::ZString test6 = test5.getTokenExclude("\n");
|
coreutils::ZString test6 = test5.getTokenExclude("\n");
|
||||||
std::cout << test6 << std::endl;
|
std::cout << test6 << std::endl;
|
||||||
|
|
||||||
|
coreutils::ZString test7 = "this is a line\n \nthis is another line\n ";
|
||||||
|
std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl;
|
||||||
|
std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl;
|
||||||
|
std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl;
|
||||||
|
std::cout << test7.lineIsWhitespace() << test7.goeol() << std::endl;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user