diff --git a/src/common/base/StringView.hpp b/src/common/base/StringView.hpp index 55622a6bf..26510d002 100644 --- a/src/common/base/StringView.hpp +++ b/src/common/base/StringView.hpp @@ -95,7 +95,7 @@ class WCDB_API UnsafeStringView { int compare(const UnsafeStringView& other) const; bool equal(const UnsafeStringView& other) const; - static constexpr size_t npos = -1; + static constexpr size_t npos = std::numeric_limits::max(); size_t find(const UnsafeStringView& other) const; #pragma mark - UnsafeStringView - Operations @@ -130,6 +130,9 @@ class WCDB_API UnsafeStringView { } }; + template + struct Convertible::value>> : public std::false_type {}; + template::value>::type> UnsafeStringView(const T& t) { diff --git a/src/common/core/config/Config.cpp b/src/common/core/config/Config.cpp index 782e17ceb..b569cad41 100644 --- a/src/common/core/config/Config.cpp +++ b/src/common/core/config/Config.cpp @@ -31,7 +31,7 @@ Config::~Config() = default; bool Config::uninvoke(InnerHandle *handle) { - WCDB_UNUSED(handle) + WCDB_UNUSED(handle); return true; } diff --git a/src/common/core/fts/tokenizer/PinyinTokenizer.cpp b/src/common/core/fts/tokenizer/PinyinTokenizer.cpp index 90cc07cbe..88f914610 100644 --- a/src/common/core/fts/tokenizer/PinyinTokenizer.cpp +++ b/src/common/core/fts/tokenizer/PinyinTokenizer.cpp @@ -75,7 +75,7 @@ void PinyinTokenizer::loadInput(const char *pText, int nText, int flags) int PinyinTokenizer::nextToken( const char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition) { - WCDB_UNUSED(iPosition) + WCDB_UNUSED(iPosition); if (m_flags & FTS5_TOKENIZE_QUERY || m_pinyinTokenArr.size() == m_pinyinTokenIndex) { while (true) { int ret = stepNextToken(); diff --git a/src/common/core/fts/tokenizer/TokenizerModule.cpp b/src/common/core/fts/tokenizer/TokenizerModule.cpp index 5d05aa594..c07afafd6 100644 --- a/src/common/core/fts/tokenizer/TokenizerModule.cpp +++ b/src/common/core/fts/tokenizer/TokenizerModule.cpp @@ -37,7 +37,9 @@ namespace WCDB { #pragma mark - AbstractFTS5Tokenizer AbstractFTSTokenizer::AbstractFTSTokenizer(const char *const *azArg, int nArg, void *pCtx){ - WCDB_UNUSED(pCtx) WCDB_UNUSED(azArg) WCDB_UNUSED(nArg) + WCDB_UNUSED(pCtx); + WCDB_UNUSED(azArg); + WCDB_UNUSED(nArg); } AbstractFTSTokenizer::~AbstractFTSTokenizer() diff --git a/src/common/platform/WCTFileManager.cpp b/src/common/platform/WCTFileManager.cpp index c8f41c6cb..d21076397 100644 --- a/src/common/platform/WCTFileManager.cpp +++ b/src/common/platform/WCTFileManager.cpp @@ -41,15 +41,15 @@ StringView FileManager::getTemporaryDirectory() bool FileManager::setFileProtection(const WCDB::UnsafeStringView &path, WCDB::FileProtection fileProtection) { - WCDB_UNUSED(path) - WCDB_UNUSED(fileProtection) + WCDB_UNUSED(path); + WCDB_UNUSED(fileProtection); return true; } Optional FileManager::getFileProtection(const WCDB::UnsafeStringView &path) { - WCDB_UNUSED(path) + WCDB_UNUSED(path); return WCDB::FileProtection::None; } diff --git a/src/common/platform/WCTOperationQueue.cpp b/src/common/platform/WCTOperationQueue.cpp index 16b720bf0..6510f4ba7 100644 --- a/src/common/platform/WCTOperationQueue.cpp +++ b/src/common/platform/WCTOperationQueue.cpp @@ -35,7 +35,7 @@ void *OperationQueueForMemory::registerNotificationWhenMemoryWarning() void OperationQueueForMemory::unregisterNotificationWhenMemoryWarning(void *observer) { - WCDB_UNUSED(observer) + WCDB_UNUSED(observer); } void OperationQueueForMemory::executeOperationWithAutoMemoryRelease(std::function operation) diff --git a/src/common/repair/basic/Crawlable.cpp b/src/common/repair/basic/Crawlable.cpp index 1cee8009a..d45cc6d83 100644 --- a/src/common/repair/basic/Crawlable.cpp +++ b/src/common/repair/basic/Crawlable.cpp @@ -160,7 +160,7 @@ void Crawlable::safeCrawl(int rootpageno, std::set &crawledInteriorPages, i void Crawlable::onCellCrawled(const Cell &cell) { - WCDB_UNUSED(cell) + WCDB_UNUSED(cell); } bool Crawlable::canCrawlPage(uint32_t pageno) @@ -171,8 +171,8 @@ bool Crawlable::canCrawlPage(uint32_t pageno) bool Crawlable::willCrawlPage(const Page &page, int height) { - WCDB_UNUSED(page) - WCDB_UNUSED(height) + WCDB_UNUSED(page); + WCDB_UNUSED(height); return true; } diff --git a/src/common/repair/crawl/SequenceCrawler.cpp b/src/common/repair/crawl/SequenceCrawler.cpp index c2759700c..1c665e4e8 100644 --- a/src/common/repair/crawl/SequenceCrawler.cpp +++ b/src/common/repair/crawl/SequenceCrawler.cpp @@ -87,7 +87,7 @@ void SequenceCrawler::onCrawlerError() bool SequenceCrawler::willCrawlPage(const Page &page, int height) { - WCDB_UNUSED(height) + WCDB_UNUSED(height); m_delegate->onSequencePageCrawled(page); return true; } diff --git a/src/common/repair/factory/Factory.cpp b/src/common/repair/factory/Factory.cpp index 4e81b77b4..5b0439763 100644 --- a/src/common/repair/factory/Factory.cpp +++ b/src/common/repair/factory/Factory.cpp @@ -172,7 +172,7 @@ bool Factory::removeDirectoryIfEmpty() const bool succeed = FileManager::enumerateDirectory( directory, [&canRemove](const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool { - WCDB_UNUSED(root) + WCDB_UNUSED(root); if (subpath == restoreDirectoryName || !isDirectory) { return true; } diff --git a/src/common/repair/factory/FactoryRetriever.cpp b/src/common/repair/factory/FactoryRetriever.cpp index 9907fa486..ff85e66a8 100644 --- a/src/common/repair/factory/FactoryRetriever.cpp +++ b/src/common/repair/factory/FactoryRetriever.cpp @@ -385,7 +385,7 @@ bool FactoryRetriever::increaseProgress(const UnsafeStringView &databasePath, double progress, double increment) { - WCDB_UNUSED(progress) + WCDB_UNUSED(progress); if (useMaterial) { increment *= 0.5; } diff --git a/src/common/repair/mechanic/Backup.cpp b/src/common/repair/mechanic/Backup.cpp index 77aef49fc..b68c669fa 100644 --- a/src/common/repair/mechanic/Backup.cpp +++ b/src/common/repair/mechanic/Backup.cpp @@ -473,7 +473,7 @@ bool Backup::willCrawlPage(const Page &page, int height) markAsInterrupted(); return false; } - WCDB_UNUSED(height) + WCDB_UNUSED(height); switch (page.getType()) { case Page::Type::InteriorTable: return true; @@ -508,7 +508,7 @@ void Backup::onMasterPageCrawled(const Page &page) void Backup::onMasterCellCrawled(const Cell &cell, const MasterItem &master) { - WCDB_UNUSED(cell) + WCDB_UNUSED(cell); if (master.name == Syntax::sequenceTable) { m_material.info.seqTableRootPage = master.rootpage; SequenceCrawler crawler; @@ -554,7 +554,7 @@ void Backup::onSequencePageCrawled(const Page &page) void Backup::onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence) { - WCDB_UNUSED(cell) + WCDB_UNUSED(cell); if (sequence.seq == 0) { return; } diff --git a/src/common/repair/parse/PageBasedFileHandle.cpp b/src/common/repair/parse/PageBasedFileHandle.cpp index b0bff137e..195dd8c77 100644 --- a/src/common/repair/parse/PageBasedFileHandle.cpp +++ b/src/common/repair/parse/PageBasedFileHandle.cpp @@ -245,7 +245,7 @@ bool PageBasedFileHandle::Cache::shouldPurge() const void PageBasedFileHandle::Cache::willPurge(const Range& range, const MappedData& data) { - WCDB_UNUSED(range) + WCDB_UNUSED(range); m_currentUsedMemery -= data.size(); } diff --git a/src/common/repair/parse/Pager.cpp b/src/common/repair/parse/Pager.cpp index d6e50c2cc..7bd6a07cd 100644 --- a/src/common/repair/parse/Pager.cpp +++ b/src/common/repair/parse/Pager.cpp @@ -394,7 +394,7 @@ bool Pager::Cache::shouldPurge() const void Pager::Cache::willPurge(const uint32_t& pageNum, const UnsafeData& data) { - WCDB_UNUSED(pageNum) + WCDB_UNUSED(pageNum); m_currentUsedMemery -= data.size(); } diff --git a/src/common/utility/Macro.h b/src/common/utility/Macro.h index 86b608951..08fe1a547 100644 --- a/src/common/utility/Macro.h +++ b/src/common/utility/Macro.h @@ -116,7 +116,7 @@ #if !defined(_WIN32) #define WCDB_UNUSED(variable) _Pragma(WCDB_STRINGIFY(unused(variable))) #else -#define WCDB_UNUSED(variable) +#define WCDB_UNUSED(variable) (void)(variable) #endif #ifdef __clang__ diff --git a/src/common/winq/extension/ColumnType.hpp b/src/common/winq/extension/ColumnType.hpp index 3557721d4..f4387cc7e 100644 --- a/src/common/winq/extension/ColumnType.hpp +++ b/src/common/winq/extension/ColumnType.hpp @@ -260,6 +260,9 @@ struct WCDB_API ColumnIsTextType : public std::true_type { const ColumnTypeInfo::UnderlyingType &t); }; +template +struct ColumnIsTextType::value>> : public std::false_type {}; + //BLOB template<> struct WCDB_API ColumnIsBLOBType> : public std::true_type { diff --git a/src/common/winq/extension/ConvertibleImplementation.hpp b/src/common/winq/extension/ConvertibleImplementation.hpp index 5fb711635..e96970709 100644 --- a/src/common/winq/extension/ConvertibleImplementation.hpp +++ b/src/common/winq/extension/ConvertibleImplementation.hpp @@ -40,7 +40,7 @@ class LiteralValueConvertible final : public std::true_type { public: static LiteralValue asLiteralValue(const std::nullptr_t& t) { - WCDB_UNUSED(t) + WCDB_UNUSED(t); return nullptr; } }; diff --git a/src/cpp/Operation/StatementOperation.hpp b/src/cpp/Operation/StatementOperation.hpp index 23410766c..a4c12f521 100644 --- a/src/cpp/Operation/StatementOperation.hpp +++ b/src/cpp/Operation/StatementOperation.hpp @@ -344,12 +344,13 @@ class WCDB_API StatementOperation { OptionalValueArray extractAllObjects(const ResultFields& resultFields) { OptionalValueArray result; - bool succeed = false; - while ((succeed = step()) && !done()) { + bool succeed = step(); + while (succeed && !done()) { if (!result.succeed()) { result = ValueArray(); } result->push_back(extractOneObject(resultFields)); + succeed = step(); } if (!succeed) { return NullOpt; diff --git a/src/cpp/chaincall/Insert.hpp b/src/cpp/chaincall/Insert.hpp index 65d90f81e..96b6f018f 100644 --- a/src/cpp/chaincall/Insert.hpp +++ b/src/cpp/chaincall/Insert.hpp @@ -202,7 +202,8 @@ class Insert final : public ChainCall { size_t count = getObjectCount(); for (size_t i = 0; i < count; i++) { const ObjectType& obj = getObjectAtIndex(i); - if (!(succeed = stepOneObject(obj, autoIncrementsOfDefinitions))) { + succeed = stepOneObject(obj, autoIncrementsOfDefinitions); + if (!(succeed)) { break; } } @@ -261,7 +262,6 @@ class Insert final : public ChainCall { return *((*m_objSharedPtrArr)[index]); default: abort(); - return *m_obj; } }