mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
enable format_underline to print hint with region
This commit is contained in:
@@ -198,7 +198,8 @@ struct region final : public region_base
|
|||||||
|
|
||||||
// to show a better error message.
|
// to show a better error message.
|
||||||
inline std::string format_underline(const std::string& 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<std::string> helps = {})
|
||||||
{
|
{
|
||||||
const auto line = reg.line();
|
const auto line = reg.line();
|
||||||
const auto line_number = reg.line_num();
|
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 += make_string(reg.size(), '~');
|
||||||
retval += ' ';
|
retval += ' ';
|
||||||
retval += comment_for_underline;
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user