diff options
author | Brad King <brad.king@kitware.com> | 2022-07-18 20:54:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-07-22 14:32:24 (GMT) |
commit | b7c82b26b03349d1201a24acbe198ee1bd00ee3e (patch) | |
tree | 6577eb58da3df4768de67e08cdd994ea29bcfca3 /Source/cmArgumentParser.h | |
parent | 50876f6b9afbf638fcc86ebfa83de7cc17a5a7e1 (diff) | |
download | CMake-b7c82b26b03349d1201a24acbe198ee1bd00ee3e.zip CMake-b7c82b26b03349d1201a24acbe198ee1bd00ee3e.tar.gz CMake-b7c82b26b03349d1201a24acbe198ee1bd00ee3e.tar.bz2 |
cmArgumentParser: Capture keyword errors in parse results
Since commit f46b2e9142 (cmArgumentParser: Model maybe-missing string
with wrapper type, 2022-07-06) we know during parsing whether or not it
is an error for a keyword to be missing a value. Record such errors in
the parse results structure. Offer clients a helper method to report
them. This provides clients with an alternative to manually checking
`keywordsMissingValue` and generating their own error message.
Diffstat (limited to 'Source/cmArgumentParser.h')
-rw-r--r-- | Source/cmArgumentParser.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 0078c04..8fda8b7 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -6,6 +6,7 @@ #include <cassert> #include <functional> +#include <map> #include <string> #include <utility> #include <vector> @@ -20,12 +21,29 @@ template <typename Result> class cmArgumentParser; // IWYU pragma: keep +class cmMakefile; + namespace ArgumentParser { class ParseResult { + std::map<cm::string_view, std::string> KeywordErrors; + public: - explicit operator bool() const { return true; } + explicit operator bool() const { return this->KeywordErrors.empty(); } + + void AddKeywordError(cm::string_view key, cm::string_view text) + + { + this->KeywordErrors[key] += text; + } + + std::map<cm::string_view, std::string> const& GetKeywordErrors() const + { + return this->KeywordErrors; + } + + bool MaybeReportError(cmMakefile& mf) const; }; template <typename Result> |