From b36fdf2f54c0229cf1ce986823c3424bb9e74c43 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 27 Feb 2019 01:07:00 +0900 Subject: [PATCH] refactor: remove internal fn not needed any more The function was needed to copy region information from value to value, for a useful error message. Because of the last few commits, the region information about keys are passed to insert_nested_keys that requires the function which is removed. And it turned out that the function is no longer required. It is originally a workaround, so I removed it. --- toml/value.hpp | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/toml/value.hpp b/toml/value.hpp index d71813c..d6f5f0e 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -21,8 +21,6 @@ namespace detail { // to show error messages. not recommended for users. region_base const& get_region(const value&); -// ditto. -void assign_keeping_region(value&, value); }// detail template @@ -562,9 +560,6 @@ class value // for error messages friend region_base const& detail::get_region(const value&); - // to see why it's here, see detail::insert_nested_key. - friend void detail::assign_keeping_region(value&, value); - template struct switch_cast; @@ -599,36 +594,8 @@ inline region_base const& get_region(const value& v) { return *(v.region_info_); } -// If we keep region information after assigning another toml::* types, the -// error message become different from the actual value contained. -// To avoid this kind of confusing phenomena, the default assigners clear the -// old region_info_. But this functionality is actually needed deep inside of -// parser, so if you want to see the usecase, see toml::detail::insert_nested_key -// defined in toml/parser.hpp. -inline void assign_keeping_region(value& v, value other) -{ - v.cleanup(); // this keeps region info - // keep region_info_ intact - v.type_ = other.type(); - switch(v.type()) - { - case value_t::Boolean : ::toml::value::assigner(v.boolean_ , other.boolean_ ); break; - case value_t::Integer : ::toml::value::assigner(v.integer_ , other.integer_ ); break; - case value_t::Float : ::toml::value::assigner(v.floating_ , other.floating_ ); break; - case value_t::String : ::toml::value::assigner(v.string_ , other.string_ ); break; - case value_t::OffsetDatetime: ::toml::value::assigner(v.offset_datetime_, other.offset_datetime_); break; - case value_t::LocalDatetime : ::toml::value::assigner(v.local_datetime_ , other.local_datetime_ ); break; - case value_t::LocalDate : ::toml::value::assigner(v.local_date_ , other.local_date_ ); break; - case value_t::LocalTime : ::toml::value::assigner(v.local_time_ , other.local_time_ ); break; - case value_t::Array : ::toml::value::assigner(v.array_ , other.array_ ); break; - case value_t::Table : ::toml::value::assigner(v.table_ , other.table_ ); break; - default: break; - } - return; -} }// detail - template<> struct value::switch_cast { static Boolean& invoke(value& v) {return v.boolean_;}