From d84bd8bc7828f4ed7d656f1bae7bbb608b80b694 Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Mon, 20 Jul 2020 02:04:33 +0300 Subject: [PATCH] renamed date_time::time_offset to just 'offset' also: - fixed natvis for date, time, time_offset, date_time --- include/toml++/toml_date_time.h | 18 ++--- include/toml++/toml_print_to_stream.h | 4 +- toml.hpp | 18 ++--- vs/toml++.natvis | 103 ++++++++++++++++++-------- 4 files changed, 94 insertions(+), 49 deletions(-) diff --git a/include/toml++/toml_date_time.h b/include/toml++/toml_date_time.h index 2fa0ff9..8e7b582 100644 --- a/include/toml++/toml_date_time.h +++ b/include/toml++/toml_date_time.h @@ -311,8 +311,8 @@ namespace toml toml::time time; /// \brief The timezone offset component. /// - /// \remarks The date_time is said to be 'local' if the time_offset is empty. - optional time_offset; + /// \remarks The date_time is said to be 'local' if the offset is empty. + optional offset; /// \brief Default-constructs a zero date-time. TOML_NODISCARD_CTOR @@ -335,19 +335,19 @@ namespace toml /// /// \param d The date component. /// \param t The time component. - /// \param offset The timezone offset. + /// \param off The timezone offset. TOML_NODISCARD_CTOR - constexpr date_time(toml::date d, toml::time t, toml::time_offset offset) noexcept + constexpr date_time(toml::date d, toml::time t, toml::time_offset off) noexcept : date{ d }, time{ t }, - time_offset{ offset } + offset{ off } {} /// \brief Returns true if this date_time does not contain timezone offset information. [[nodiscard]] constexpr bool is_local() const noexcept { - return !time_offset.has_value(); + return !offset.has_value(); } /// \brief Equality operator. @@ -356,7 +356,7 @@ namespace toml { return lhs.date == rhs.date && lhs.time == rhs.time - && lhs.time_offset == rhs.time_offset; + && lhs.offset == rhs.offset; } /// \brief Inequality operator. @@ -374,7 +374,7 @@ namespace toml return lhs.date < rhs.date; if (lhs.time != rhs.time) return lhs.time < rhs.time; - return lhs.time_offset < rhs.time_offset; + return lhs.offset < rhs.offset; } /// \brief Less-than-or-equal-to operator. @@ -385,7 +385,7 @@ namespace toml return lhs.date < rhs.date; if (lhs.time != rhs.time) return lhs.time < rhs.time; - return lhs.time_offset <= rhs.time_offset; + return lhs.offset <= rhs.offset; } /// \brief Greater-than operator. diff --git a/include/toml++/toml_print_to_stream.h b/include/toml++/toml_print_to_stream.h index a35850f..e526b66 100644 --- a/include/toml++/toml_print_to_stream.h +++ b/include/toml++/toml_print_to_stream.h @@ -326,8 +326,8 @@ namespace toml print_to_stream(val.date, stream); print_to_stream('T', stream); print_to_stream(val.time, stream); - if (val.time_offset) - print_to_stream(*val.time_offset, stream); + if (val.offset) + print_to_stream(*val.offset, stream); } TOML_PUSH_WARNINGS diff --git a/toml.hpp b/toml.hpp index 8f23f52..ad29755 100644 --- a/toml.hpp +++ b/toml.hpp @@ -1388,7 +1388,7 @@ namespace toml { toml::date date; toml::time time; - optional time_offset; + optional offset; TOML_NODISCARD_CTOR constexpr date_time() noexcept @@ -1403,16 +1403,16 @@ namespace toml {} TOML_NODISCARD_CTOR - constexpr date_time(toml::date d, toml::time t, toml::time_offset offset) noexcept + constexpr date_time(toml::date d, toml::time t, toml::time_offset off) noexcept : date{ d }, time{ t }, - time_offset{ offset } + offset{ off } {} [[nodiscard]] constexpr bool is_local() const noexcept { - return !time_offset.has_value(); + return !offset.has_value(); } [[nodiscard]] @@ -1420,7 +1420,7 @@ namespace toml { return lhs.date == rhs.date && lhs.time == rhs.time - && lhs.time_offset == rhs.time_offset; + && lhs.offset == rhs.offset; } [[nodiscard]] @@ -1436,7 +1436,7 @@ namespace toml return lhs.date < rhs.date; if (lhs.time != rhs.time) return lhs.time < rhs.time; - return lhs.time_offset < rhs.time_offset; + return lhs.offset < rhs.offset; } [[nodiscard]] @@ -1446,7 +1446,7 @@ namespace toml return lhs.date < rhs.date; if (lhs.time != rhs.time) return lhs.time < rhs.time; - return lhs.time_offset <= rhs.time_offset; + return lhs.offset <= rhs.offset; } [[nodiscard]] @@ -1807,8 +1807,8 @@ namespace toml print_to_stream(val.date, stream); print_to_stream('T', stream); print_to_stream(val.time, stream); - if (val.time_offset) - print_to_stream(*val.time_offset, stream); + if (val.offset) + print_to_stream(*val.offset, stream); } TOML_PUSH_WARNINGS diff --git a/vs/toml++.natvis b/vs/toml++.natvis index aafd4d8..386fbdf 100644 --- a/vs/toml++.natvis +++ b/vs/toml++.natvis @@ -1,8 +1,18 @@ - - {(int)year}-{(int)month}-{(int)day} + + + + + 0{y()}-0{mo()}-0{d()} + 0{y()}-0{mo()}-{d()} + 0{y()}-{mo()}-0{d()} + {y()}-0{mo()}-0{d()} + 0{y()}-{mo()}-{d()} + {y()}-0{mo()}-{d()} + {y()}-{mo()}-0{d()} + {y()}-{mo()}-{d()} year month @@ -10,8 +20,18 @@ - - {(int)hour}:{(int)minute}:{second + (nanosecond / 1000000000.0)} + + + + + 0{h()}:0{m()}:0{s()} + 0{h()}:0{m()}:{s()} + 0{h()}:{m()}:0{s()} + {h()}:0{m()}:0{s()} + 0{h()}:{m()}:{s()} + {h()}:0{m()}:{s()} + {h()}:{m()}:0{s()} + {h()}:{m()}:{s()} hour minute @@ -19,26 +39,50 @@ nanosecond - - - {(int)hours}:{(int)minutes} - -{-((int)hours)}:{(int)minutes} - -{-((int)hours)}:{-((int)minutes)} - -{(int)hours}:{-((int)minutes)} + + + + + + Z + -0{ho()}:0{mo()} + -0{ho()}:{mo()} + -{ho()}:0{mo()} + -{ho()}:{mo()} + 0{ho()}:0{mo()} + 0{ho()}:{mo()} + {ho()}:0{mo()} + {ho()}:{mo()} - hours minutes - + + {date}T{time}{offset} + {date}T{time} + + date + time + offset + + + + {{ {val_} }} val_ - + + {{ {val_,s8} }} + + val_,s8 + + + + line {line}, column {column} line @@ -46,11 +90,11 @@ - + {&bytes,s8} ({position}) - + {values} @@ -59,12 +103,12 @@ values._Mypair._Myval2._Myval2._Myhead->_Parent _Left _Right - *_Myval.second + *_Myval.second - + {values} @@ -75,22 +119,23 @@ - - {*reinterpret_cast<::toml::table*>(&storage)} - {*reinterpret_cast<::toml::abi_sf::abi_noex::parse_error*>(&storage)} + + line {source_.begin.line}: {description_,s8b} + + + + line {source_.begin.line}: {_Data._What,s8b} + + + + {*reinterpret_cast<toml::v2::table*>(&storage)} + {*reinterpret_cast<toml::v2::noex::parse_error*>(&storage)} - *reinterpret_cast<::toml::table*>(&storage) - *reinterpret_cast<::toml::abi_sf::abi_noex::parse_error*>(&storage) + *reinterpret_cast<toml::v2::table*>(&storage) + *reinterpret_cast<toml::v2::noex::parse_error*>(&storage) is_err - - line {source_.begin.line}: {description_,sb} - - - - line {source_.begin.line}: {description_,sb} -