feat [skip ci]: update single_include

This commit is contained in:
ToruNiina
2025-02-02 14:02:48 +00:00
parent f64ef36ffa
commit 45209aae4a

View File

@@ -5785,6 +5785,10 @@ TOML11_INLINE std::ostream& operator<<(std::ostream& os, const error_info& e)
#include <string_view>
#endif
#ifdef TOML11_ENABLE_ACCESS_CHECK
#include <atomic>
#endif
#include <cassert>
namespace toml
@@ -5823,6 +5827,11 @@ void change_region_of_value(basic_value<TC>&, const basic_value<TC>&);
template<typename TC, value_t V>
struct getter;
#ifdef TOML11_ENABLE_ACCESS_CHECK
template<typename TC>
void unset_access_flag(basic_value<TC>&);
#endif
} // detail
template<typename TypeConfig>
@@ -5854,6 +5863,9 @@ class basic_value
basic_value() noexcept
: type_(value_t::empty), empty_('\0'), region_{}, comments_{}
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
~basic_value() noexcept {this->cleanup();}
@@ -5861,6 +5873,9 @@ class basic_value
basic_value(const basic_value& v)
: type_(v.type_), region_(v.region_), comments_(v.comments_)
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{v.accessed()}
#endif
{
switch(this->type_)
{
@@ -5880,6 +5895,9 @@ class basic_value
basic_value(basic_value&& v)
: type_(v.type()), region_(std::move(v.region_)),
comments_(std::move(v.comments_))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{v.accessed()}
#endif
{
switch(this->type_)
{
@@ -5905,6 +5923,9 @@ class basic_value
this->type_ = v.type_;
this->region_ = v.region_;
this->comments_ = v.comments_;
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = v.accessed();
#endif
switch(this->type_)
{
case value_t::boolean : assigner(boolean_ , v.boolean_ ); break;
@@ -5929,6 +5950,9 @@ class basic_value
this->type_ = v.type_;
this->region_ = std::move(v.region_);
this->comments_ = std::move(v.comments_);
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = v.accessed();
#endif
switch(this->type_)
{
case value_t::boolean : assigner(boolean_ , std::move(v.boolean_ )); break;
@@ -5952,6 +5976,9 @@ class basic_value
basic_value(basic_value v, std::vector<std::string> com)
: type_(v.type()), region_(std::move(v.region_)),
comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{v.accessed()}
#endif
{
switch(this->type_)
{
@@ -5977,6 +6004,9 @@ class basic_value
: type_(other.type_),
region_(std::move(other.region_)),
comments_(std::move(other.comments_))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{other.accessed()}
#endif
{
switch(other.type_)
{
@@ -6022,6 +6052,9 @@ class basic_value
: type_(other.type_),
region_(std::move(other.region_)),
comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{other.accessed()}
#endif
{
switch(other.type_)
{
@@ -6068,6 +6101,10 @@ class basic_value
this->region_ = other.region_;
this->comments_ = comment_type(other.comments_);
this->type_ = other.type_;
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = other.accessed();
#endif
switch(other.type_)
{
// use auto-convert in constructor
@@ -6127,6 +6164,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::boolean), boolean_(boolean_storage(x, fmt)),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(boolean_type x)
{
@@ -6138,6 +6178,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::boolean;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->boolean_, boolean_storage(x, fmt));
return *this;
}
@@ -6161,6 +6204,9 @@ class basic_value
basic_value(integer_type x, integer_format_info fmt, std::vector<std::string> com, region_type reg)
: type_(value_t::integer), integer_(integer_storage(std::move(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(integer_type x)
{
@@ -6172,6 +6218,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::integer;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->integer_, integer_storage(std::move(x), std::move(fmt)));
return *this;
}
@@ -6207,6 +6256,9 @@ class basic_value
basic_value(T x, integer_format_info fmt, std::vector<std::string> com, region_type reg)
: type_(value_t::integer), integer_(integer_storage(std::move(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
template<typename T, enable_if_integer_like_t<T> = nullptr>
basic_value& operator=(T x)
@@ -6219,6 +6271,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::integer;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->integer_, integer_storage(x, std::move(fmt)));
return *this;
}
@@ -6242,6 +6297,9 @@ class basic_value
basic_value(floating_type x, floating_format_info fmt, std::vector<std::string> com, region_type reg)
: type_(value_t::floating), floating_(floating_storage(std::move(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(floating_type x)
{
@@ -6253,6 +6311,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::floating;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->floating_, floating_storage(std::move(x), std::move(fmt)));
return *this;
}
@@ -6291,6 +6352,9 @@ class basic_value
basic_value(T x, floating_format_info fmt, std::vector<std::string> com, region_type reg)
: type_(value_t::floating), floating_(floating_storage(x, std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
template<typename T, enable_if_floating_like_t<T> = nullptr>
@@ -6304,6 +6368,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::floating;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->floating_, floating_storage(x, std::move(fmt)));
return *this;
}
@@ -6328,6 +6395,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::string), string_(string_storage(std::move(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(string_type x)
{
@@ -6339,6 +6409,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::string;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->string_, string_storage(x, std::move(fmt)));
return *this;
}
@@ -6361,6 +6434,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::string), string_(string_storage(string_type(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(const typename string_type::value_type* x)
{
@@ -6372,6 +6448,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::string;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
return *this;
}
@@ -6396,6 +6475,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::string), string_(string_storage(string_type(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(string_view_type x)
{
@@ -6407,6 +6489,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::string;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
return *this;
}
@@ -6450,6 +6535,9 @@ class basic_value
: type_(value_t::string),
string_(string_storage(detail::string_conv<string_type>(x), std::move(fmt))),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
template<typename T, cxx::enable_if_t<cxx::conjunction<
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
@@ -6465,6 +6553,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::string;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->string_, string_storage(detail::string_conv<string_type>(x), std::move(fmt)));
return *this;
}
@@ -6489,6 +6580,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::local_date), local_date_(local_date_storage(x, fmt)),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(local_date_type x)
{
@@ -6500,6 +6594,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::local_date;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->local_date_, local_date_storage(x, fmt));
return *this;
}
@@ -6524,6 +6621,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::local_time), local_time_(local_time_storage(x, fmt)),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(local_time_type x)
{
@@ -6535,6 +6635,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::local_time;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->local_time_, local_time_storage(x, fmt));
return *this;
}
@@ -6572,6 +6675,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::local_time;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->local_time_, local_time_storage(local_time_type(x), std::move(fmt)));
return *this;
}
@@ -6596,6 +6702,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::local_datetime), local_datetime_(local_datetime_storage(x, fmt)),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(local_datetime_type x)
{
@@ -6607,6 +6716,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::local_datetime;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->local_datetime_, local_datetime_storage(x, fmt));
return *this;
}
@@ -6631,6 +6743,9 @@ class basic_value
std::vector<std::string> com, region_type reg)
: type_(value_t::offset_datetime), offset_datetime_(offset_datetime_storage(x, fmt)),
region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(offset_datetime_type x)
{
@@ -6642,6 +6757,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::offset_datetime;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->offset_datetime_, offset_datetime_storage(x, fmt));
return *this;
}
@@ -6674,6 +6792,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::offset_datetime;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->offset_datetime_, offset_datetime_storage(offset_datetime_type(x), fmt));
return *this;
}
@@ -6699,6 +6820,9 @@ class basic_value
: type_(value_t::array), array_(array_storage(
detail::storage<array_type>(std::move(x)), std::move(fmt)
)), region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(array_type x)
{
@@ -6710,6 +6834,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::array;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->array_, array_storage(
detail::storage<array_type>(std::move(x)), std::move(fmt)));
return *this;
@@ -6756,6 +6883,9 @@ class basic_value
std::make_move_iterator(x.end()))
), std::move(fmt)
)), region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
template<typename T, enable_if_array_like_t<T> = nullptr>
basic_value& operator=(T x)
@@ -6768,7 +6898,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::array;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
array_type a(std::make_move_iterator(x.begin()),
std::make_move_iterator(x.end()));
assigner(this->array_, array_storage(
@@ -6797,6 +6929,9 @@ class basic_value
: type_(value_t::table), table_(table_storage(
detail::storage<table_type>(std::move(x)), std::move(fmt)
)), region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
basic_value& operator=(table_type x)
{
@@ -6808,6 +6943,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::table;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
assigner(this->table_, table_storage(
detail::storage<table_type>(std::move(x)), std::move(fmt)));
return *this;
@@ -6852,6 +6990,9 @@ class basic_value
std::make_move_iterator(x.end())
)), std::move(fmt)
)), region_(std::move(reg)), comments_(std::move(com))
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
template<typename T, enable_if_table_like_t<T> = nullptr>
basic_value& operator=(T x)
@@ -6864,7 +7005,9 @@ class basic_value
this->cleanup();
this->type_ = value_t::table;
this->region_ = region_type{};
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
table_type t(std::make_move_iterator(x.begin()),
std::make_move_iterator(x.end()));
assigner(this->table_, table_storage(
@@ -6894,6 +7037,9 @@ class basic_value
basic_value& operator=(const T& ud)
{
*this = into<cxx::remove_cvref_t<T>>::template into_toml<config_type>(ud);
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
return *this;
}
@@ -6917,6 +7063,9 @@ class basic_value
basic_value& operator=(const T& ud)
{
*this = ud.into_toml();
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
return *this;
}
@@ -6940,6 +7089,9 @@ class basic_value
basic_value& operator=(const T& ud)
{
*this = ud.template into_toml<TypeConfig>();
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
return *this;
}
// }}}
@@ -6949,6 +7101,9 @@ class basic_value
// mainly for `null` extension
basic_value(detail::none_t, region_type reg) noexcept
: type_(value_t::empty), empty_('\0'), region_(std::move(reg)), comments_{}
#ifdef TOML11_ENABLE_ACCESS_CHECK
, accessed_{false}
#endif
{}
// }}}
@@ -6960,9 +7115,13 @@ class basic_value
std::nullptr_t> = nullptr>
bool is() const noexcept
{
return detail::type_to_enum<T, value_type>::value == this->type_;
return this->is(detail::type_to_enum<T, value_type>::value);
}
bool is(value_t t) const noexcept
{
this->set_accessed();
return t == this->type_;
}
bool is(value_t t) const noexcept {return t == this->type_;}
bool is_empty() const noexcept {return this->is(value_t::empty );}
bool is_boolean() const noexcept {return this->is(value_t::boolean );}
@@ -6978,6 +7137,7 @@ class basic_value
bool is_array_of_tables() const noexcept
{
this->set_accessed();
if( ! this->is_array()) {return false;}
const auto& a = this->as_array(std::nothrow); // already checked.
@@ -6997,7 +7157,11 @@ class basic_value
return true;
}
value_t type() const noexcept {return type_;}
value_t type() const noexcept
{
this->set_accessed();
return type_;
}
// }}}
@@ -7007,36 +7171,38 @@ class basic_value
detail::enum_to_type_t<T, basic_value<config_type>> const&
as(const std::nothrow_t&) const noexcept
{
this->set_accessed();
return detail::getter<config_type, T>::get_nothrow(*this);
}
template<value_t T>
detail::enum_to_type_t<T, basic_value<config_type>>&
as(const std::nothrow_t&) noexcept
{
this->set_accessed();
return detail::getter<config_type, T>::get_nothrow(*this);
}
boolean_type const& as_boolean (const std::nothrow_t&) const noexcept {return this->boolean_.value;}
integer_type const& as_integer (const std::nothrow_t&) const noexcept {return this->integer_.value;}
floating_type const& as_floating (const std::nothrow_t&) const noexcept {return this->floating_.value;}
string_type const& as_string (const std::nothrow_t&) const noexcept {return this->string_.value;}
offset_datetime_type const& as_offset_datetime(const std::nothrow_t&) const noexcept {return this->offset_datetime_.value;}
local_datetime_type const& as_local_datetime (const std::nothrow_t&) const noexcept {return this->local_datetime_.value;}
local_date_type const& as_local_date (const std::nothrow_t&) const noexcept {return this->local_date_.value;}
local_time_type const& as_local_time (const std::nothrow_t&) const noexcept {return this->local_time_.value;}
array_type const& as_array (const std::nothrow_t&) const noexcept {return this->array_.value.get();}
table_type const& as_table (const std::nothrow_t&) const noexcept {return this->table_.value.get();}
boolean_type const& as_boolean (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->boolean_.value;}
integer_type const& as_integer (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->integer_.value;}
floating_type const& as_floating (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->floating_.value;}
string_type const& as_string (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->string_.value;}
offset_datetime_type const& as_offset_datetime(const std::nothrow_t&) const noexcept {this->set_accessed(); return this->offset_datetime_.value;}
local_datetime_type const& as_local_datetime (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->local_datetime_.value;}
local_date_type const& as_local_date (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->local_date_.value;}
local_time_type const& as_local_time (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->local_time_.value;}
array_type const& as_array (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->array_.value.get();}
table_type const& as_table (const std::nothrow_t&) const noexcept {this->set_accessed(); return this->table_.value.get();}
boolean_type & as_boolean (const std::nothrow_t&) noexcept {return this->boolean_.value;}
integer_type & as_integer (const std::nothrow_t&) noexcept {return this->integer_.value;}
floating_type & as_floating (const std::nothrow_t&) noexcept {return this->floating_.value;}
string_type & as_string (const std::nothrow_t&) noexcept {return this->string_.value;}
offset_datetime_type& as_offset_datetime(const std::nothrow_t&) noexcept {return this->offset_datetime_.value;}
local_datetime_type & as_local_datetime (const std::nothrow_t&) noexcept {return this->local_datetime_.value;}
local_date_type & as_local_date (const std::nothrow_t&) noexcept {return this->local_date_.value;}
local_time_type & as_local_time (const std::nothrow_t&) noexcept {return this->local_time_.value;}
array_type & as_array (const std::nothrow_t&) noexcept {return this->array_.value.get();}
table_type & as_table (const std::nothrow_t&) noexcept {return this->table_.value.get();}
boolean_type & as_boolean (const std::nothrow_t&) noexcept {this->set_accessed(); return this->boolean_.value;}
integer_type & as_integer (const std::nothrow_t&) noexcept {this->set_accessed(); return this->integer_.value;}
floating_type & as_floating (const std::nothrow_t&) noexcept {this->set_accessed(); return this->floating_.value;}
string_type & as_string (const std::nothrow_t&) noexcept {this->set_accessed(); return this->string_.value;}
offset_datetime_type& as_offset_datetime(const std::nothrow_t&) noexcept {this->set_accessed(); return this->offset_datetime_.value;}
local_datetime_type & as_local_datetime (const std::nothrow_t&) noexcept {this->set_accessed(); return this->local_datetime_.value;}
local_date_type & as_local_date (const std::nothrow_t&) noexcept {this->set_accessed(); return this->local_date_.value;}
local_time_type & as_local_time (const std::nothrow_t&) noexcept {this->set_accessed(); return this->local_time_.value;}
array_type & as_array (const std::nothrow_t&) noexcept {this->set_accessed(); return this->array_.value.get();}
table_type & as_table (const std::nothrow_t&) noexcept {this->set_accessed(); return this->table_.value.get();}
// }}}
@@ -7059,6 +7225,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_boolean()", value_t::boolean);
}
this->set_accessed();
return this->boolean_.value;
}
integer_type const& as_integer() const
@@ -7067,6 +7234,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_integer()", value_t::integer);
}
this->set_accessed();
return this->integer_.value;
}
floating_type const& as_floating() const
@@ -7075,6 +7243,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_floating()", value_t::floating);
}
this->set_accessed();
return this->floating_.value;
}
string_type const& as_string() const
@@ -7083,6 +7252,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_string()", value_t::string);
}
this->set_accessed();
return this->string_.value;
}
offset_datetime_type const& as_offset_datetime() const
@@ -7091,6 +7261,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_offset_datetime()", value_t::offset_datetime);
}
this->set_accessed();
return this->offset_datetime_.value;
}
local_datetime_type const& as_local_datetime() const
@@ -7099,6 +7270,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_datetime()", value_t::local_datetime);
}
this->set_accessed();
return this->local_datetime_.value;
}
local_date_type const& as_local_date() const
@@ -7107,6 +7279,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_date()", value_t::local_date);
}
this->set_accessed();
return this->local_date_.value;
}
local_time_type const& as_local_time() const
@@ -7115,6 +7288,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_time()", value_t::local_time);
}
this->set_accessed();
return this->local_time_.value;
}
array_type const& as_array() const
@@ -7123,6 +7297,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_array()", value_t::array);
}
this->set_accessed();
return this->array_.value.get();
}
table_type const& as_table() const
@@ -7131,6 +7306,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_table()", value_t::table);
}
this->set_accessed();
return this->table_.value.get();
}
@@ -7143,6 +7319,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_boolean()", value_t::boolean);
}
this->set_accessed();
return this->boolean_.value;
}
integer_type& as_integer()
@@ -7151,6 +7328,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_integer()", value_t::integer);
}
this->set_accessed();
return this->integer_.value;
}
floating_type& as_floating()
@@ -7159,6 +7337,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_floating()", value_t::floating);
}
this->set_accessed();
return this->floating_.value;
}
string_type& as_string()
@@ -7167,6 +7346,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_string()", value_t::string);
}
this->set_accessed();
return this->string_.value;
}
offset_datetime_type& as_offset_datetime()
@@ -7175,6 +7355,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_offset_datetime()", value_t::offset_datetime);
}
this->set_accessed();
return this->offset_datetime_.value;
}
local_datetime_type& as_local_datetime()
@@ -7183,6 +7364,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_datetime()", value_t::local_datetime);
}
this->set_accessed();
return this->local_datetime_.value;
}
local_date_type& as_local_date()
@@ -7191,6 +7373,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_date()", value_t::local_date);
}
this->set_accessed();
return this->local_date_.value;
}
local_time_type& as_local_time()
@@ -7199,6 +7382,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_local_time()", value_t::local_time);
}
this->set_accessed();
return this->local_time_.value;
}
array_type& as_array()
@@ -7207,6 +7391,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_array()", value_t::array);
}
this->set_accessed();
return this->array_.value.get();
}
table_type& as_table()
@@ -7215,6 +7400,7 @@ class basic_value
{
this->throw_bad_cast("toml::value::as_table()", value_t::table);
}
this->set_accessed();
return this->table_.value.get();
}
@@ -7624,10 +7810,22 @@ class basic_value
comment_type const& comments() const noexcept {return this->comments_;}
comment_type& comments() noexcept {return this->comments_;}
#ifdef TOML11_ENABLE_ACCESS_CHECK
bool accessed() const {return this->accessed_.load();}
#endif
private:
// private helper functions =========================================== {{{
void set_accessed() const noexcept
{
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_.store(true);
#endif
return;
}
void cleanup() noexcept
{
switch(this->type_)
@@ -7644,6 +7842,9 @@ class basic_value
case value_t::table : { table_ .~table_storage (); break; }
default : { break; }
}
#ifdef TOML11_ENABLE_ACCESS_CHECK
this->accessed_ = false;
#endif
this->type_ = value_t::empty;
return;
}
@@ -7676,6 +7877,12 @@ class basic_value
template<typename TC>
friend class basic_value;
#ifdef TOML11_ENABLE_ACCESS_CHECK
template<typename TC>
friend void detail::unset_access_flag(basic_value<TC>&);
#endif
// }}}
private:
@@ -7710,6 +7917,10 @@ class basic_value
};
region_type region_;
comment_type comments_;
#ifdef TOML11_ENABLE_ACCESS_CHECK
mutable std::atomic<bool> accessed_;
#endif
};
template<typename TC>
@@ -8020,6 +8231,48 @@ void change_region_of_value(basic_value<TC>& dst, const basic_value<TC>& src)
return;
}
#ifdef TOML11_ENABLE_ACCESS_CHECK
template<typename TC>
void unset_access_flag(basic_value<TC>& v)
{
v.accessed_.store(false);
}
template<typename TC>
void unset_access_flag_recursively(basic_value<TC>& v)
{
switch(v.type())
{
case value_t::empty : { return unset_access_flag(v); }
case value_t::boolean : { return unset_access_flag(v); }
case value_t::integer : { return unset_access_flag(v); }
case value_t::floating : { return unset_access_flag(v); }
case value_t::string : { return unset_access_flag(v); }
case value_t::offset_datetime : { return unset_access_flag(v); }
case value_t::local_datetime : { return unset_access_flag(v); }
case value_t::local_date : { return unset_access_flag(v); }
case value_t::local_time : { return unset_access_flag(v); }
case value_t::array:
{
for(auto& elem : v.as_array())
{
unset_access_flag_recursively(elem);
}
return unset_access_flag(v);
}
case value_t::table:
{
for(auto& kv : v.as_table())
{
unset_access_flag_recursively(kv.second);
}
return unset_access_flag(v);
}
default: { return unset_access_flag(v); }
}
}
#endif
} // namespace detail
} // namespace toml
#endif // TOML11_VALUE_HPP
@@ -15763,6 +16016,11 @@ parse_file(location& loc, context<TC>& ctx)
{
return err(std::move(ctx.errors()));
}
#ifdef TOML11_ENABLE_ACCESS_CHECK
detail::unset_access_flag_recursively(root);
#endif
return ok(std::move(root));
}