From b5a01851d9f8f9683ae5ca158c8001570869286f Mon Sep 17 00:00:00 2001 From: k0zmo Date: Sat, 18 Jul 2020 21:18:47 +0200 Subject: [PATCH] Make const char* keys streamable when exception is thrown --- include/yaml-cpp/exceptions.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/yaml-cpp/exceptions.h b/include/yaml-cpp/exceptions.h index f60b67f..c3f4474 100644 --- a/include/yaml-cpp/exceptions.h +++ b/include/yaml-cpp/exceptions.h @@ -100,6 +100,12 @@ inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) { return stream.str(); } +inline const std::string KEY_NOT_FOUND_WITH_KEY(const char* key) { + std::stringstream stream; + stream << KEY_NOT_FOUND << ": " << key; + return stream.str(); +} + template inline const std::string KEY_NOT_FOUND_WITH_KEY( const T& key, typename enable_if>::type* = 0) { @@ -120,6 +126,12 @@ inline const std::string BAD_SUBSCRIPT_WITH_KEY(const std::string& key) { return stream.str(); } +inline const std::string BAD_SUBSCRIPT_WITH_KEY(const char* key) { + std::stringstream stream; + stream << BAD_SUBSCRIPT << " (key: \"" << key << "\")"; + return stream.str(); +} + template inline const std::string BAD_SUBSCRIPT_WITH_KEY( const T& key, typename enable_if>::type* = nullptr) {