summaryrefslogtreecommitdiffstats
path: root/src/bin/netconf
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2021-11-26 10:42:06 +0100
committerAndrei Pavel <andrei@isc.org>2021-12-17 16:19:03 +0100
commita414c2b83e058b6286307be95731564952e7f44b (patch)
tree514147986015f86ddd9675f4b97c991c3f9efa50 /src/bin/netconf
parent[#2084] add ChangeLog entry (diff)
downloadkea-a414c2b83e058b6286307be95731564952e7f44b.tar.xz
kea-a414c2b83e058b6286307be95731564952e7f44b.zip
[#2084] add warning() method to parser contexts
Diffstat (limited to 'src/bin/netconf')
-rw-r--r--src/bin/netconf/parser_context.cc13
-rw-r--r--src/bin/netconf/parser_context.h15
2 files changed, 26 insertions, 2 deletions
diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc
index 24fc650407..c672d95226 100644
--- a/src/bin/netconf/parser_context.cc
+++ b/src/bin/netconf/parser_context.cc
@@ -180,5 +180,16 @@ ParserContext::contextName()
}
}
+void
+ParserContext::warning(const isc::netconf::location& loc,
+ const std::string& what,
+ size_t pos /* = 0 */) {
+ if (pos == 0) {
+ std::cerr << loc << ": " << what << std::endl;
+ } else {
+ std::cerr << loc << " (near " << pos << "): " << what << std::endl;
+ }
}
-}
+
+} // namespace netconf
+} // namespace isc
diff --git a/src/bin/netconf/parser_context.h b/src/bin/netconf/parser_context.h
index 22be5d0f63..5db590fff0 100644
--- a/src/bin/netconf/parser_context.h
+++ b/src/bin/netconf/parser_context.h
@@ -119,7 +119,7 @@ public:
/// @note The optional position for an error in a string begins by 1
/// so the caller should add 1 to the position of the C++ string.
///
- /// @param loc location within the parsed file when experienced a problem.
+ /// @param loc location within the parsed file where the problem was experienced.
/// @param what string explaining the nature of the error.
/// @param pos optional position for in string errors.
/// @throw ParseError
@@ -178,6 +178,19 @@ public:
void unique(const std::string& name,
isc::data::Element::Position loc);
+ /// @brief Warning handler
+ ///
+ /// @param loc location within the parsed file where the problem was experienced
+ /// @param what string explaining the nature of the error
+ /// @param pos optional position for in string errors. The optional position
+ /// for an error in a string begins by 1 so the caller should add 1 to the
+ /// position of the C++ string.
+ ///
+ /// @throw ParseError
+ void warning(const isc::netconf::location& loc,
+ const std::string& what,
+ size_t pos = 0);
+
/// @brief Defines syntactic contexts for lexical tie-ins
typedef enum {
///< This one is used in pure JSON mode.