2018-12-13 11:44:10 +00:00
|
|
|
// Copyright Toru Niina 2017.
|
|
|
|
// Distributed under the MIT License.
|
2019-03-16 05:19:47 +00:00
|
|
|
#ifndef TOML11_REGION_HPP
|
|
|
|
#define TOML11_REGION_HPP
|
2018-12-02 15:10:26 +00:00
|
|
|
#include "exception.hpp"
|
2018-12-02 11:52:04 +00:00
|
|
|
#include <memory>
|
2018-12-09 10:30:46 +00:00
|
|
|
#include <vector>
|
2018-12-02 11:52:04 +00:00
|
|
|
#include <algorithm>
|
2018-12-09 04:05:09 +00:00
|
|
|
#include <initializer_list>
|
2018-12-02 11:52:04 +00:00
|
|
|
#include <iterator>
|
2018-12-13 08:07:03 +00:00
|
|
|
#include <iomanip>
|
2018-12-02 11:52:04 +00:00
|
|
|
|
|
|
|
namespace toml
|
|
|
|
{
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
|
2019-03-18 02:09:12 +00:00
|
|
|
// helper function to avoid std::string(0, 'c') or std::string(iter, iter)
|
2018-12-05 07:55:31 +00:00
|
|
|
template<typename Iterator>
|
|
|
|
std::string make_string(Iterator first, Iterator last)
|
|
|
|
{
|
|
|
|
if(first == last) {return "";}
|
|
|
|
return std::string(first, last);
|
|
|
|
}
|
|
|
|
inline std::string make_string(std::size_t len, char c)
|
|
|
|
{
|
|
|
|
if(len == 0) {return "";}
|
|
|
|
return std::string(len, c);
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:09:12 +00:00
|
|
|
// region_base is a base class of location and region that are defined below.
|
2019-03-02 08:52:00 +00:00
|
|
|
// it will be used to generate better error messages.
|
|
|
|
struct region_base
|
|
|
|
{
|
|
|
|
region_base() = default;
|
|
|
|
virtual ~region_base() = default;
|
|
|
|
region_base(const region_base&) = default;
|
|
|
|
region_base(region_base&& ) = default;
|
|
|
|
region_base& operator=(const region_base&) = default;
|
|
|
|
region_base& operator=(region_base&& ) = default;
|
|
|
|
|
|
|
|
virtual bool is_ok() const noexcept {return false;}
|
|
|
|
|
|
|
|
virtual std::string str() const {return std::string("unknown region");}
|
|
|
|
virtual std::string name() const {return std::string("unknown file");}
|
|
|
|
virtual std::string line() const {return std::string("unknown line");}
|
|
|
|
virtual std::string line_num() const {return std::string("?");}
|
|
|
|
|
2019-03-18 02:09:12 +00:00
|
|
|
// length of the region
|
2019-03-02 08:52:00 +00:00
|
|
|
virtual std::size_t size() const noexcept {return 0;}
|
2019-03-18 02:09:12 +00:00
|
|
|
// number of characters in the line before the region
|
|
|
|
virtual std::size_t before() const noexcept {return 0;}
|
|
|
|
// number of characters in the line after the region
|
2019-03-02 08:52:00 +00:00
|
|
|
virtual std::size_t after() const noexcept {return 0;}
|
2019-04-25 13:32:18 +00:00
|
|
|
|
|
|
|
virtual std::string comment_before() const {return "";} // just before
|
|
|
|
virtual std::string comment_inline() const {return "";} // in the same line
|
|
|
|
virtual std::string comment() const {return "";} // concatenate
|
|
|
|
// ```toml
|
|
|
|
// # comment_before
|
|
|
|
// key = "value" # comment_inline
|
|
|
|
// ```
|
2019-03-02 08:52:00 +00:00
|
|
|
};
|
|
|
|
|
2019-03-18 02:09:12 +00:00
|
|
|
// location represents a position in a container, which contains a file content.
|
2019-03-02 08:52:00 +00:00
|
|
|
// it can be considered as a region that contains only one character.
|
2019-03-18 02:09:12 +00:00
|
|
|
//
|
|
|
|
// it contains pointer to the file content and iterator that points the current
|
|
|
|
// location.
|
2018-12-02 11:52:04 +00:00
|
|
|
template<typename Container>
|
2019-03-02 08:52:00 +00:00
|
|
|
struct location final : public region_base
|
2018-12-02 11:52:04 +00:00
|
|
|
{
|
|
|
|
using const_iterator = typename Container::const_iterator;
|
2018-12-02 15:10:26 +00:00
|
|
|
using source_ptr = std::shared_ptr<const Container>;
|
2018-12-02 11:52:04 +00:00
|
|
|
|
2019-04-12 09:00:53 +00:00
|
|
|
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
|
|
|
static_assert(std::is_same<std::random_access_iterator_tag,
|
|
|
|
typename std::iterator_traits<const_iterator>::iterator_category>::value,
|
|
|
|
"container should be randomly accessible");
|
|
|
|
|
2018-12-05 07:55:31 +00:00
|
|
|
location(std::string name, Container cont)
|
2019-04-18 04:56:19 +00:00
|
|
|
: source_(std::make_shared<Container>(std::move(cont))), line_number_(1),
|
2018-12-08 15:00:15 +00:00
|
|
|
source_name_(std::move(name)), iter_(source_->cbegin())
|
2018-12-02 11:52:04 +00:00
|
|
|
{}
|
|
|
|
location(const location&) = default;
|
|
|
|
location(location&&) = default;
|
|
|
|
location& operator=(const location&) = default;
|
|
|
|
location& operator=(location&&) = default;
|
2018-12-02 15:10:26 +00:00
|
|
|
~location() = default;
|
2018-12-02 11:52:04 +00:00
|
|
|
|
2019-03-02 08:52:00 +00:00
|
|
|
bool is_ok() const noexcept override {return static_cast<bool>(source_);}
|
|
|
|
|
2019-04-12 09:32:46 +00:00
|
|
|
// this const prohibits codes like `++(loc.iter())`.
|
|
|
|
const const_iterator iter() const noexcept {return iter_;}
|
|
|
|
|
|
|
|
const_iterator begin() const noexcept {return source_->cbegin();}
|
|
|
|
const_iterator end() const noexcept {return source_->cend();}
|
|
|
|
|
2019-04-18 04:56:19 +00:00
|
|
|
// XXX `location::line_num()` used to be implemented using `std::count` to
|
2019-04-12 09:32:46 +00:00
|
|
|
// count a number of '\n'. But with a long toml file (typically, 10k lines),
|
|
|
|
// it becomes intolerably slow because each time it generates error messages,
|
|
|
|
// it counts '\n' from thousands of characters. To workaround it, I decided
|
|
|
|
// to introduce `location::line_number_` member variable and synchronize it
|
|
|
|
// to the location changes the point to look. So an overload of `iter()`
|
|
|
|
// which returns mutable reference is removed and `advance()`, `retrace()`
|
|
|
|
// and `reset()` is added.
|
|
|
|
void advance(std::size_t n = 1) noexcept
|
|
|
|
{
|
|
|
|
this->line_number_ += std::count(this->iter_, this->iter_ + n, '\n');
|
|
|
|
this->iter_ += n;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
void retrace(std::size_t n = 1) noexcept
|
|
|
|
{
|
|
|
|
this->line_number_ -= std::count(this->iter_ - n, this->iter_, '\n');
|
|
|
|
this->iter_ -= n;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
void reset(const_iterator rollback) noexcept
|
|
|
|
{
|
2019-04-18 04:56:19 +00:00
|
|
|
// since c++11, std::distance works in both ways for random-access
|
|
|
|
// iterators and returns a negative value if `first > last`.
|
2019-04-12 09:32:46 +00:00
|
|
|
if(0 <= std::distance(rollback, this->iter_)) // rollback < iter
|
|
|
|
{
|
|
|
|
this->line_number_ -= std::count(rollback, this->iter_, '\n');
|
|
|
|
}
|
|
|
|
else // iter < rollback [[unlikely]]
|
|
|
|
{
|
|
|
|
this->line_number_ += std::count(this->iter_, rollback, '\n');
|
|
|
|
}
|
|
|
|
this->iter_ = rollback;
|
|
|
|
return;
|
|
|
|
}
|
2018-12-02 15:10:26 +00:00
|
|
|
|
2019-03-02 08:52:00 +00:00
|
|
|
std::string str() const override {return make_string(1, *this->iter());}
|
|
|
|
std::string name() const override {return source_name_;}
|
|
|
|
|
|
|
|
std::string line_num() const override
|
|
|
|
{
|
2019-04-12 09:32:46 +00:00
|
|
|
return std::to_string(this->line_number_);
|
2019-03-02 08:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string line() const override
|
|
|
|
{
|
|
|
|
return make_string(this->line_begin(), this->line_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
const_iterator line_begin() const noexcept
|
|
|
|
{
|
|
|
|
using reverse_iterator = std::reverse_iterator<const_iterator>;
|
|
|
|
return std::find(reverse_iterator(this->iter()),
|
|
|
|
reverse_iterator(this->begin()), '\n').base();
|
|
|
|
}
|
|
|
|
const_iterator line_end() const noexcept
|
|
|
|
{
|
|
|
|
return std::find(this->iter(), this->end(), '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
// location is always points a character. so the size is 1.
|
|
|
|
std::size_t size() const noexcept override
|
|
|
|
{
|
|
|
|
return 1u;
|
|
|
|
}
|
|
|
|
std::size_t before() const noexcept override
|
|
|
|
{
|
|
|
|
return std::distance(this->line_begin(), this->iter());
|
|
|
|
}
|
|
|
|
std::size_t after() const noexcept override
|
|
|
|
{
|
|
|
|
return std::distance(this->iter(), this->line_end());
|
|
|
|
}
|
|
|
|
|
2018-12-02 15:10:26 +00:00
|
|
|
source_ptr const& source() const& noexcept {return source_;}
|
|
|
|
source_ptr&& source() && noexcept {return std::move(source_);}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-12-05 07:55:31 +00:00
|
|
|
source_ptr source_;
|
2019-04-12 09:32:46 +00:00
|
|
|
std::size_t line_number_;
|
2018-12-05 07:55:31 +00:00
|
|
|
std::string source_name_;
|
2018-12-08 15:00:15 +00:00
|
|
|
const_iterator iter_;
|
2018-12-02 11:52:04 +00:00
|
|
|
};
|
|
|
|
|
2019-03-18 02:09:12 +00:00
|
|
|
// region represents a range in a container, which contains a file content.
|
|
|
|
//
|
|
|
|
// it contains pointer to the file content and iterator that points the first
|
|
|
|
// and last location.
|
2018-12-02 11:52:04 +00:00
|
|
|
template<typename Container>
|
2018-12-09 03:41:38 +00:00
|
|
|
struct region final : public region_base
|
2018-12-02 11:52:04 +00:00
|
|
|
{
|
|
|
|
using const_iterator = typename Container::const_iterator;
|
2018-12-02 15:10:26 +00:00
|
|
|
using source_ptr = std::shared_ptr<const Container>;
|
2018-12-02 11:52:04 +00:00
|
|
|
|
2019-04-12 09:00:53 +00:00
|
|
|
static_assert(std::is_same<char, typename Container::value_type>::value,"");
|
|
|
|
static_assert(std::is_same<std::random_access_iterator_tag,
|
|
|
|
typename std::iterator_traits<const_iterator>::iterator_category>::value,
|
|
|
|
"container should be randomly accessible");
|
|
|
|
|
2018-12-09 03:41:38 +00:00
|
|
|
// delete default constructor. source_ never be null.
|
|
|
|
region() = delete;
|
|
|
|
|
2018-12-02 11:52:04 +00:00
|
|
|
region(const location<Container>& loc)
|
2018-12-05 07:55:31 +00:00
|
|
|
: source_(loc.source()), source_name_(loc.name()),
|
2018-12-08 15:00:15 +00:00
|
|
|
first_(loc.iter()), last_(loc.iter())
|
2018-12-02 11:52:04 +00:00
|
|
|
{}
|
|
|
|
region(location<Container>&& loc)
|
2018-12-05 07:55:31 +00:00
|
|
|
: source_(loc.source()), source_name_(loc.name()),
|
2018-12-08 15:00:15 +00:00
|
|
|
first_(loc.iter()), last_(loc.iter())
|
2018-12-02 11:52:04 +00:00
|
|
|
{}
|
|
|
|
|
2018-12-02 14:04:49 +00:00
|
|
|
region(const location<Container>& loc, const_iterator f, const_iterator l)
|
2018-12-08 15:00:15 +00:00
|
|
|
: source_(loc.source()), source_name_(loc.name()), first_(f), last_(l)
|
2018-12-02 14:04:49 +00:00
|
|
|
{}
|
|
|
|
region(location<Container>&& loc, const_iterator f, const_iterator l)
|
2018-12-08 15:00:15 +00:00
|
|
|
: source_(loc.source()), source_name_(loc.name()), first_(f), last_(l)
|
2018-12-02 14:04:49 +00:00
|
|
|
{}
|
|
|
|
|
2018-12-02 11:52:04 +00:00
|
|
|
region(const region&) = default;
|
|
|
|
region(region&&) = default;
|
|
|
|
region& operator=(const region&) = default;
|
|
|
|
region& operator=(region&&) = default;
|
|
|
|
~region() = default;
|
|
|
|
|
2018-12-02 15:10:26 +00:00
|
|
|
region& operator+=(const region& other)
|
|
|
|
{
|
2018-12-08 15:00:15 +00:00
|
|
|
if(this->begin() != other.begin() || this->end() != other.end() ||
|
2018-12-02 15:10:26 +00:00
|
|
|
this->last_ != other.first_)
|
|
|
|
{
|
|
|
|
throw internal_error("invalid region concatenation");
|
|
|
|
}
|
|
|
|
this->last_ = other.last_;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-12-09 03:41:38 +00:00
|
|
|
bool is_ok() const noexcept override {return static_cast<bool>(source_);}
|
2018-12-02 15:10:26 +00:00
|
|
|
|
2018-12-09 03:41:38 +00:00
|
|
|
std::string str() const override {return make_string(first_, last_);}
|
|
|
|
std::string line() const override
|
|
|
|
{
|
2018-12-09 09:08:04 +00:00
|
|
|
if(this->contain_newline())
|
|
|
|
{
|
|
|
|
return make_string(this->line_begin(),
|
|
|
|
std::find(this->line_begin(), this->last(), '\n'));
|
|
|
|
}
|
2018-12-09 03:41:38 +00:00
|
|
|
return make_string(this->line_begin(), this->line_end());
|
|
|
|
}
|
|
|
|
std::string line_num() const override
|
|
|
|
{
|
|
|
|
return std::to_string(1 + std::count(this->begin(), this->first(), '\n'));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t size() const noexcept override
|
|
|
|
{
|
|
|
|
return std::distance(first_, last_);
|
|
|
|
}
|
|
|
|
std::size_t before() const noexcept override
|
|
|
|
{
|
|
|
|
return std::distance(this->line_begin(), this->first());
|
|
|
|
}
|
|
|
|
std::size_t after() const noexcept override
|
|
|
|
{
|
|
|
|
return std::distance(this->last(), this->line_end());
|
|
|
|
}
|
|
|
|
|
2018-12-09 09:08:04 +00:00
|
|
|
bool contain_newline() const noexcept
|
|
|
|
{
|
|
|
|
return std::find(this->first(), this->last(), '\n') != this->last();
|
|
|
|
}
|
|
|
|
|
2018-12-09 03:41:38 +00:00
|
|
|
const_iterator line_begin() const noexcept
|
|
|
|
{
|
|
|
|
using reverse_iterator = std::reverse_iterator<const_iterator>;
|
|
|
|
return std::find(reverse_iterator(this->first()),
|
|
|
|
reverse_iterator(this->begin()), '\n').base();
|
|
|
|
}
|
|
|
|
const_iterator line_end() const noexcept
|
|
|
|
{
|
|
|
|
return std::find(this->last(), this->end(), '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
const_iterator begin() const noexcept {return source_->cbegin();}
|
|
|
|
const_iterator end() const noexcept {return source_->cend();}
|
|
|
|
const_iterator first() const noexcept {return first_;}
|
|
|
|
const_iterator last() const noexcept {return last_;}
|
2018-12-02 15:10:26 +00:00
|
|
|
|
|
|
|
source_ptr const& source() const& noexcept {return source_;}
|
|
|
|
source_ptr&& source() && noexcept {return std::move(source_);}
|
|
|
|
|
2018-12-09 03:41:38 +00:00
|
|
|
std::string name() const override {return source_name_;}
|
2018-12-05 07:55:31 +00:00
|
|
|
|
2019-04-25 13:32:18 +00:00
|
|
|
std::string comment_before() const override
|
|
|
|
{
|
|
|
|
auto iter = this->line_begin(); // points the first element
|
|
|
|
std::vector<std::pair<decltype(iter), decltype(iter)>> comments;
|
|
|
|
while(iter != this->begin())
|
|
|
|
{
|
|
|
|
iter = std::prev(iter);
|
|
|
|
using rev_iter = std::reverse_iterator<decltype(iter)>;
|
|
|
|
auto line_before = std::find(rev_iter(iter), rev_iter(this->begin()),
|
|
|
|
'\n').base();
|
|
|
|
// range [line_before, iter) represents the previous line
|
|
|
|
|
|
|
|
auto comment_found = std::find(line_before, iter, '#');
|
|
|
|
if(iter != comment_found && std::all_of(line_before, comment_found,
|
|
|
|
[](const char c) noexcept -> bool {
|
|
|
|
return c == ' ' || c == '\t';
|
|
|
|
}))
|
|
|
|
{
|
|
|
|
// the line before this range contains only a comment.
|
|
|
|
comments.push_back(std::make_pair(comment_found, iter));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
iter = line_before;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string com;
|
|
|
|
for(auto i = comments.crbegin(), e = comments.crend(); i!=e; ++i)
|
|
|
|
{
|
|
|
|
if(i != comments.crbegin()) {com += '\n';}
|
|
|
|
com += std::string(i->first, i->second);
|
|
|
|
}
|
|
|
|
return com;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string comment_inline() const override
|
|
|
|
{
|
|
|
|
if(this->contain_newline())
|
|
|
|
{
|
|
|
|
std::string com;
|
|
|
|
// check both the first and the last line.
|
|
|
|
const auto first_line_end =
|
|
|
|
std::find(this->line_begin(), this->last(), '\n');
|
|
|
|
const auto first_comment_found =
|
|
|
|
std::find(this->line_begin(), first_line_end, '#');
|
|
|
|
|
|
|
|
if(first_comment_found != first_line_end)
|
|
|
|
{
|
|
|
|
com += std::string(first_comment_found, first_line_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto last_comment_found =
|
|
|
|
std::find(this->last(), this->line_end(), '#');
|
|
|
|
if(last_comment_found != this->line_end())
|
|
|
|
{
|
|
|
|
if(!com.empty()){com += '\n';}
|
|
|
|
com += std::string(last_comment_found, this->line_end());
|
|
|
|
}
|
|
|
|
return com;
|
|
|
|
}
|
|
|
|
const auto comment_found =
|
|
|
|
std::find(this->line_begin(), this->line_end(), '#');
|
|
|
|
return std::string(comment_found, this->line_end());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string comment() const override
|
|
|
|
{
|
|
|
|
std::string com_bef = this->comment_before();
|
|
|
|
std::string com_inl = this->comment_inline();
|
|
|
|
if(!com_bef.empty() && !com_inl.empty())
|
|
|
|
{
|
|
|
|
com_bef += '\n';
|
|
|
|
return com_bef + com_inl;
|
|
|
|
}
|
|
|
|
else if(com_bef.empty())
|
|
|
|
{
|
|
|
|
return com_inl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return com_bef;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-02 15:10:26 +00:00
|
|
|
private:
|
2018-12-02 14:16:28 +00:00
|
|
|
|
2018-12-05 07:55:31 +00:00
|
|
|
source_ptr source_;
|
|
|
|
std::string source_name_;
|
2018-12-08 15:00:15 +00:00
|
|
|
const_iterator first_, last_;
|
2018-12-02 11:52:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// to show a better error message.
|
2019-03-02 08:52:00 +00:00
|
|
|
inline std::string format_underline(const std::string& message,
|
|
|
|
std::vector<std::pair<region_base const*, std::string>> reg_com,
|
|
|
|
std::vector<std::string> helps = {})
|
2018-12-02 11:52:04 +00:00
|
|
|
{
|
2019-03-02 08:52:00 +00:00
|
|
|
assert(!reg_com.empty());
|
|
|
|
|
2018-12-12 14:22:31 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
const auto newline = "\r\n";
|
|
|
|
#else
|
|
|
|
const char newline = '\n';
|
|
|
|
#endif
|
2018-12-02 11:52:04 +00:00
|
|
|
|
2019-03-02 08:52:00 +00:00
|
|
|
const auto line_num_width = std::max_element(reg_com.begin(), reg_com.end(),
|
|
|
|
[](std::pair<region_base const*, std::string> const& lhs,
|
|
|
|
std::pair<region_base const*, std::string> const& rhs)
|
|
|
|
{
|
|
|
|
return lhs.first->line_num().size() < rhs.first->line_num().size();
|
|
|
|
}
|
|
|
|
)->first->line_num().size();
|
|
|
|
|
|
|
|
std::ostringstream retval;
|
|
|
|
retval << message << newline;
|
|
|
|
|
|
|
|
for(std::size_t i=0; i<reg_com.size(); ++i)
|
|
|
|
{
|
|
|
|
if(i!=0 && reg_com.at(i-1).first->name() == reg_com.at(i).first->name())
|
|
|
|
{
|
2019-03-13 15:56:35 +00:00
|
|
|
retval << newline << " ..." << newline;
|
2019-03-02 08:52:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-13 15:56:35 +00:00
|
|
|
if(i != 0) {retval << newline;}
|
2019-03-02 08:52:00 +00:00
|
|
|
retval << " --> " << reg_com.at(i).first->name() << newline;
|
|
|
|
}
|
|
|
|
|
|
|
|
const region_base* const reg = reg_com.at(i).first;
|
|
|
|
const std::string& comment = reg_com.at(i).second;
|
|
|
|
|
|
|
|
|
|
|
|
retval << ' ' << std::setw(line_num_width) << reg->line_num();
|
|
|
|
retval << " | " << reg->line() << newline;
|
|
|
|
retval << make_string(line_num_width + 1, ' ');
|
|
|
|
retval << " | " << make_string(reg->before(), ' ');
|
|
|
|
|
|
|
|
if(reg->size() == 1)
|
|
|
|
{
|
|
|
|
// invalid
|
|
|
|
// ^------
|
|
|
|
retval << '^';
|
|
|
|
retval << make_string(reg->after(), '-');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// invalid
|
|
|
|
// ~~~~~~~
|
2019-04-21 07:38:08 +00:00
|
|
|
const auto underline_len = std::min(reg->size(), reg->line().size());
|
|
|
|
retval << make_string(underline_len, '~');
|
2019-03-02 08:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
retval << ' ';
|
2019-03-13 15:56:35 +00:00
|
|
|
retval << comment;
|
2019-03-02 08:52:00 +00:00
|
|
|
}
|
2018-12-02 11:52:04 +00:00
|
|
|
|
2018-12-09 04:05:09 +00:00
|
|
|
if(helps.size() != 0)
|
|
|
|
{
|
2019-03-02 08:52:00 +00:00
|
|
|
retval << newline;
|
|
|
|
retval << make_string(line_num_width + 1, ' ');
|
|
|
|
retval << " | ";
|
2018-12-09 04:05:09 +00:00
|
|
|
for(const auto help : helps)
|
|
|
|
{
|
2019-03-02 08:52:00 +00:00
|
|
|
retval << newline;
|
|
|
|
retval << "Hint: ";
|
|
|
|
retval << help;
|
2018-12-09 04:05:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-02 08:52:00 +00:00
|
|
|
return retval.str();
|
2018-12-02 11:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // detail
|
|
|
|
} // toml
|
|
|
|
#endif// TOML11_REGION_H
|