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; diff --git a/yaml-path/yaml-path.cpp b/yaml-path/yaml-path.cpp index 677214b..734df01 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 @@ -82,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 = ", ") @@ -166,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. @@ -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); } 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);