From 8e0727ecbcd3a72a5d2659aa9cbd00afc0537cfb Mon Sep 17 00:00:00 2001 From: Florian Dollinger Date: Mon, 7 Dec 2020 23:25:49 +0100 Subject: [PATCH 1/4] added noexcept to what() --- yaml-path/yaml-path.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yaml-path/yaml-path.h b/yaml-path/yaml-path.h index 567f593..e80b1ae 100644 --- a/yaml-path/yaml-path.h +++ b/yaml-path/yaml-path.h @@ -112,7 +112,7 @@ namespace YAML std::size_t ErrorOffset() const { return m_offsTokenScan; } ///< index into the full path where the error occurred std::optional BoundArg() const { return m_fromBoundArg; } ///< if token was taken from a bound argument, this is its index - char const * what() const override { return What().c_str(); } ///< overrides \c std::exception::what, returning the detailed error message from \ref What + char const * what() const noexcept override { return What().c_str(); } ///< overrides \c std::exception::what, returning the detailed error message from \ref What std::string const & What(bool detailed = true) const; static std::string GetErrorMessage(EPathError error); From 3d2465fedd9fc22b4ff429807605a848b81d9935 Mon Sep 17 00:00:00 2001 From: Florian Dollinger Date: Tue, 8 Dec 2020 04:15:31 +0100 Subject: [PATCH 2/4] fixed some problems and made it compilable @linux --- yaml-path/yaml-path.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/yaml-path/yaml-path.cpp b/yaml-path/yaml-path.cpp index 677214b..141d212 100644 --- a/yaml-path/yaml-path.cpp +++ b/yaml-path/yaml-path.cpp @@ -26,6 +26,9 @@ SOFTWARE. #include "yaml-path-internals.h" #include #include +#include +#include +#include /// namspace shared by yaml-cpp and yaml-path namespace YAML @@ -681,7 +684,7 @@ namespace YAML // Unicode: some assumptions here don't hold. It's strcoll, stricoll, and I'm not sure how to implement no-case starry matches size_t cmpLen = std::min(tok.token.length(), snode.length()); - int result = tok.noCase ? _strnicmp(&tok.token[0], snode.c_str(), cmpLen) : strncmp(&tok.token[0], snode.c_str(), cmpLen); + int result = tok.noCase ? strncasecmp(&tok.token[0], snode.c_str(), cmpLen) : strncmp(&tok.token[0], snode.c_str(), cmpLen); return result == 0; // under assumption of above length-based shortcuts } @@ -923,22 +926,21 @@ namespace YAML namespace YamlPathDetail { - Node EnsureNodeApplyKeyToMapOrNothing(Node & start, std::string key) + Node EnsureNodeApplyKeyToMapOrNothing(const Node & start, std::string key) { Node n = start[key]; if (n) return n; - start[key] = Node(NodeType::Null); - return start[key]; + return Node(NodeType::Null); } - void EnsureNodeApplyKey(std::vector & result, Node & start, std::string key, bool recurse) + void EnsureNodeApplyKey(std::vector & result, const Node & start, std::string key, bool recurse) { if (!start || start.IsNull() || start.IsMap()) result.push_back(EnsureNodeApplyKeyToMapOrNothing(start, key)); else if (start.IsSequence() && recurse) { - for (auto & el : start) + for (auto& el : start) if (el.IsNull() || el.IsMap()) EnsureNodeApplyKey(result, el, key, false); } @@ -946,7 +948,7 @@ namespace YAML void EnsureNodeApplyKey(std::vector & result, std::vector & start, std::string key) { - for (auto & el : start) + for (auto& el : start) if (el.IsNull() || el.IsMap()) EnsureNodeApplyKey(result, el, key, true); } From a82660fc60ad03b864068591860799f45271f716 Mon Sep 17 00:00:00 2001 From: Florian Dollinger Date: Tue, 8 Dec 2020 04:20:06 +0100 Subject: [PATCH 3/4] changed order --- yaml-path/yaml-path.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yaml-path/yaml-path.cpp b/yaml-path/yaml-path.cpp index 141d212..734df01 100644 --- a/yaml-path/yaml-path.cpp +++ b/yaml-path/yaml-path.cpp @@ -85,6 +85,15 @@ namespace YAML namespace YamlPathDetail { + /// \internal result = target; target = newValue + template + T1 Exchange(T1 & target, T2 newValue) + { + T1 result = std::move(target); + target = std::move(newValue); + return std::move(result); + } + /// \internal uses the same mapping as \ref MapValue to create diagnostic for a bit mask (e.g. created by \ref BitsOf) template std::string MapBitMask(TMask value, std::initializer_list> values, T2 sep = ", ") @@ -169,15 +178,6 @@ namespace YAML return undefinedNode; } - /// \internal result = target; target = newValue - template - T1 Exchange(T1 & target, T2 newValue) - { - T1 result = std::move(target); - target = std::move(newValue); - return std::move(result); - } - /** \internal splits path at offset, returning everything left of [offset], assigning everything right of it to \c path. From a02e5040b072dcfd069b6ec11deb2a791d3d8236 Mon Sep 17 00:00:00 2001 From: Florian Dollinger Date: Tue, 8 Dec 2020 04:21:56 +0100 Subject: [PATCH 4/4] changed __int64 to int64_t --- yaml-path/yaml-path-internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yaml-path/yaml-path-internals.h b/yaml-path/yaml-path-internals.h index b880f91..8ee3377 100644 --- a/yaml-path/yaml-path-internals.h +++ b/yaml-path/yaml-path-internals.h @@ -212,7 +212,7 @@ namespace YAML template constexpr uint64_t BitsOf(std::initializer_list values) { - __int64 bits = 0; + int64_t bits = 0; for (auto v : values) bits |= TBits(1) << TBits(v); return bits;