From f1337c682a4a440401e2f9038996bf7a730d29fb Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Thu, 31 Oct 2024 15:48:13 -0700 Subject: [PATCH] Added ability for ifNextInclude and changed data type on isCaracter to ZString. --- ZString.cpp | 14 ++++++++++---- ZString.h | 9 ++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ZString.cpp b/ZString.cpp index b56d34c..25d6d9c 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -268,15 +268,21 @@ namespace coreutils { return list; } - bool ZString::isCharacter(char ch, const char *string) { - int len = strlen(string); - for (int ix = 0; ix < len; ++ix) { - if (ch == string[ix]) + bool ZString::isCharacter(char ch, ZString include) { + for (int ix = 0; ix < include.getLength(); ++ix) { + if (ch == include.charAt(ix)) return true; } return false; } + bool ZString::ifNextInclude(ZString include) { + if((cursor <= (data + length)) && isCharacter(*cursor, include)) + return true; + return false; + } + + ZString ZString::getTokenInclude(const char *include) { char *start = cursor; while ((cursor <= (data + length)) && isCharacter(*cursor, include)) diff --git a/ZString.h b/ZString.h index 570c6a1..9df6061 100644 --- a/ZString.h +++ b/ZString.h @@ -201,6 +201,13 @@ namespace coreutils { /// std::vector &split(std::string delimiter, size_t maxSize = 0); + + /// + /// If ZString cursor is currently pointing to a character in the include + /// string then return true. + /// + + bool ifNextInclude(ZString include); /// /// Use getTokenInclude with a list of character to allow the forwarding @@ -426,7 +433,7 @@ namespace coreutils { private: std::stack stack; - bool isCharacter(char ch, const char *string); + bool isCharacter(char ch, ZString include); }; }