From adf4a7883e29eb3110b1965512f530930dabcb68 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Thu, 24 Jun 2021 12:24:49 -0400 Subject: [PATCH 01/11] Upgrade to require c++ 17 for replacing boost features --- CMakeLists.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c3d3d..6b95059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,9 @@ project(StyleSheets CXX) set(StyleSheets_VERSION_MAJOR 0) set(StyleSheets_VERSION_MINOR 1) -# Enable C++11 +set(CMAKE_CXX_STANDARD 17) + +# Enable C++17 include(CheckCXXCompilerFlag) if(MSVC) # Check if we are using Visual Studio 2015 or later @@ -32,11 +34,11 @@ if(MSVC) message(FATAL_ERROR "You are using an unsupported Windows compiler! (Visual C++ 2015 or later required)") endif() else() - set(cxx11_options -std=c++11) - CHECK_CXX_COMPILER_FLAG(${cxx11_options} COMPILER_SUPPORTS_CXX11) + set(cxx17_options -std=c++1z) + CHECK_CXX_COMPILER_FLAG(${cxx17_options} COMPILER_SUPPORTS_CXX17) - if(NOT COMPILER_SUPPORTS_CXX11) - message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has insufficient C++11 support. Please use a different C++ compiler.") + if(NOT COMPILER_SUPPORTS_CXX17) + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has insufficient C++17 support. Please use a different C++ compiler.") endif() endif() @@ -52,8 +54,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL Clang set(warning_options -Werror -Weverything - -Wno-c++98-compat - -Wno-c++98-compat-pedantic + -Wno-c++1z-compat + -Wno-c++1z-compat-pedantic -Wno-disabled-macro-expansion -Wno-documentation-unknown-command -Wno-exit-time-destructors @@ -87,10 +89,10 @@ find_package(Qt5Qml 5.3.0 REQUIRED) find_package(Qt5Test 5.3.0 REQUIRED) find_package(Qt5QuickTest 5.3.0 REQUIRED) -if(DEFINED Boost_INCLUDE_DIR) - get_filename_component(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR} ABSOLUTE) -endif() -find_package(Boost 1.54 REQUIRED) +#if(DEFINED Boost_INCLUDE_DIR) +# get_filename_component(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR} ABSOLUTE) +#endif() +#find_package(Boost 1.54 REQUIRED) include(FeatureSummary) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) From 071cf32a57f6c3c5b30cfdb4b108a4e323c52d75 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Thu, 24 Jun 2021 12:32:56 -0400 Subject: [PATCH 02/11] Replace boost optional with std::optional --- src/Convert.cpp | 1 - src/Convert.hpp | 16 ++++++++-------- src/StyleSetProps.cpp | 2 +- src/StyleSetProps.ipp | 2 +- src/test/tst_Convert.cpp | 12 ++++++------ 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Convert.cpp b/src/Convert.cpp index 87a75cd..b3e69d9 100644 --- a/src/Convert.cpp +++ b/src/Convert.cpp @@ -30,7 +30,6 @@ SUPPRESS_WARNINGS #include #include #include -#include #include #include #include diff --git a/src/Convert.hpp b/src/Convert.hpp index 1c59c83..3908308 100644 --- a/src/Convert.hpp +++ b/src/Convert.hpp @@ -31,7 +31,7 @@ SUPPRESS_WARNINGS #include #include #include -#include +#include RESTORE_WARNINGS #include @@ -65,36 +65,36 @@ struct PropertyValueConvertTraits; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template <> struct PropertyValueConvertTraits { - boost::optional convert(const PropertyValue& value) const; + std::optional convert(const PropertyValue& value) const; }; template > -boost::optional convertProperty(const PropertyValue& value, Traits traits = Traits()) +std::optional convertProperty(const PropertyValue& value, Traits traits = Traits()) { return traits.convert(value); } diff --git a/src/StyleSetProps.cpp b/src/StyleSetProps.cpp index 4c0ab3c..fac8f25 100644 --- a/src/StyleSetProps.cpp +++ b/src/StyleSetProps.cpp @@ -96,7 +96,7 @@ QVariant StyleSetProps::get(const QString& key) const try { auto conv = convertProperty(propValue); if (conv) { - result.push_back(conv.get()); + result.push_back(conv.value()); } } catch (ConvertException& e) { styleSheetsLogWarning() << e.what(); diff --git a/src/StyleSetProps.ipp b/src/StyleSetProps.ipp index 680cc56..24074c4 100644 --- a/src/StyleSetProps.ipp +++ b/src/StyleSetProps.ipp @@ -62,7 +62,7 @@ T StyleSetProps::lookupProperty(Property& def, const QString& key) const try { auto result = convertProperty(def.mValues[0]); if (result) { - return result.get(); + return result.value(); } } catch (const ConvertException& e) { styleSheetsLogWarning() << e.what(); diff --git a/src/test/tst_Convert.cpp b/src/test/tst_Convert.cpp index a100267..1f642db 100644 --- a/src/test/tst_Convert.cpp +++ b/src/test/tst_Convert.cpp @@ -57,12 +57,12 @@ TEST_CASE("Convert to QDouble", "[convert]") TEST_CASE("Convert to boolean", "[convert]") { - REQUIRE(convertProperty(PropertyValue(std::string("true"))).get()); - REQUIRE(convertProperty(PropertyValue(std::string("True"))).get()); - REQUIRE(convertProperty(PropertyValue(std::string("YES"))).get()); - REQUIRE(convertProperty(PropertyValue(std::string("yEs"))).get()); - REQUIRE(!convertProperty(PropertyValue(std::string("no"))).get()); - REQUIRE(!convertProperty(PropertyValue(std::string("false"))).get()); + REQUIRE(convertProperty(PropertyValue(std::string("true"))).value()); + REQUIRE(convertProperty(PropertyValue(std::string("True"))).value()); + REQUIRE(convertProperty(PropertyValue(std::string("YES"))).value()); + REQUIRE(convertProperty(PropertyValue(std::string("yEs"))).value()); + REQUIRE(!convertProperty(PropertyValue(std::string("no"))).value()); + REQUIRE(!convertProperty(PropertyValue(std::string("false"))).value()); REQUIRE(!convertProperty(PropertyValue(std::string("1")))); REQUIRE(!convertProperty(PropertyValue(std::string()))); From a50544e729f6a80df0e7b37cc10dadef3f493654 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Thu, 24 Jun 2021 12:39:18 -0400 Subject: [PATCH 03/11] Add missed boost optional replacements and replace boost variant and lexical_cast --- src/Convert.cpp | 146 ++++++++++++++++++++------------ src/CssParser.cpp | 5 +- src/CssParser.hpp | 1 - src/Property.hpp | 4 +- src/test/tst_CssParser.cpp | 9 +- src/test/tst_StyleMatchTree.cpp | 5 +- 6 files changed, 102 insertions(+), 68 deletions(-) diff --git a/src/Convert.cpp b/src/Convert.cpp index b3e69d9..888c5e2 100644 --- a/src/Convert.cpp +++ b/src/Convert.cpp @@ -27,12 +27,7 @@ THE SOFTWARE. SUPPRESS_WARNINGS #include #include -#include -#include -#include -#include -#include -#include +#include RESTORE_WARNINGS #include @@ -198,42 +193,61 @@ QFont fontDeclarationToFont(const QString& fontDecl) struct Undefined { }; -using ExprValue = boost::variant; +using ExprValue = std::variant; + +int lexicalCastInt(const std::string& s) +{ + if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) + throw ConvertException("lexicalCastInt expression with bad value"); + + char* p; + int val = strtol(s.c_str(), &p, 10); + + if (*p != 0) + throw ConvertException("lexicalCastInt expression with bad value"); + return val; +} + +float lexicalCastFloat(const std::string& s) +{ + if (s.find('%') != std::string::npos) + throw ConvertException("lexicalCastFloat expression with bad value"); + return std::stof(s); +} int rgbColorOrPercentage(const std::string& arg) { if (!arg.empty() && arg.back() == '%') { - auto factor = boost::lexical_cast(arg.substr(0, arg.size() - 1)); - return boost::algorithm::clamp(int(std::round(255 * factor / 100.0f)), 0, 255); + auto factor = lexicalCastFloat(arg.substr(0, arg.size() - 1)); + return std::clamp(int(std::round(255 * factor / 100.0f)), 0, 255); } - return boost::algorithm::clamp(boost::lexical_cast(arg), 0, 255); + return std::clamp(lexicalCastInt(arg), 0, 255); } int transformAlphaFromFloatRatio(const std::string& arg) { - auto factor = boost::lexical_cast(arg); - return boost::algorithm::clamp(int(std::round(256 * factor)), 0, 255); + auto factor = lexicalCastFloat(arg); + return std::clamp(int(std::round(256 * factor)), 0, 255); } double hslHue(const std::string& arg) { - return boost::algorithm::clamp(boost::lexical_cast(arg) / 360.0, 0.0, 1.0); + return std::clamp(lexicalCastInt(arg) / 360.0, 0.0, 1.0); } double percentageToFactor(const std::string& arg) { if (!arg.empty() && arg.back() == '%') { - return boost::algorithm::clamp( - boost::lexical_cast(arg.substr(0, arg.size() - 1)) / 100.0, 0.0, 1.0); + return std::clamp(lexicalCastInt(arg.substr(0, arg.size() - 1)) / 100.0, 0.0, 1.0); } - throw boost::bad_lexical_cast(); + throw std::invalid_argument(""); } double factorFromFloat(const std::string& arg) { - return boost::algorithm::clamp(boost::lexical_cast(arg), 0.0, 1.0); + return std::clamp(std::stod(arg), 0.0, 1.0); } ExprValue makeRgbaColor(const std::vector& args) @@ -242,7 +256,10 @@ ExprValue makeRgbaColor(const std::vector& args) try { return QColor(rgbColorOrPercentage(args[0]), rgbColorOrPercentage(args[1]), rgbColorOrPercentage(args[2]), transformAlphaFromFloatRatio(args[3])); - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kRgbaColorExpr).append("() expression with bad value")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kRgbaColorExpr).append("() expression with bad value")); } @@ -258,7 +275,10 @@ ExprValue makeRgbColor(const std::vector& args) try { return QColor(rgbColorOrPercentage(args[0]), rgbColorOrPercentage(args[1]), rgbColorOrPercentage(args[2]), 0xff); - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kRgbColorExpr).append("() expression with bad value")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kRgbColorExpr).append("() expression with bad value")); } @@ -275,7 +295,10 @@ ExprValue makeHslaColor(const std::vector& args) color.setHslF(hslHue(args[0]), percentageToFactor(args[1]), percentageToFactor(args[2]), factorFromFloat(args[3])); return color; - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kHslaColorExpr).append("() expression with bad values")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kHslaColorExpr).append("() expression with bad values")); } @@ -293,7 +316,10 @@ ExprValue makeHslColor(const std::vector& args) color.setHslF( hslHue(args[0]), percentageToFactor(args[1]), percentageToFactor(args[2]), 1.0); return color; - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kHslColorExpr).append("() expression with bad values")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kHslColorExpr).append("() expression with bad values")); } @@ -311,7 +337,10 @@ ExprValue makeHsbaColor(const std::vector& args) color.setHsvF(hslHue(args[0]), percentageToFactor(args[1]), percentageToFactor(args[2]), factorFromFloat(args[3])); return color; - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kHslaColorExpr).append("() expression with bad values")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kHslaColorExpr).append("() expression with bad values")); } @@ -329,7 +358,10 @@ ExprValue makeHsbColor(const std::vector& args) color.setHsvF( hslHue(args[0]), percentageToFactor(args[1]), percentageToFactor(args[2]), 1.0); return color; - } catch (const boost::bad_lexical_cast&) { + } catch (const std::invalid_argument&) { + throw ConvertException( + std::string().append(kHslColorExpr).append("() expression with bad values")); + } catch (const std::out_of_range&) { throw ConvertException( std::string().append(kHslColorExpr).append("() expression with bad values")); } @@ -377,20 +409,20 @@ ExprValue evaluateExpression(const Expression& expr) std::string("Unsupported expression '").append(expr.name).append("'")); } -struct PropValueVisitor : public boost::static_visitor> { - boost::optional operator()(const std::string& value) +struct PropValueVisitor { + std::optional operator()(const std::string& value) { auto qvalue = QVariant(QString::fromStdString(value)); if (qvalue.canConvert(QMetaType::QColor)) { return qvalue.value(); } - return boost::none; + return {}; } - boost::optional operator()(const Expression& expr) + std::optional operator()(const Expression& expr) { auto value = evaluateExpression(expr); - if (const QColor* color = boost::get(&value)) { + if (const QColor* color = std::get_if(&value)) { return *color; } @@ -403,78 +435,80 @@ struct PropValueVisitor : public boost::static_visitor> //------------------------------------------------------------------------------ -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { - if (const std::string* str = boost::get(&value)) { + if (const std::string* str = std::get_if(&value)) { QVariant qvalue = QVariant::fromValue(QString::fromStdString(*str)); if (qvalue.canConvert(QMetaType::QString)) { return fontDeclarationToFont(qvalue.toString()); } } - return boost::none; + return {}; } -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { PropValueVisitor visitor; - return boost::apply_visitor(visitor, value); + return std::visit(visitor, value); } -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { - if (const std::string* str = boost::get(&value)) { + if (const std::string* str = std::get_if(&value)) { return QString::fromStdString(*str); } - return boost::none; + return {}; } -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { - if (const std::string* str = boost::get(&value)) { + if (const std::string* str = std::get_if(&value)) { try { - return boost::make_optional(std::stod(*str)); + return std::make_optional(std::stod(*str)); } catch (const std::invalid_argument&) { } catch (const std::out_of_range&) { } } - return boost::none; + return {}; } -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { - if (const std::string* str = boost::get(&value)) { - auto lstr = boost::algorithm::to_lower_copy(*str); + if (const std::string* str = std::get_if(&value)) { + std::string lstr = *str; + std::transform(lstr.begin(), lstr.end(), lstr.begin(), + [](unsigned char c) { return std::tolower(c); }); if (lstr == kTrue || lstr == kYes) { - return boost::make_optional(true); + return std::make_optional(true); } else if (lstr == kFalse || lstr == kNo) { - return boost::make_optional(false); + return std::make_optional(false); } } - return boost::none; + return {}; } -boost::optional PropertyValueConvertTraits::convert( +std::optional PropertyValueConvertTraits::convert( const PropertyValue& value) const { - struct PropValueToUrlVisitor : public boost::static_visitor> { - boost::optional operator()(const std::string& str) + struct PropValueToUrlVisitor { + std::optional operator()(const std::string& str) { return QUrl(QString::fromStdString(str)); } - boost::optional operator()(const Expression& expr) + std::optional operator()(const Expression& expr) { auto exprValue = evaluateExpression(expr); - if (const QUrl* url = boost::get(&exprValue)) { + if (const QUrl* url = std::get_if(&exprValue)) { return *url; } @@ -484,14 +518,14 @@ boost::optional PropertyValueConvertTraits::convert( }; PropValueToUrlVisitor visitor; - return boost::apply_visitor(visitor, value); + return std::visit(visitor, value); } //---------------------------------------------------------------------------------------- namespace { -struct PropValueToVariantVisitor : public boost::static_visitor { +struct PropValueToVariantVisitor { QVariant operator()(const std::string& value) { return QVariant(QString::fromStdString(value)); @@ -499,7 +533,7 @@ struct PropValueToVariantVisitor : public boost::static_visitor { QVariant operator()(const Expression& expr) { - struct ExprValueToVariantVisitor : public boost::static_visitor { + struct ExprValueToVariantVisitor { QVariant operator()(const Undefined&) { return QVariant(); @@ -519,7 +553,7 @@ struct PropValueToVariantVisitor : public boost::static_visitor { auto exprValue = evaluateExpression(expr); ExprValueToVariantVisitor visitor; - return boost::apply_visitor(visitor, exprValue); + return std::visit(visitor, exprValue); } }; } // anon namespace @@ -527,7 +561,7 @@ struct PropValueToVariantVisitor : public boost::static_visitor { QVariant convertValueToVariant(const PropertyValue& value) { PropValueToVariantVisitor visitor; - return boost::apply_visitor(visitor, value); + return std::visit(visitor, value); } QVariantList convertValueToVariantList(const PropertyValues& values) diff --git a/src/CssParser.cpp b/src/CssParser.cpp index ec1b846..5b917cc 100644 --- a/src/CssParser.cpp +++ b/src/CssParser.cpp @@ -25,10 +25,9 @@ THE SOFTWARE. #include "Warnings.hpp" SUPPRESS_WARNINGS -#include -#include +#include "cpp-peglib/peglib.h" +#include RESTORE_WARNINGS - #include #include #include diff --git a/src/CssParser.hpp b/src/CssParser.hpp index 3766c39..cbf2d89 100644 --- a/src/CssParser.hpp +++ b/src/CssParser.hpp @@ -28,7 +28,6 @@ THE SOFTWARE. SUPPRESS_WARNINGS #include -#include RESTORE_WARNINGS #include diff --git a/src/Property.hpp b/src/Property.hpp index a9058e5..80c9bef 100644 --- a/src/Property.hpp +++ b/src/Property.hpp @@ -25,7 +25,7 @@ THE SOFTWARE. #include "Warnings.hpp" SUPPRESS_WARNINGS -#include +#include RESTORE_WARNINGS #include @@ -46,7 +46,7 @@ class Expression std::vector args; }; -using PropertyValue = boost::variant; +using PropertyValue = std::variant; using PropertyValues = std::vector; class SourceLocation diff --git a/src/test/tst_CssParser.cpp b/src/test/tst_CssParser.cpp index c5a828a..d803760 100644 --- a/src/test/tst_CssParser.cpp +++ b/src/test/tst_CssParser.cpp @@ -25,8 +25,9 @@ THE SOFTWARE. #include "Warnings.hpp" SUPPRESS_WARNINGS -#include -#include +//#include +//#include +#include #include RESTORE_WARNINGS @@ -57,7 +58,7 @@ std::string selectorName(const StyleSheet& ss, std::string getFirstValue(const PropertyValues& val, const std::string& def = "") { if (!val.empty()) { - if (const std::string* str = boost::get(&val[0])) { + if (const std::string* str = std::get_if(&val[0])) { return *str; } } @@ -70,7 +71,7 @@ Expression getExpr(const PropertyValues& val, const Expression& def = Expression{}) { if (!val.empty()) { - if (const Expression* expr = boost::get(&val[idx])) { + if (const Expression* expr = std::get_if(&val[idx])) { return *expr; } } diff --git a/src/test/tst_StyleMatchTree.cpp b/src/test/tst_StyleMatchTree.cpp index 9f48127..9f08bd9 100644 --- a/src/test/tst_StyleMatchTree.cpp +++ b/src/test/tst_StyleMatchTree.cpp @@ -27,7 +27,8 @@ THE SOFTWARE. #include "Warnings.hpp" SUPPRESS_WARNINGS -#include +//#include +#include #include #include #include @@ -43,7 +44,7 @@ namespace std::string propertyAsString(PropertyMap pm, const char* pPropertyName) { if (const std::string* str = - boost::get(&pm[QString(pPropertyName)].mValues[0])) { + std::get_if(&pm[QString(pPropertyName)].mValues[0])) { return *str; } return std::string(); From 8f76b9e00b3c7a1031a4741af695b07695b1bac6 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Thu, 24 Jun 2021 12:40:04 -0400 Subject: [PATCH 04/11] Replace boost variant in StyleMatchTree and replace boost hash --- src/StyleMatchTree.cpp | 54 ++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/StyleMatchTree.cpp b/src/StyleMatchTree.cpp index ad191f8..7bd8bda 100644 --- a/src/StyleMatchTree.cpp +++ b/src/StyleMatchTree.cpp @@ -28,13 +28,11 @@ THE SOFTWARE. #include "Log.hpp" SUPPRESS_WARNINGS -#include -#include -#include -#include -#include +#include +#include +#include +#include RESTORE_WARNINGS - #include #include #include @@ -509,7 +507,7 @@ PropertyMap mergeMatchResults(const MatchResult& result) Specificity lastSpec; for (const auto& tup : result) { - BOOST_ASSERT(lastSpec < getMatchSpecificity(tup) + assert(lastSpec < getMatchSpecificity(tup) || lastSpec == getMatchSpecificity(tup)); mergePropertiesIntoPropertyMap( @@ -533,7 +531,7 @@ std::ostream& operator<<(std::ostream& os, const SourceLocation& srcloc) std::ostream& operator<<(std::ostream& os, const PropertyValues& values) { - class StreamVisitor : public boost::static_visitor<> + class StreamVisitor /*: public boost::static_visitor<>*/ { std::ostream& mStream; @@ -560,7 +558,7 @@ std::ostream& operator<<(std::ostream& os, const PropertyValues& values) StreamVisitor visitor(os); for (const auto& value : values) { - boost::apply_visitor(visitor, value); + std::visit(visitor, value); os << ", "; } @@ -664,17 +662,47 @@ std::string pathToString(const UiItemPath& path) return ss.str(); } +struct PathElementHasher { + std::size_t operator()(const PathElement& v) const + { + return hash_value(v); + } +}; + +struct PathElementVectorHasher { + std::size_t operator()(const std::vector& v) const + { + std::size_t seed = 0; + for (auto it = v.begin(); it != v.end(); ++it) { + seed ^= PathElementHasher{}(*it) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + } + return seed; + } +}; + +struct VectorHasher { + template + std::size_t operator()(const std::vector& v) const + { + std::size_t seed = 0; + for (auto it = v.begin(); it != v.end(); ++it) { + seed ^= std::hash{}(*it) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + } + return seed; + } +}; + std::size_t hash_value(const PathElement& pathElement) { - std::size_t seed = boost::hash{}(pathElement.mTypeName); - boost::hash_combine( - seed, boost::hash>{}(pathElement.mClassNames)); + std::size_t seed = std::hash{}(pathElement.mTypeName); + seed ^= + VectorHasher{}(pathElement.mClassNames) + 0x9e3779b9 + (seed << 6) + (seed >> 2); return seed; } std::size_t UiItemPathHasher::operator()(const UiItemPath& path) const { - return boost::hash{}(path); + return PathElementVectorHasher{}(path); } } // namespace stylesheets From b1fcfc1d79dc58c37cd19f4006be1c0f871f74c0 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Thu, 24 Jun 2021 12:47:08 -0400 Subject: [PATCH 05/11] Remove commented boost code from cmake file --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b95059..36b8ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,11 +89,6 @@ find_package(Qt5Qml 5.3.0 REQUIRED) find_package(Qt5Test 5.3.0 REQUIRED) find_package(Qt5QuickTest 5.3.0 REQUIRED) -#if(DEFINED Boost_INCLUDE_DIR) -# get_filename_component(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR} ABSOLUTE) -#endif() -#find_package(Boost 1.54 REQUIRED) - include(FeatureSummary) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) From 8b0eb1e6d0d84fbdf90c1756a8d1ab0a53abbefb Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Fri, 25 Jun 2021 11:58:16 -0400 Subject: [PATCH 06/11] Remove boost reference in yml file --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 8a37597..d2463ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,7 @@ install: build_script: - mkdir build && cd build - - cmake .. -G"%CMAKE_GENERATOR%" -DBoost_INCLUDE_DIR=%BOOST_ROOT% + - cmake .. -G"%CMAKE_GENERATOR%" - cmake --build . --config Release - cmake --build . --config Release --target install From 359daaded12002fc37bc122b67685892e656ad43 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Fri, 25 Jun 2021 11:58:30 -0400 Subject: [PATCH 07/11] Remove boost reference in README file --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index d6ef3ea..ea835b9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ fewer lines of code through selectors that apply across many components. Dependencies: - Qt (>= 5.3) - - Boost (>= 1.54) - CMake (>= 2.8.12) Mac: @@ -50,10 +49,6 @@ The unit tests can be executed with ctest: ctest -V -C Release ``` -You might set the following variables: - -- Boost_INCLUDE_DIR to the folder, where Boost headers are found - In case the CMake files shipped with Qt are not found, set the CMAKE_PREFIX_PATH to the Qt installation prefix. See the [Qt5 CMake manual](http://qt-project.org/doc/qt-5/cmake-manual.html) for more. From 83be10125832cb7b8c9f853d06b67afbb38d65fb Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Fri, 25 Jun 2021 12:44:54 -0400 Subject: [PATCH 08/11] Remove support for Visual Studio 2015 --- CMakeLists.txt | 6 +++--- README.md | 2 +- appveyor.yml | 6 ------ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36b8ebb..97e4899 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ set(CMAKE_CXX_STANDARD 17) # Enable C++17 include(CheckCXXCompilerFlag) if(MSVC) - # Check if we are using Visual Studio 2015 or later - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - message(FATAL_ERROR "You are using an unsupported Windows compiler! (Visual C++ 2015 or later required)") + # Check if we are using Visual Studio 2017 or later + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) + message(FATAL_ERROR "You are using an unsupported Windows compiler! (Visual C++ 2017 or later required)") endif() else() set(cxx17_options -std=c++1z) diff --git a/README.md b/README.md index ea835b9..db24ca2 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Mac: Windows: - - Visual Studio 2015 + - Visual Studio 2017 ## Build and Test diff --git a/appveyor.yml b/appveyor.yml index d2463ee..091ecb9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,14 +6,8 @@ clone_depth: 5 environment: matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - CMAKE_GENERATOR: "Visual Studio 14 2015 Win64" - BOOST_ROOT: C:\Libraries\boost_1_60_0 - CMAKE_PREFIX_PATH: C:\Qt\5.6.3\msvc2015_64 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 CMAKE_GENERATOR: "Visual Studio 15 2017 Win64" - BOOST_ROOT: C:\Libraries\boost_1_67_0 CMAKE_PREFIX_PATH: C:\Qt\5.11.3\msvc2017_64 install: From e8e4c519b26f3d9ecd557eba226617b2e40ac8e2 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Fri, 25 Jun 2021 12:55:59 -0400 Subject: [PATCH 09/11] Add cctype include --- src/Convert.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Convert.cpp b/src/Convert.cpp index 888c5e2..9535b16 100644 --- a/src/Convert.cpp +++ b/src/Convert.cpp @@ -35,6 +35,7 @@ RESTORE_WARNINGS #include #include #include +#include namespace aqt { From e43467508cfe468e2d817f2bf3ce49ddd5fabea3 Mon Sep 17 00:00:00 2001 From: Jessica Marquis <83971431+jmarquisbq@users.noreply.github.com> Date: Fri, 25 Jun 2021 13:45:58 -0400 Subject: [PATCH 10/11] Update src/Convert.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove unnecessary checks in lexicalCastInt Co-authored-by: Carsten Müncheberg --- src/Convert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Convert.cpp b/src/Convert.cpp index 9535b16..07f7f50 100644 --- a/src/Convert.cpp +++ b/src/Convert.cpp @@ -198,7 +198,7 @@ using ExprValue = std::variant; int lexicalCastInt(const std::string& s) { - if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) + if (s.empty()) throw ConvertException("lexicalCastInt expression with bad value"); char* p; From b80dd13e0f2193690b3b648810d0643a1a6bed92 Mon Sep 17 00:00:00 2001 From: "TITANIUM\\jmarquis" Date: Mon, 28 Jun 2021 17:06:41 -0400 Subject: [PATCH 11/11] revert changes from last commit --- src/Convert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Convert.cpp b/src/Convert.cpp index 07f7f50..9535b16 100644 --- a/src/Convert.cpp +++ b/src/Convert.cpp @@ -198,7 +198,7 @@ using ExprValue = std::variant; int lexicalCastInt(const std::string& s) { - if (s.empty()) + if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) throw ConvertException("lexicalCastInt expression with bad value"); char* p;