mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
refactor: require comments while construction
Note: at this commit, the code would not compile.
This commit is contained in:
@@ -1047,10 +1047,10 @@ class basic_value
|
|||||||
//
|
//
|
||||||
// Those constructors take detail::region that contains parse result.
|
// Those constructors take detail::region that contains parse result.
|
||||||
|
|
||||||
basic_value(boolean b, detail::region reg)
|
basic_value(boolean b, detail::region reg, std::vector<std::string> cm)
|
||||||
: type_(value_t::boolean),
|
: type_(value_t::boolean),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->boolean_, b);
|
assigner(this->boolean_, b);
|
||||||
}
|
}
|
||||||
@@ -1058,68 +1058,75 @@ class basic_value
|
|||||||
detail::conjunction<
|
detail::conjunction<
|
||||||
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>
|
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
basic_value(T i, detail::region reg)
|
basic_value(T i, detail::region reg, std::vector<std::string> cm)
|
||||||
: type_(value_t::integer),
|
: type_(value_t::integer),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->integer_, static_cast<integer>(i));
|
assigner(this->integer_, static_cast<integer>(i));
|
||||||
}
|
}
|
||||||
template<typename T, typename std::enable_if<
|
template<typename T, typename std::enable_if<
|
||||||
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
|
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
|
||||||
basic_value(T f, detail::region reg)
|
basic_value(T f, detail::region reg, std::vector<std::string> cm)
|
||||||
: type_(value_t::floating),
|
: type_(value_t::floating),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->floating_, static_cast<floating>(f));
|
assigner(this->floating_, static_cast<floating>(f));
|
||||||
}
|
}
|
||||||
basic_value(toml::string s, detail::region reg)
|
basic_value(toml::string s, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->string_, std::move(s));
|
assigner(this->string_, std::move(s));
|
||||||
}
|
}
|
||||||
basic_value(const local_date& ld, detail::region reg)
|
basic_value(const local_date& ld, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::local_date),
|
: type_(value_t::local_date),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->local_date_, ld);
|
assigner(this->local_date_, ld);
|
||||||
}
|
}
|
||||||
basic_value(const local_time& lt, detail::region reg)
|
basic_value(const local_time& lt, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::local_time),
|
: type_(value_t::local_time),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->local_time_, lt);
|
assigner(this->local_time_, lt);
|
||||||
}
|
}
|
||||||
basic_value(const local_datetime& ldt, detail::region reg)
|
basic_value(const local_datetime& ldt, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::local_datetime),
|
: type_(value_t::local_datetime),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->local_datetime_, ldt);
|
assigner(this->local_datetime_, ldt);
|
||||||
}
|
}
|
||||||
basic_value(const offset_datetime& odt, detail::region reg)
|
basic_value(const offset_datetime& odt, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::offset_datetime),
|
: type_(value_t::offset_datetime),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->offset_datetime_, odt);
|
assigner(this->offset_datetime_, odt);
|
||||||
}
|
}
|
||||||
basic_value(const array_type& ary, detail::region reg)
|
basic_value(const array_type& ary, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::array),
|
: type_(value_t::array),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->array_, ary);
|
assigner(this->array_, ary);
|
||||||
}
|
}
|
||||||
basic_value(const table_type& tab, detail::region reg)
|
basic_value(const table_type& tab, detail::region reg,
|
||||||
|
std::vector<std::string> cm)
|
||||||
: type_(value_t::table),
|
: type_(value_t::table),
|
||||||
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
region_info_(std::make_shared<detail::region>(std::move(reg))),
|
||||||
comments_(region_info_->comments())
|
comments_(std::move(cm))
|
||||||
{
|
{
|
||||||
assigner(this->table_, tab);
|
assigner(this->table_, tab);
|
||||||
}
|
}
|
||||||
@@ -1127,8 +1134,10 @@ class basic_value
|
|||||||
template<typename T, typename std::enable_if<
|
template<typename T, typename std::enable_if<
|
||||||
detail::is_exact_toml_type<T, value_type>::value,
|
detail::is_exact_toml_type<T, value_type>::value,
|
||||||
std::nullptr_t>::type = nullptr>
|
std::nullptr_t>::type = nullptr>
|
||||||
basic_value(std::pair<T, detail::region> parse_result)
|
basic_value(std::pair<T, detail::region> parse_result, std::vector<std::string> comments)
|
||||||
: basic_value(std::move(parse_result.first), std::move(parse_result.second))
|
: basic_value(std::move(parse_result.first),
|
||||||
|
std::move(parse_result.second),
|
||||||
|
std::move(comments))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// type checking and casting ============================================
|
// type checking and casting ============================================
|
||||||
|
Reference in New Issue
Block a user