From 2bb04c64ea5a4047e0671bb8128310e869103876 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 16 Jul 2021 15:58:40 +0200 Subject: [PATCH] Use std::string_view::value_type in BufferSearch --- io/buffersearch.cpp | 2 +- io/buffersearch.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/io/buffersearch.cpp b/io/buffersearch.cpp index cdb5db6..38ac2b9 100644 --- a/io/buffersearch.cpp +++ b/io/buffersearch.cpp @@ -24,7 +24,7 @@ namespace CppUtilities { /*! * \brief Processes the specified \a buffer. Invokes the callback according to the remarks mentioned in the class documentation. */ -void BufferSearch::operator()(const char *buffer, std::size_t bufferSize) +void BufferSearch::operator()(const std::string_view::value_type *buffer, std::size_t bufferSize) { if (m_hasResult || (!m_giveUpTerm.empty() && m_giveUpTermIterator == m_giveUpTerm.end())) { return; diff --git a/io/buffersearch.h b/io/buffersearch.h index 97da6b5..427ffe4 100644 --- a/io/buffersearch.h +++ b/io/buffersearch.h @@ -17,8 +17,9 @@ public: using CallbackType = std::function; BufferSearch(std::string_view searchTerm, std::string_view terminationChars, std::string_view giveUpTerm, CallbackType &&callback); void operator()(std::string_view buffer); - void operator()(const char *buffer, std::size_t bufferSize); - template void operator()(std::shared_ptr> buffer, std::size_t bufferSize); + void operator()(const std::string_view::value_type *buffer, std::size_t bufferSize); + template + void operator()(std::shared_ptr> buffer, std::size_t bufferSize); void reset(); private: @@ -62,7 +63,7 @@ inline void BufferSearch::operator()(std::string_view buffer) * \brief Processes the specified \a buffer which is a shared array with fixed \tp bufferCapacity. Invokes the callback according to the remarks mentioned in the class documentation. */ template -inline void BufferSearch::operator()(std::shared_ptr> buffer, std::size_t bufferSize) +inline void BufferSearch::operator()(std::shared_ptr> buffer, std::size_t bufferSize) { (*this)(buffer->data(), bufferSize); }