From fc6a15440df7d64e7865344ddee6d5d312868326 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 11 Dec 2018 22:22:07 +0900 Subject: [PATCH] enable format_underline to print hint with region --- toml/region.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/toml/region.hpp b/toml/region.hpp index 6dba5ea..b7e4abc 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -198,7 +198,8 @@ struct region final : public region_base // to show a better error message. inline std::string format_underline(const std::string& message, - const region_base& reg, const std::string& comment_for_underline) + const region_base& reg, const std::string& comment_for_underline, + std::vector helps = {}) { const auto line = reg.line(); const auto line_number = reg.line_num(); @@ -218,6 +219,17 @@ inline std::string format_underline(const std::string& message, retval += make_string(reg.size(), '~'); retval += ' '; retval += comment_for_underline; + if(helps.size() != 0) + { + retval += '\n'; + retval += make_string(line_number.size() + 1, ' '); + retval += " | "; + for(const auto help : helps) + { + retval += "\nHint: "; + retval += help; + } + } return retval; }