From 3eb1f5954a24f7bb260ea0fa84175e02052d0b4d Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Wed, 30 Oct 2024 08:36:30 -0700 Subject: [PATCH] Modified ifNext to only take the ZString parameter and let C++ do the conversions. --- File.cpp | 8 ++------ File.h | 5 ++--- ZString.cpp | 18 +++++++++--------- ZString.h | 4 ++-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/File.cpp b/File.cpp index 1d5e6f5..962be11 100644 --- a/File.cpp +++ b/File.cpp @@ -9,15 +9,11 @@ namespace coreutils { -// File::File(std::string fileName, int mode, int authority) { -// open(fileName, mode, authority); -// } - File::File(coreutils::ZString fileName, int mode, int authority) { - open(fileName.str(), mode, authority); + open(fileName, mode, authority); } - void File::open(std::string fileName, int mode, int authority) { + void File::open(coreutils::ZString fileName, int mode, int authority) { this->fileName = fileName; diff --git a/File.h b/File.h index 09d2db3..fe8e471 100644 --- a/File.h +++ b/File.h @@ -16,7 +16,6 @@ namespace coreutils { class File { public: -// File(std::string fileName, int mode, int authority); File(ZString fileName, int mode = O_RDONLY, int authority = 0664); ~File(); void setBufferSize(size_t size); @@ -30,10 +29,10 @@ namespace coreutils { size_t size; bool eof(); - std::string fileName; + coreutils::ZString fileName; private: - void open(std::string fileName, int mode, int authority); + void open(coreutils::ZString fileName, int mode, int authority); int fd; coreutils::ZString zstring; bool mEof = false; diff --git a/ZString.cpp b/ZString.cpp index b4b2496..b56d34c 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -377,16 +377,16 @@ namespace coreutils { return string == std::string(data, length); } - bool ZString::ifNext(const char *value) { - if (((data + length) - cursor) < strlen(value)) - return false; - bool test = (strncmp(cursor, value, strlen(value)) == 0); - if (test) - cursor += strlen(value); - return test; - } +// bool ZString::ifNext(const char *value) { +// if (((data + length) - cursor) < strlen(value)/) +// return false; +// bool test = (strncmp(cursor, value, strlen(value)) == 0); +// if (test) +// cursor += strlen(value); +// return test; +// } - bool ZString::ifNext(ZString &value) { + bool ZString::ifNext(ZString value) { if (((data + length) - cursor) < value.getLength()) return false; bool test = (strncmp(cursor, value.getCursor(), value.getLength()) == 0); diff --git a/ZString.h b/ZString.h index c332e4a..570c6a1 100644 --- a/ZString.h +++ b/ZString.h @@ -289,13 +289,13 @@ namespace coreutils { /// the cursor position is equal to the value provided. /// - bool ifNext(const char *value); +// bool ifNext(const char *value); /// /// /// - bool ifNext(ZString &value); + bool ifNext(ZString value); /// ///