mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
fix: #158 Merge branch 'gcc-wshadow'
The -Wshadow warning is avoided from the source code level
This commit is contained in:
@@ -59,7 +59,7 @@ CHECK_CXX_COMPILER_FLAG("-Wuseless-cast" COMPILER_SUPPORTS_WUSELESS_CAST)
|
|||||||
CHECK_CXX_COMPILER_FLAG("-Wdouble-promotion" COMPILER_SUPPORTS_WDOUBLE_PROMOTION)
|
CHECK_CXX_COMPILER_FLAG("-Wdouble-promotion" COMPILER_SUPPORTS_WDOUBLE_PROMOTION)
|
||||||
CHECK_CXX_COMPILER_FLAG("-Wrange-loop-analysis" COMPILER_SUPPORTS_WRANGE_LOOP_ANALYSIS)
|
CHECK_CXX_COMPILER_FLAG("-Wrange-loop-analysis" COMPILER_SUPPORTS_WRANGE_LOOP_ANALYSIS)
|
||||||
CHECK_CXX_COMPILER_FLAG("-Wundef" COMPILER_SUPPORTS_WUNDEF)
|
CHECK_CXX_COMPILER_FLAG("-Wundef" COMPILER_SUPPORTS_WUNDEF)
|
||||||
CHECK_CXX_COMPILER_FLAG("-Wshadow=local" COMPILER_SUPPORTS_WSHADOW_LOCAL)
|
CHECK_CXX_COMPILER_FLAG("-Wshadow" COMPILER_SUPPORTS_WSHADOW)
|
||||||
|
|
||||||
if(COMPILER_SUPPORTS_WALL)
|
if(COMPILER_SUPPORTS_WALL)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
@@ -73,8 +73,8 @@ endif()
|
|||||||
if(COMPILER_SUPPORTS_WERROR)
|
if(COMPILER_SUPPORTS_WERROR)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||||
endif()
|
endif()
|
||||||
if(COMPILER_SUPPORTS_WSHADOW_LOCAL)
|
if(COMPILER_SUPPORTS_WSHADOW)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow=local")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
|
||||||
endif()
|
endif()
|
||||||
if(COMPILER_SUPPORTS_WSIGN_CONVERSION)
|
if(COMPILER_SUPPORTS_WSIGN_CONVERSION)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion")
|
||||||
|
@@ -73,13 +73,13 @@ struct location final : public region_base
|
|||||||
using difference_type = typename const_iterator::difference_type;
|
using difference_type = typename const_iterator::difference_type;
|
||||||
using source_ptr = std::shared_ptr<const std::vector<char>>;
|
using source_ptr = std::shared_ptr<const std::vector<char>>;
|
||||||
|
|
||||||
location(std::string name, std::vector<char> cont)
|
location(std::string source_name, std::vector<char> cont)
|
||||||
: source_(std::make_shared<std::vector<char>>(std::move(cont))),
|
: source_(std::make_shared<std::vector<char>>(std::move(cont))),
|
||||||
line_number_(1), source_name_(std::move(name)), iter_(source_->cbegin())
|
line_number_(1), source_name_(std::move(source_name)), iter_(source_->cbegin())
|
||||||
{}
|
{}
|
||||||
location(std::string name, const std::string& cont)
|
location(std::string source_name, const std::string& cont)
|
||||||
: source_(std::make_shared<std::vector<char>>(cont.begin(), cont.end())),
|
: source_(std::make_shared<std::vector<char>>(cont.begin(), cont.end())),
|
||||||
line_number_(1), source_name_(std::move(name)), iter_(source_->cbegin())
|
line_number_(1), source_name_(std::move(source_name)), iter_(source_->cbegin())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
location(const location&) = default;
|
location(const location&) = default;
|
||||||
@@ -343,9 +343,9 @@ struct region final : public region_base
|
|||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
// unwrap the first '#' by std::next.
|
// unwrap the first '#' by std::next.
|
||||||
auto str = make_string(std::next(comment_found), iter);
|
auto s = make_string(std::next(comment_found), iter);
|
||||||
if(!str.empty() && str.back() == '\r') {str.pop_back();}
|
if(!s.empty() && s.back() == '\r') {s.pop_back();}
|
||||||
com.push_back(std::move(str));
|
com.push_back(std::move(s));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -396,9 +396,9 @@ struct region final : public region_base
|
|||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
// unwrap the first '#' by std::next.
|
// unwrap the first '#' by std::next.
|
||||||
auto str = make_string(std::next(comment_found), this->line_end());
|
auto s = make_string(std::next(comment_found), this->line_end());
|
||||||
if(!str.empty() && str.back() == '\r') {str.pop_back();}
|
if(!s.empty() && s.back() == '\r') {s.pop_back();}
|
||||||
com.push_back(std::move(str));
|
com.push_back(std::move(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,19 +26,19 @@ namespace toml
|
|||||||
// a `"` and escaping some special character is boring.
|
// a `"` and escaping some special character is boring.
|
||||||
template<typename charT, typename traits, typename Alloc>
|
template<typename charT, typename traits, typename Alloc>
|
||||||
std::basic_string<charT, traits, Alloc>
|
std::basic_string<charT, traits, Alloc>
|
||||||
format_key(const std::basic_string<charT, traits, Alloc>& key)
|
format_key(const std::basic_string<charT, traits, Alloc>& k)
|
||||||
{
|
{
|
||||||
// check the key can be a bare (unquoted) key
|
// check the key can be a bare (unquoted) key
|
||||||
detail::location loc(key, std::vector<char>(key.begin(), key.end()));
|
detail::location loc(k, std::vector<char>(k.begin(), k.end()));
|
||||||
detail::lex_unquoted_key::invoke(loc);
|
detail::lex_unquoted_key::invoke(loc);
|
||||||
if(loc.iter() == loc.end())
|
if(loc.iter() == loc.end())
|
||||||
{
|
{
|
||||||
return key; // all the tokens are consumed. the key is unquoted-key.
|
return k; // all the tokens are consumed. the key is unquoted-key.
|
||||||
}
|
}
|
||||||
|
|
||||||
//if it includes special characters, then format it in a "quoted" key.
|
//if it includes special characters, then format it in a "quoted" key.
|
||||||
std::basic_string<charT, traits, Alloc> serialized("\"");
|
std::basic_string<charT, traits, Alloc> serialized("\"");
|
||||||
for(const char c : key)
|
for(const char c : k)
|
||||||
{
|
{
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
|
@@ -21,6 +21,11 @@ class basic_value;
|
|||||||
using character = char;
|
using character = char;
|
||||||
using key = std::string;
|
using key = std::string;
|
||||||
|
|
||||||
|
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ <= 4
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wshadow"
|
||||||
|
#endif
|
||||||
|
|
||||||
using boolean = bool;
|
using boolean = bool;
|
||||||
using integer = std::int64_t;
|
using integer = std::int64_t;
|
||||||
using floating = double; // "float" is a keyward, cannot use it here.
|
using floating = double; // "float" is a keyward, cannot use it here.
|
||||||
@@ -32,12 +37,26 @@ using floating = double; // "float" is a keyward, cannot use it here.
|
|||||||
// - local_date
|
// - local_date
|
||||||
// - local_time
|
// - local_time
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
// default toml::value and default array/table. these are defined after defining
|
// default toml::value and default array/table. these are defined after defining
|
||||||
// basic_value itself.
|
// basic_value itself.
|
||||||
// using value = basic_value<discard_comments, std::unordered_map, std::vector>;
|
// using value = basic_value<discard_comments, std::unordered_map, std::vector>;
|
||||||
// using array = typename value::array_type;
|
// using array = typename value::array_type;
|
||||||
// using table = typename value::table_type;
|
// using table = typename value::table_type;
|
||||||
|
|
||||||
|
// to avoid warnings about `value_t::integer` is "shadowing" toml::integer in
|
||||||
|
// GCC -Wshadow=global.
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# if 7 <= __GNUC__
|
||||||
|
# pragma GCC diagnostic ignored "-Wshadow=global"
|
||||||
|
# else // gcc-6 or older
|
||||||
|
# pragma GCC diagnostic ignored "-Wshadow"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
enum class value_t : std::uint8_t
|
enum class value_t : std::uint8_t
|
||||||
{
|
{
|
||||||
empty = 0,
|
empty = 0,
|
||||||
@@ -52,6 +71,9 @@ enum class value_t : std::uint8_t
|
|||||||
array = 9,
|
array = 9,
|
||||||
table = 10,
|
table = 10,
|
||||||
};
|
};
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename charT, typename traits>
|
template<typename charT, typename traits>
|
||||||
inline std::basic_ostream<charT, traits>&
|
inline std::basic_ostream<charT, traits>&
|
||||||
@@ -147,4 +169,5 @@ template<typename T, typename V> struct is_exact_toml_type<T const volatile&, V>
|
|||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // toml
|
} // toml
|
||||||
|
|
||||||
#endif// TOML11_TYPES_H
|
#endif// TOML11_TYPES_H
|
||||||
|
112
toml/value.hpp
112
toml/value.hpp
@@ -281,9 +281,9 @@ class basic_value
|
|||||||
|
|
||||||
// overwrite comments ----------------------------------------------------
|
// overwrite comments ----------------------------------------------------
|
||||||
|
|
||||||
basic_value(const basic_value& v, std::vector<std::string> comments)
|
basic_value(const basic_value& v, std::vector<std::string> com)
|
||||||
: type_(v.type()), region_info_(v.region_info_),
|
: type_(v.type()), region_info_(v.region_info_),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
switch(v.type())
|
switch(v.type())
|
||||||
{
|
{
|
||||||
@@ -301,9 +301,9 @@ class basic_value
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_value(basic_value&& v, std::vector<std::string> comments)
|
basic_value(basic_value&& v, std::vector<std::string> com)
|
||||||
: type_(v.type()), region_info_(std::move(v.region_info_)),
|
: type_(v.type()), region_info_(std::move(v.region_info_)),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
switch(this->type_) // here this->type_ is already initialized
|
switch(this->type_) // here this->type_ is already initialized
|
||||||
{
|
{
|
||||||
@@ -359,9 +359,9 @@ class basic_value
|
|||||||
template<typename C,
|
template<typename C,
|
||||||
template<typename ...> class T,
|
template<typename ...> class T,
|
||||||
template<typename ...> class A>
|
template<typename ...> class A>
|
||||||
basic_value(const basic_value<C, T, A>& v, std::vector<std::string> comments)
|
basic_value(const basic_value<C, T, A>& v, std::vector<std::string> com)
|
||||||
: type_(v.type()), region_info_(v.region_info_),
|
: type_(v.type()), region_info_(v.region_info_),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
switch(v.type())
|
switch(v.type())
|
||||||
{
|
{
|
||||||
@@ -443,10 +443,10 @@ class basic_value
|
|||||||
assigner(this->boolean_, b);
|
assigner(this->boolean_, b);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
basic_value(boolean b, std::vector<std::string> comments)
|
basic_value(boolean b, std::vector<std::string> com)
|
||||||
: type_(value_t::boolean),
|
: type_(value_t::boolean),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->boolean_, b);
|
assigner(this->boolean_, b);
|
||||||
}
|
}
|
||||||
@@ -478,10 +478,10 @@ class basic_value
|
|||||||
template<typename T, typename std::enable_if<detail::conjunction<
|
template<typename T, typename std::enable_if<detail::conjunction<
|
||||||
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>>::value,
|
std::is_integral<T>, detail::negation<std::is_same<T, boolean>>>::value,
|
||||||
std::nullptr_t>::type = nullptr>
|
std::nullptr_t>::type = nullptr>
|
||||||
basic_value(T i, std::vector<std::string> comments)
|
basic_value(T i, std::vector<std::string> com)
|
||||||
: type_(value_t::integer),
|
: type_(value_t::integer),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->integer_, static_cast<integer>(i));
|
assigner(this->integer_, static_cast<integer>(i));
|
||||||
}
|
}
|
||||||
@@ -511,10 +511,10 @@ class basic_value
|
|||||||
|
|
||||||
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, std::vector<std::string> comments)
|
basic_value(T f, std::vector<std::string> com)
|
||||||
: type_(value_t::floating),
|
: type_(value_t::floating),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->floating_, f);
|
assigner(this->floating_, f);
|
||||||
}
|
}
|
||||||
@@ -535,10 +535,10 @@ class basic_value
|
|||||||
assigner(this->string_, s);
|
assigner(this->string_, s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
basic_value(toml::string s, std::vector<std::string> comments)
|
basic_value(toml::string s, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, std::move(s));
|
assigner(this->string_, std::move(s));
|
||||||
}
|
}
|
||||||
@@ -563,17 +563,17 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::move(s), kind));
|
assigner(this->string_, toml::string(std::move(s), kind));
|
||||||
}
|
}
|
||||||
basic_value(std::string s, std::vector<std::string> comments)
|
basic_value(std::string s, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::move(s)));
|
assigner(this->string_, toml::string(std::move(s)));
|
||||||
}
|
}
|
||||||
basic_value(std::string s, string_t kind, std::vector<std::string> comments)
|
basic_value(std::string s, string_t kind, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::move(s), kind));
|
assigner(this->string_, toml::string(std::move(s), kind));
|
||||||
}
|
}
|
||||||
@@ -598,17 +598,17 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::string(s), kind));
|
assigner(this->string_, toml::string(std::string(s), kind));
|
||||||
}
|
}
|
||||||
basic_value(const char* s, std::vector<std::string> comments)
|
basic_value(const char* s, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::string(s)));
|
assigner(this->string_, toml::string(std::string(s)));
|
||||||
}
|
}
|
||||||
basic_value(const char* s, string_t kind, std::vector<std::string> comments)
|
basic_value(const char* s, string_t kind, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(std::string(s), kind));
|
assigner(this->string_, toml::string(std::string(s), kind));
|
||||||
}
|
}
|
||||||
@@ -628,10 +628,10 @@ class basic_value
|
|||||||
assigner(this->string_, toml::string(s));
|
assigner(this->string_, toml::string(s));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
basic_value(std::string_view s, std::vector<std::string> comments)
|
basic_value(std::string_view s, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(s));
|
assigner(this->string_, toml::string(s));
|
||||||
}
|
}
|
||||||
@@ -641,10 +641,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(s, kind));
|
assigner(this->string_, toml::string(s, kind));
|
||||||
}
|
}
|
||||||
basic_value(std::string_view s, string_t kind, std::vector<std::string> comments)
|
basic_value(std::string_view s, string_t kind, std::vector<std::string> com)
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->string_, toml::string(s, kind));
|
assigner(this->string_, toml::string(s, kind));
|
||||||
}
|
}
|
||||||
@@ -666,10 +666,10 @@ class basic_value
|
|||||||
assigner(this->local_date_, ld);
|
assigner(this->local_date_, ld);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
basic_value(const local_date& ld, std::vector<std::string> comments)
|
basic_value(const local_date& ld, std::vector<std::string> com)
|
||||||
: type_(value_t::local_date),
|
: type_(value_t::local_date),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->local_date_, ld);
|
assigner(this->local_date_, ld);
|
||||||
}
|
}
|
||||||
@@ -682,10 +682,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->local_time_, lt);
|
assigner(this->local_time_, lt);
|
||||||
}
|
}
|
||||||
basic_value(const local_time& lt, std::vector<std::string> comments)
|
basic_value(const local_time& lt, std::vector<std::string> com)
|
||||||
: type_(value_t::local_time),
|
: type_(value_t::local_time),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->local_time_, lt);
|
assigner(this->local_time_, lt);
|
||||||
}
|
}
|
||||||
@@ -707,10 +707,10 @@ class basic_value
|
|||||||
}
|
}
|
||||||
template<typename Rep, typename Period>
|
template<typename Rep, typename Period>
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& dur,
|
basic_value(const std::chrono::duration<Rep, Period>& dur,
|
||||||
std::vector<std::string> comments)
|
std::vector<std::string> com)
|
||||||
: type_(value_t::local_time),
|
: type_(value_t::local_time),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->local_time_, local_time(dur));
|
assigner(this->local_time_, local_time(dur));
|
||||||
}
|
}
|
||||||
@@ -732,10 +732,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->local_datetime_, ldt);
|
assigner(this->local_datetime_, ldt);
|
||||||
}
|
}
|
||||||
basic_value(const local_datetime& ldt, std::vector<std::string> comments)
|
basic_value(const local_datetime& ldt, std::vector<std::string> com)
|
||||||
: type_(value_t::local_datetime),
|
: type_(value_t::local_datetime),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->local_datetime_, ldt);
|
assigner(this->local_datetime_, ldt);
|
||||||
}
|
}
|
||||||
@@ -756,10 +756,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->offset_datetime_, odt);
|
assigner(this->offset_datetime_, odt);
|
||||||
}
|
}
|
||||||
basic_value(const offset_datetime& odt, std::vector<std::string> comments)
|
basic_value(const offset_datetime& odt, std::vector<std::string> com)
|
||||||
: type_(value_t::offset_datetime),
|
: type_(value_t::offset_datetime),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->offset_datetime_, odt);
|
assigner(this->offset_datetime_, odt);
|
||||||
}
|
}
|
||||||
@@ -778,10 +778,10 @@ class basic_value
|
|||||||
assigner(this->offset_datetime_, offset_datetime(tp));
|
assigner(this->offset_datetime_, offset_datetime(tp));
|
||||||
}
|
}
|
||||||
basic_value(const std::chrono::system_clock::time_point& tp,
|
basic_value(const std::chrono::system_clock::time_point& tp,
|
||||||
std::vector<std::string> comments)
|
std::vector<std::string> com)
|
||||||
: type_(value_t::offset_datetime),
|
: type_(value_t::offset_datetime),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->offset_datetime_, offset_datetime(tp));
|
assigner(this->offset_datetime_, offset_datetime(tp));
|
||||||
}
|
}
|
||||||
@@ -802,10 +802,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->array_, ary);
|
assigner(this->array_, ary);
|
||||||
}
|
}
|
||||||
basic_value(const array_type& ary, std::vector<std::string> comments)
|
basic_value(const array_type& ary, std::vector<std::string> com)
|
||||||
: type_(value_t::array),
|
: type_(value_t::array),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->array_, ary);
|
assigner(this->array_, ary);
|
||||||
}
|
}
|
||||||
@@ -833,10 +833,10 @@ class basic_value
|
|||||||
template<typename T, typename std::enable_if<
|
template<typename T, typename std::enable_if<
|
||||||
std::is_convertible<T, value_type>::value,
|
std::is_convertible<T, value_type>::value,
|
||||||
std::nullptr_t>::type = nullptr>
|
std::nullptr_t>::type = nullptr>
|
||||||
basic_value(std::initializer_list<T> list, std::vector<std::string> comments)
|
basic_value(std::initializer_list<T> list, std::vector<std::string> com)
|
||||||
: type_(value_t::array),
|
: type_(value_t::array),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
array_type ary(list.begin(), list.end());
|
array_type ary(list.begin(), list.end());
|
||||||
assigner(this->array_, std::move(ary));
|
assigner(this->array_, std::move(ary));
|
||||||
@@ -876,10 +876,10 @@ class basic_value
|
|||||||
detail::negation<std::is_same<T, array_type>>,
|
detail::negation<std::is_same<T, array_type>>,
|
||||||
detail::is_container<T>
|
detail::is_container<T>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
basic_value(const T& list, std::vector<std::string> comments)
|
basic_value(const T& list, std::vector<std::string> com)
|
||||||
: type_(value_t::array),
|
: type_(value_t::array),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
static_assert(std::is_convertible<typename T::value_type, value_type>::value,
|
static_assert(std::is_convertible<typename T::value_type, value_type>::value,
|
||||||
"elements of a container should be convertible to toml::value");
|
"elements of a container should be convertible to toml::value");
|
||||||
@@ -915,10 +915,10 @@ class basic_value
|
|||||||
{
|
{
|
||||||
assigner(this->table_, tab);
|
assigner(this->table_, tab);
|
||||||
}
|
}
|
||||||
basic_value(const table_type& tab, std::vector<std::string> comments)
|
basic_value(const table_type& tab, std::vector<std::string> com)
|
||||||
: type_(value_t::table),
|
: type_(value_t::table),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
assigner(this->table_, tab);
|
assigner(this->table_, tab);
|
||||||
}
|
}
|
||||||
@@ -943,10 +943,10 @@ class basic_value
|
|||||||
}
|
}
|
||||||
|
|
||||||
basic_value(std::initializer_list<std::pair<key, basic_value>> list,
|
basic_value(std::initializer_list<std::pair<key, basic_value>> list,
|
||||||
std::vector<std::string> comments)
|
std::vector<std::string> com)
|
||||||
: type_(value_t::table),
|
: type_(value_t::table),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
table_type tab;
|
table_type tab;
|
||||||
for(const auto& elem : list) {tab[elem.first] = elem.second;}
|
for(const auto& elem : list) {tab[elem.first] = elem.second;}
|
||||||
@@ -982,10 +982,10 @@ class basic_value
|
|||||||
detail::negation<std::is_same<Map, table_type>>,
|
detail::negation<std::is_same<Map, table_type>>,
|
||||||
detail::is_map<Map>
|
detail::is_map<Map>
|
||||||
>::value, std::nullptr_t>::type = nullptr>
|
>::value, std::nullptr_t>::type = nullptr>
|
||||||
basic_value(const Map& mp, std::vector<std::string> comments)
|
basic_value(const Map& mp, std::vector<std::string> com)
|
||||||
: type_(value_t::table),
|
: type_(value_t::table),
|
||||||
region_info_(std::make_shared<region_base>(region_base{})),
|
region_info_(std::make_shared<region_base>(region_base{})),
|
||||||
comments_(std::move(comments))
|
comments_(std::move(com))
|
||||||
{
|
{
|
||||||
table_type tab;
|
table_type tab;
|
||||||
for(const auto& elem : mp) {tab[elem.first] = elem.second;}
|
for(const auto& elem : mp) {tab[elem.first] = elem.second;}
|
||||||
@@ -1017,8 +1017,8 @@ class basic_value
|
|||||||
|
|
||||||
template<typename T, typename std::enable_if<
|
template<typename T, typename std::enable_if<
|
||||||
detail::has_into_toml_method<T>::value, std::nullptr_t>::type = nullptr>
|
detail::has_into_toml_method<T>::value, std::nullptr_t>::type = nullptr>
|
||||||
basic_value(const T& ud, std::vector<std::string> comments)
|
basic_value(const T& ud, std::vector<std::string> com)
|
||||||
: basic_value(ud.into_toml(), std::move(comments))
|
: basic_value(ud.into_toml(), std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, typename std::enable_if<
|
template<typename T, typename std::enable_if<
|
||||||
detail::has_into_toml_method<T>::value, std::nullptr_t>::type = nullptr>
|
detail::has_into_toml_method<T>::value, std::nullptr_t>::type = nullptr>
|
||||||
@@ -1033,8 +1033,8 @@ class basic_value
|
|||||||
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
||||||
basic_value(const T& ud): basic_value(::toml::into<T>::into_toml(ud)) {}
|
basic_value(const T& ud): basic_value(::toml::into<T>::into_toml(ud)) {}
|
||||||
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
||||||
basic_value(const T& ud, std::vector<std::string> comments)
|
basic_value(const T& ud, std::vector<std::string> com)
|
||||||
: basic_value(::toml::into<T>::into_toml(ud), std::move(comments))
|
: basic_value(::toml::into<T>::into_toml(ud), std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
||||||
basic_value& operator=(const T& ud)
|
basic_value& operator=(const T& ud)
|
||||||
@@ -1134,10 +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, std::vector<std::string> comments)
|
basic_value(std::pair<T, detail::region> parse_result, std::vector<std::string> com)
|
||||||
: basic_value(std::move(parse_result.first),
|
: basic_value(std::move(parse_result.first),
|
||||||
std::move(parse_result.second),
|
std::move(parse_result.second),
|
||||||
std::move(comments))
|
std::move(com))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// type checking and casting ============================================
|
// type checking and casting ============================================
|
||||||
|
Reference in New Issue
Block a user