From d7ef47cd491504166bcb7829e1447f7e58b812c3 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Tue, 24 Sep 2024 11:14:58 -0700 Subject: [PATCH] Add trim to ZString. --- ZString.cpp | 5 +++++ ZString.h | 8 +++++++- testing/zstring_test.cpp | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ZString.cpp b/ZString.cpp index e6f1445..219d726 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -397,6 +397,11 @@ namespace coreutils { return ZString(temp, tempend - temp); } + ZString ZString::trim() { + skipWhitespace(); + return unparsed(); + } + int ZString::find(ZString comparator) { int count = 0; char *temp = cursor; diff --git a/ZString.h b/ZString.h index 5ec2844..0a1b899 100644 --- a/ZString.h +++ b/ZString.h @@ -321,7 +321,13 @@ namespace coreutils { /// ZString goeol(); - + + /// + /// + /// + + ZString trim(); + /// /// Return a block of data as a ZString from the cursor location for /// the number of bytes specified by size. diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index 3e1d978..d9135a2 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -91,5 +91,8 @@ int main(int argc, char **argv) { std::cout << test16.substring(10, 4) << std::endl; std::cout << test16.substring(0, 7) << std::endl; std::cout << test16.substring(18, 20) << std::endl; + + coreutils::ZString test17(" hello there "); + std::cout << "[" << test17.trim() << "]" << std::endl; }