From 5715a041d2791d36128cc840c81626030091157b Mon Sep 17 00:00:00 2001 From: Jessica James Date: Sun, 28 Nov 2021 17:21:29 -0600 Subject: [PATCH] Remove getToken, gotoToken, tokenCount --- src/include/Jupiter/Readable_String.h | 37 ------ src/include/Jupiter/Readable_String_Imp.h | 144 --------------------- src/include/Jupiter/Reference_String.h | 42 ------ src/include/Jupiter/Reference_String_Imp.h | 32 ----- src/include/Jupiter/String.hpp | 84 ------------ src/include/Jupiter/String_Imp.h | 80 ------------ 6 files changed, 419 deletions(-) diff --git a/src/include/Jupiter/Readable_String.h b/src/include/Jupiter/Readable_String.h index 2d6b8f0..0265465 100644 --- a/src/include/Jupiter/Readable_String.h +++ b/src/include/Jupiter/Readable_String.h @@ -192,17 +192,6 @@ namespace Jupiter */ unsigned int wordCount(const T *whitespace) const; - /** - * @brief Counts the number of token-deliminated strings in the string. - * - * @param token Token to scan for. - * @return Number of token-deliminated strings in the string. - */ - size_t tokenCount(const T &token) const; - size_t tokenCount(const Readable_String &token) const; - size_t tokenCount(const std::basic_string &token) const; - size_t tokenCount(const T *token, size_t tokenLength) const; - /** * @brief Interprets the string as a bool. * @@ -262,19 +251,6 @@ namespace Jupiter template class R> static R getWord(const Jupiter::Readable_String &in, size_t pos, const T *whitespace); template class R> static R getWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Copies a the elements between two tokens from an input string and returns it in an output type. - * - * @param R Type to return. Must be a subclass of String_Type. - * - * @param in String to get a partial copy of. - * @param pos Index of the token to copy. - * @param token Token to scan for. - * @return Copy of the token at the specified index on success, an empty string otherwise. - */ - template class R> static R getToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - template class R> static R getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Copies a part of an input string starting at a specified "word" and returns it in an output type. * @@ -288,19 +264,6 @@ namespace Jupiter template class R> static R gotoWord(const Jupiter::Readable_String &in, size_t pos, const T *whitespace); template class R> static R gotoWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Copies a part of an input string starting at a specified token and returns it in an output type. - * - * @param R Type to return. Must be a subclass of String_Type. - * - * @param in String to get a partial copy of. - * @param pos Index of the word to start copying from. - * @param token Token to scan for. - * @return Copy of the string starting at the specified word on success, an empty string otherwise. - */ - template class R> static R gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - template class R> static R gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Destructor for the Readable_String class. */ diff --git a/src/include/Jupiter/Readable_String_Imp.h b/src/include/Jupiter/Readable_String_Imp.h index 4ef6cae..57128a5 100644 --- a/src/include/Jupiter/Readable_String_Imp.h +++ b/src/include/Jupiter/Readable_String_Imp.h @@ -888,60 +888,6 @@ template unsigned int Jupiter::Readable_String::wordCount(const T return result; } -// tokenCount() - -template size_t Jupiter::Readable_String::tokenCount(const T &token) const -{ - if (this->size() == 0) - return 0; - - size_t total = 1; - for (size_t i = 0; i != this->size(); i++) - if (this->get(i) == token) - total++; - return total; -} - -template size_t Jupiter::Readable_String::tokenCount(const Jupiter::Readable_String &token) const -{ - return this->tokenCount(token.ptr(), token.size()); -} - -template size_t Jupiter::Readable_String::tokenCount(const std::basic_string &token) const -{ - return this->tokenCount(token.data(), token.size()); -} - -template size_t Jupiter::Readable_String::tokenCount(const T *token, size_t tokenLength) const -{ - if (tokenLength == 1) - return this->tokenCount(*token); - if (tokenLength == 0 || tokenLength > this->size()) - return 0; - if (tokenLength == this->size()) - return this->equals(token, tokenLength) ? 1 : 0; - - size_t total = 1; - for (size_t i = 0, j; i != this->size() - tokenLength + 1; i++) - { - Jupiter_Readable_String_tokenCount_skip_increment: - j = 0; - while (this->get(i + j) == token[j]) - { - if (++j == tokenLength) - { - i += j; - total++; - if (i >= this->size() - tokenLength + 1) - return total; - - goto Jupiter_Readable_String_tokenCount_skip_increment; - } - } - } - return total; -} - // as template<> bool inline Jupiter::Readable_String::asBool() const @@ -1131,59 +1077,6 @@ template template class R> R Jupiter::Readable return R::substring(in, 0, pos); } -// getToken - -template template class R> R Jupiter::Readable_String::getToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - size_t x, y; - for (x = 0; x != in.size() && pos != 0; x++) - if (in.get(x) == token) - pos--; - for (y = x; y != in.size() && in.get(y) != token; y++); - return R::substring(in, x, y - x); -} - -template template class R> R Jupiter::Readable_String::getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - if (token.isEmpty()) - return R(in); - if (token.size() == 1) - return Jupiter::Readable_String::getToken(in, pos, token.get(0)); - if (pos == 0) - return R::substring(in, 0, in.find(token)); - - size_t i, j; - for (i = 0; i != in.size(); i++) - { - Jupiter_Readable_String_getToken_skip_increment: - j = 0; - while (in.get(i + j) == token.get(j)) - { - if (++j == token.size()) - { - i += j; - if (--pos == 0) - { - size_t k; - for (j = i; j != in.size(); j++) - { - k = 0; - while (in.get(j + k) == token.get(k)) - if (++k == token.size()) - return R::substring(in, i, j - i); - } - return R::substring(in, i); - } - else - goto Jupiter_Readable_String_getToken_skip_increment; - break; - } - } - } - - return R(); -} - // gotoWord template template class R> R Jupiter::Readable_String::gotoWord(const Jupiter::Readable_String &in, size_t pos, const T *whitespace) @@ -1234,43 +1127,6 @@ template template class R> R Jupiter::Readable return R::substring(in, x); } -// gotoToken - -template template class R> R Jupiter::Readable_String::gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - size_t i; - for (i = 0; i != in.size() && pos != 0; i++) - if (in.get(i) == token) - pos--; - - return R::substring(in, i); -} - -template template class R> R Jupiter::Readable_String::gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - if (pos == 0 || token.isEmpty()) - return R(in); - if (token.size() == 1) - return Jupiter::Readable_String::gotoToken(in, pos, token.get(0)); - - size_t i, j; - for (i = 0; i != in.size(); i++) - { - j = 0; - while (in.get(i + j) == token.get(j)) - { - if (++j == token.size()) - { - if (--pos == 0) - return R::substring(in, i + token.size()); - break; - } - } - } - - return R(); -} - // Jupiter::DataBuffer specialization template<> struct _Jupiter_DataBuffer_partial_specialization_impl diff --git a/src/include/Jupiter/Reference_String.h b/src/include/Jupiter/Reference_String.h index 942036e..513654f 100644 --- a/src/include/Jupiter/Reference_String.h +++ b/src/include/Jupiter/Reference_String.h @@ -170,27 +170,6 @@ namespace Jupiter */ static Reference_String getWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - Reference_String getToken(size_t pos, const T &token) const; - Reference_String getToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of an input string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static Reference_String getToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static Reference_String getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Creates a partial copy of the string, based on a set of tokens. * @@ -220,27 +199,6 @@ namespace Jupiter */ static Reference_String gotoWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - Reference_String gotoToken(size_t pos, const T &token) const; - Reference_String gotoToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static Reference_String gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static Reference_String gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** Mutative operators */ inline Reference_String& operator-=(size_t right) { this->truncate(right); return *this; }; inline Reference_String& operator=(const Readable_String &right) { std::basic_string_view::operator=({right.ptr(), right.size()}); return *this; }; diff --git a/src/include/Jupiter/Reference_String_Imp.h b/src/include/Jupiter/Reference_String_Imp.h index c6460fa..4220b70 100644 --- a/src/include/Jupiter/Reference_String_Imp.h +++ b/src/include/Jupiter/Reference_String_Imp.h @@ -154,22 +154,6 @@ template Jupiter::Reference_String Jupiter::Reference_String:: return Jupiter::Readable_String::template getWord(in, pos, whitespace); } -template Jupiter::Reference_String Jupiter::Reference_String::getToken(size_t pos, const T &token) const { - return Jupiter::Reference_String::getToken(*this, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::getToken(size_t pos, const Jupiter::Readable_String &token) const { - return Jupiter::Reference_String::getToken(*this, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::getToken(const Jupiter::Readable_String &in, size_t pos, const T &token) { - return Jupiter::Readable_String::template getToken(in, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) { - return Jupiter::Readable_String::template getToken(in, pos, token); -} - template Jupiter::Reference_String Jupiter::Reference_String::gotoWord(size_t pos, const T *whitespace) const { return Jupiter::Reference_String::gotoWord(*this, pos, whitespace); } @@ -182,22 +166,6 @@ template Jupiter::Reference_String Jupiter::Reference_String:: return Jupiter::Readable_String::template gotoWord(in, pos, whitespace); } -template Jupiter::Reference_String Jupiter::Reference_String::gotoToken(size_t pos, const T &token) const { - return Jupiter::Reference_String::gotoToken(*this, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::gotoToken(size_t pos, const Jupiter::Readable_String &token) const { - return Jupiter::Reference_String::gotoToken(*this, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token) { - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - -template Jupiter::Reference_String Jupiter::Reference_String::gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) { - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - template const Jupiter::Reference_String Jupiter::Reference_String::empty = Jupiter::Reference_String(); // Jupiter::DataBuffer specialization diff --git a/src/include/Jupiter/String.hpp b/src/include/Jupiter/String.hpp index d7deb03..04d939c 100644 --- a/src/include/Jupiter/String.hpp +++ b/src/include/Jupiter/String.hpp @@ -144,27 +144,6 @@ namespace Jupiter */ static String_Strict getWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - String_Strict getToken(size_t pos, const T &token) const; - String_Strict getToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of an input string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static String_Strict getToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static String_Strict getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Creates a partial copy of the string, based on a set of tokens. * @@ -184,27 +163,6 @@ namespace Jupiter */ static String_Strict gotoWord(const Jupiter::Readable_String &in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - String_Strict gotoToken(size_t pos, const T &token) const; - String_Strict gotoToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static String_Strict gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static String_Strict gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** Default Constructor */ String_Strict(); @@ -379,27 +337,6 @@ namespace Jupiter */ static String_Loose getWord(const T *in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - String_Loose getToken(size_t pos, const T &token) const; - String_Loose getToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of an input string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position of the token in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static String_Loose getToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static String_Loose getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Creates a partial copy of the string, based on a set of tokens. * @@ -419,27 +356,6 @@ namespace Jupiter */ static String_Loose gotoWord(const Jupiter::Readable_String &in, size_t pos, const T *whitespace); - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - String_Loose gotoToken(size_t pos, const T &token) const; - String_Loose gotoToken(size_t pos, const Jupiter::Readable_String &token) const; - - /** - * @brief Creates a partial copy of the string, based on a token. - * - * @param in String to get a partial copy of. - * @param pos Position in the string to start copying from. - * @param token Token to scan for. - * @return String containing a partial copy of the original string. - */ - static String_Loose gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token); - static String_Loose gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); - /** * @brief Sets the internal buffer to be at least large enough to old a specified number of elements. * Note: This does nothing if len is less than the string's current length. diff --git a/src/include/Jupiter/String_Imp.h b/src/include/Jupiter/String_Imp.h index dafed15..3422751 100644 --- a/src/include/Jupiter/String_Imp.h +++ b/src/include/Jupiter/String_Imp.h @@ -298,26 +298,6 @@ template Jupiter::String_Strict Jupiter::String_Strict::getWor return Jupiter::Readable_String::template getWord(in, pos, whitespace); } -template Jupiter::String_Strict Jupiter::String_Strict::getToken(size_t pos, const T &token) const -{ - return Jupiter::String_Strict::getToken(*this, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::getToken(size_t pos, const Jupiter::Readable_String &token) const -{ - return Jupiter::String_Strict::getToken(*this, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::getToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - return Jupiter::Readable_String::template getToken(in, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - return Jupiter::Readable_String::template getToken(in, pos, token); -} - template Jupiter::String_Strict Jupiter::String_Strict::gotoWord(size_t pos, const T *whitespace) const { return Jupiter::String_Strict::gotoWord(*this, pos, whitespace); @@ -328,26 +308,6 @@ template Jupiter::String_Strict Jupiter::String_Strict::gotoWo return Jupiter::Readable_String::template gotoWord(in, pos, whitespace); } -template Jupiter::String_Strict Jupiter::String_Strict::gotoToken(size_t pos, const T &token) const -{ - return Jupiter::String_Strict::gotoToken(*this, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::gotoToken(size_t pos, const Jupiter::Readable_String &token) const -{ - return Jupiter::String_Strict::gotoToken(*this, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - -template Jupiter::String_Strict Jupiter::String_Strict::gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - // Operators template inline Jupiter::String_Strict Jupiter::String_Strict::operator+(const T &rhs) const @@ -752,26 +712,6 @@ template Jupiter::String_Loose Jupiter::String_Loose::getWord( return Jupiter::Readable_String::template getWord(in, pos, whitespace); } -template Jupiter::String_Loose Jupiter::String_Loose::getToken(size_t pos, const T &token) const -{ - return Jupiter::String_Loose::getToken(*this, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::getToken(size_t pos, const Jupiter::Readable_String &token) const -{ - return Jupiter::String_Loose::getToken(*this, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::getToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - return Jupiter::Readable_String::template getToken(in, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::getToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - return Jupiter::Readable_String::template getToken(in, pos, token); -} - template Jupiter::String_Loose Jupiter::String_Loose::gotoWord(size_t pos, const T *whitespace) const { return Jupiter::String_Loose::gotoWord(*this, pos, whitespace); @@ -782,26 +722,6 @@ template Jupiter::String_Loose Jupiter::String_Loose::gotoWord return Jupiter::Readable_String::template gotoWord(in, pos, whitespace); } -template Jupiter::String_Loose Jupiter::String_Loose::gotoToken(size_t pos, const T &token) const -{ - return Jupiter::String_Loose::gotoToken(*this, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::gotoToken(size_t pos, const Jupiter::Readable_String &token) const -{ - return Jupiter::String_Loose::gotoToken(*this, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token) -{ - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - -template Jupiter::String_Loose Jupiter::String_Loose::gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token) -{ - return Jupiter::Readable_String::template gotoToken(in, pos, token); -} - // Operators template inline Jupiter::String_Loose Jupiter::String_Loose::operator+(const T &rhs) const