mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 00:38:08 +08:00
Merge branch 'master' of github.com:ToruNiina/toml11
This commit is contained in:
@@ -12,7 +12,7 @@ namespace toml
|
||||
struct exception : public std::exception
|
||||
{
|
||||
public:
|
||||
exception(const source_location& loc): loc_(loc) {}
|
||||
explicit exception(const source_location& loc): loc_(loc) {}
|
||||
virtual ~exception() noexcept override = default;
|
||||
virtual const char* what() const noexcept override {return "";}
|
||||
virtual source_location const& location() const noexcept {return loc_;}
|
||||
|
175
toml/value.hpp
175
toml/value.hpp
@@ -529,14 +529,6 @@ class basic_value
|
||||
assigner(this->boolean_, b);
|
||||
return *this;
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(boolean b, detail::region<Container> reg)
|
||||
: type_(value_t::boolean),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->boolean_, b);
|
||||
}
|
||||
basic_value(boolean b, std::vector<std::string> comments)
|
||||
: type_(value_t::boolean),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -557,19 +549,6 @@ class basic_value
|
||||
assigner(this->integer_, static_cast<integer>(i));
|
||||
}
|
||||
|
||||
template<typename T, typename Container, typename std::enable_if<
|
||||
detail::conjunction<
|
||||
std::is_integral<T>,
|
||||
detail::negation<std::is_same<T, boolean>>
|
||||
>::value, std::nullptr_t>::type = nullptr>
|
||||
basic_value(T i, detail::region<Container> reg)
|
||||
: type_(value_t::integer),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->integer_, static_cast<integer>(i));
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<detail::conjunction<
|
||||
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>>::value,
|
||||
std::nullptr_t>::type = nullptr>
|
||||
@@ -604,15 +583,6 @@ class basic_value
|
||||
assigner(this->floating_, static_cast<floating>(f));
|
||||
}
|
||||
|
||||
template<typename T, typename Container, typename std::enable_if<
|
||||
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
|
||||
basic_value(T f, detail::region<Container> reg)
|
||||
: type_(value_t::floating),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->floating_, static_cast<floating>(f));
|
||||
}
|
||||
|
||||
template<typename T, typename std::enable_if<
|
||||
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
|
||||
@@ -643,14 +613,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->string_, std::move(s));
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(toml::string s, detail::region<Container> reg)
|
||||
: type_(value_t::string),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->string_, std::move(s));
|
||||
}
|
||||
basic_value& operator=(toml::string s)
|
||||
{
|
||||
this->cleanup();
|
||||
@@ -782,14 +744,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->local_date_, ld);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_date& ld, detail::region<Container> reg)
|
||||
: type_(value_t::local_date),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_date_, ld);
|
||||
}
|
||||
basic_value& operator=(const local_date& ld)
|
||||
{
|
||||
this->cleanup();
|
||||
@@ -814,14 +768,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->local_time_, lt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_time& lt, detail::region<Container> reg)
|
||||
: type_(value_t::local_time),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_time_, lt);
|
||||
}
|
||||
basic_value(const local_time& lt, std::vector<std::string> comments)
|
||||
: type_(value_t::local_time),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -872,14 +818,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->local_datetime_, ldt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_datetime& ldt, detail::region<Container> reg)
|
||||
: type_(value_t::local_datetime),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_datetime_, ldt);
|
||||
}
|
||||
basic_value(const local_datetime& ldt, std::vector<std::string> comments)
|
||||
: type_(value_t::local_datetime),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -904,14 +842,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->offset_datetime_, odt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const offset_datetime& odt, detail::region<Container> reg)
|
||||
: type_(value_t::offset_datetime),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->offset_datetime_, odt);
|
||||
}
|
||||
basic_value(const offset_datetime& odt, std::vector<std::string> comments)
|
||||
: type_(value_t::offset_datetime),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -958,14 +888,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->array_, ary);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const array_type& ary, detail::region<Container> reg)
|
||||
: type_(value_t::array),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->array_, ary);
|
||||
}
|
||||
basic_value(const array_type& ary, std::vector<std::string> comments)
|
||||
: type_(value_t::array),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -1079,14 +1001,6 @@ class basic_value
|
||||
{
|
||||
assigner(this->table_, tab);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const table_type& tab, detail::region<Container> reg)
|
||||
: type_(value_t::table),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->table_, tab);
|
||||
}
|
||||
basic_value(const table_type& tab, std::vector<std::string> comments)
|
||||
: type_(value_t::table),
|
||||
region_info_(std::make_shared<region_base>(region_base{})),
|
||||
@@ -1216,6 +1130,93 @@ class basic_value
|
||||
}
|
||||
|
||||
// for internal use ------------------------------------------------------
|
||||
//
|
||||
// Those constructors take detail::region that contains parse result.
|
||||
|
||||
template<typename Container>
|
||||
basic_value(boolean b, detail::region<Container> reg)
|
||||
: type_(value_t::boolean),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->boolean_, b);
|
||||
}
|
||||
template<typename T, typename Container, typename std::enable_if<
|
||||
detail::conjunction<
|
||||
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>
|
||||
>::value, std::nullptr_t>::type = nullptr>
|
||||
basic_value(T i, detail::region<Container> reg)
|
||||
: type_(value_t::integer),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->integer_, static_cast<integer>(i));
|
||||
}
|
||||
template<typename T, typename Container, typename std::enable_if<
|
||||
std::is_floating_point<T>::value, std::nullptr_t>::type = nullptr>
|
||||
basic_value(T f, detail::region<Container> reg)
|
||||
: type_(value_t::floating),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->floating_, static_cast<floating>(f));
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(toml::string s, detail::region<Container> reg)
|
||||
: type_(value_t::string),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->string_, std::move(s));
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_date& ld, detail::region<Container> reg)
|
||||
: type_(value_t::local_date),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_date_, ld);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_time& lt, detail::region<Container> reg)
|
||||
: type_(value_t::local_time),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_time_, lt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const local_datetime& ldt, detail::region<Container> reg)
|
||||
: type_(value_t::local_datetime),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->local_datetime_, ldt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const offset_datetime& odt, detail::region<Container> reg)
|
||||
: type_(value_t::offset_datetime),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->offset_datetime_, odt);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const array_type& ary, detail::region<Container> reg)
|
||||
: type_(value_t::array),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->array_, ary);
|
||||
}
|
||||
template<typename Container>
|
||||
basic_value(const table_type& tab, detail::region<Container> reg)
|
||||
: type_(value_t::table),
|
||||
region_info_(std::make_shared<detail::region<Container>>(std::move(reg))),
|
||||
comments_(region_info_->comments())
|
||||
{
|
||||
assigner(this->table_, tab);
|
||||
}
|
||||
|
||||
template<typename T, typename Container, typename std::enable_if<
|
||||
detail::is_exact_toml_type<T, value_type>::value,
|
||||
@@ -1247,7 +1248,7 @@ class basic_value
|
||||
bool is_array() const noexcept {return this->is(value_t::array );}
|
||||
bool is_table() const noexcept {return this->is(value_t::table );}
|
||||
|
||||
value_t type() const {return type_;}
|
||||
value_t type() const noexcept {return type_;}
|
||||
|
||||
template<value_t T>
|
||||
typename detail::enum_to_type<T, value_type>::type& cast() &
|
||||
|
Reference in New Issue
Block a user