mirror of
https://github.com/marzer/tomlplusplus.git
synced 2025-02-24 12:41:05 +00:00
renamed date_time::time_offset to just 'offset'
also: - fixed natvis for date, time, time_offset, date_time
This commit is contained in:
parent
1ecd0bd844
commit
d84bd8bc78
@ -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<toml::time_offset> time_offset;
|
||||
/// \remarks The date_time is said to be 'local' if the offset is empty.
|
||||
optional<toml::time_offset> 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.
|
||||
|
@ -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
|
||||
|
18
toml.hpp
18
toml.hpp
@ -1388,7 +1388,7 @@ namespace toml
|
||||
{
|
||||
toml::date date;
|
||||
toml::time time;
|
||||
optional<toml::time_offset> time_offset;
|
||||
optional<toml::time_offset> 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
|
||||
|
103
vs/toml++.natvis
103
vs/toml++.natvis
@ -1,8 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
|
||||
<Type Name="::toml::v2::date">
|
||||
<DisplayString>{(int)year}-{(int)month}-{(int)day}</DisplayString>
|
||||
<Type Name="toml::v2::date">
|
||||
<Intrinsic Name="y" Expression="(int)year" />
|
||||
<Intrinsic Name="mo" Expression="(int)month" />
|
||||
<Intrinsic Name="d" Expression="(int)day" />
|
||||
<DisplayString Condition="y() < 10 && mo() < 10 && d() < 10">0{y()}-0{mo()}-0{d()}</DisplayString>
|
||||
<DisplayString Condition="y() < 10 && mo() < 10">0{y()}-0{mo()}-{d()}</DisplayString>
|
||||
<DisplayString Condition="y() < 10 && d() < 10">0{y()}-{mo()}-0{d()}</DisplayString>
|
||||
<DisplayString Condition="mo() < 10 && d() < 10">{y()}-0{mo()}-0{d()}</DisplayString>
|
||||
<DisplayString Condition="y() < 10">0{y()}-{mo()}-{d()}</DisplayString>
|
||||
<DisplayString Condition="mo() < 10">{y()}-0{mo()}-{d()}</DisplayString>
|
||||
<DisplayString Condition="d() < 10">{y()}-{mo()}-0{d()}</DisplayString>
|
||||
<DisplayString>{y()}-{mo()}-{d()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="year" ExcludeView="simple">year</Item>
|
||||
<Item Name="month" ExcludeView="simple">month</Item>
|
||||
@ -10,8 +20,18 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::v2::time">
|
||||
<DisplayString>{(int)hour}:{(int)minute}:{second + (nanosecond / 1000000000.0)}</DisplayString>
|
||||
<Type Name="toml::v2::time">
|
||||
<Intrinsic Name="h" Expression="(int)hour" />
|
||||
<Intrinsic Name="m" Expression="(int)minute" />
|
||||
<Intrinsic Name="s" Expression="(int)(second + (int)(nanosecond / 1000000000.0))" />
|
||||
<DisplayString Condition="h() < 10 && m() < 10 && s() < 10">0{h()}:0{m()}:0{s()}</DisplayString>
|
||||
<DisplayString Condition="h() < 10 && m() < 10">0{h()}:0{m()}:{s()}</DisplayString>
|
||||
<DisplayString Condition="h() < 10 && s() < 10">0{h()}:{m()}:0{s()}</DisplayString>
|
||||
<DisplayString Condition="m() < 10 && s() < 10">{h()}:0{m()}:0{s()}</DisplayString>
|
||||
<DisplayString Condition="h() < 10">0{h()}:{m()}:{s()}</DisplayString>
|
||||
<DisplayString Condition="m() < 10">{h()}:0{m()}:{s()}</DisplayString>
|
||||
<DisplayString Condition="s() < 10">{h()}:{m()}:0{s()}</DisplayString>
|
||||
<DisplayString>{h()}:{m()}:{s()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="hour" ExcludeView="simple">hour</Item>
|
||||
<Item Name="minute" ExcludeView="simple">minute</Item>
|
||||
@ -19,26 +39,50 @@
|
||||
<Item Name="nanosecond" ExcludeView="simple">nanosecond</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::v2::time_offset">
|
||||
<DisplayString Condition="hours >= 0 && minutes >= 0">{(int)hours}:{(int)minutes}</DisplayString>
|
||||
<DisplayString Condition="hours < 0 && minutes >= 0">-{-((int)hours)}:{(int)minutes}</DisplayString>
|
||||
<DisplayString Condition="hours < 0 && minutes < 0">-{-((int)hours)}:{-((int)minutes)}</DisplayString>
|
||||
<DisplayString Condition="hours >= 0 && minutes < 0">-{(int)hours}:{-((int)minutes)}</DisplayString>
|
||||
|
||||
<Type Name="toml::v2::time_offset">
|
||||
<Intrinsic Name="absmin" Expression="((int)minutes ^ ((int)minutes >> 31)) - ((int)minutes >> 31)" />
|
||||
<Intrinsic Name="ho" Expression="absmin() / 60u" />
|
||||
<Intrinsic Name="mo" Expression="absmin() % 60u" />
|
||||
<DisplayString Condition="minutes == 0">Z</DisplayString>
|
||||
<DisplayString Condition="minutes < 0 && ho() < 10 && mo() < 10">-0{ho()}:0{mo()}</DisplayString>
|
||||
<DisplayString Condition="minutes < 0 && ho() < 10">-0{ho()}:{mo()}</DisplayString>
|
||||
<DisplayString Condition="minutes < 0 && mo() < 10">-{ho()}:0{mo()}</DisplayString>
|
||||
<DisplayString Condition="minutes < 0">-{ho()}:{mo()}</DisplayString>
|
||||
<DisplayString Condition="ho() < 10 && mo() < 10">0{ho()}:0{mo()}</DisplayString>
|
||||
<DisplayString Condition="ho() < 10">0{ho()}:{mo()}</DisplayString>
|
||||
<DisplayString Condition="mo() < 10">{ho()}:0{mo()}</DisplayString>
|
||||
<DisplayString>{ho()}:{mo()}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="hours" ExcludeView="simple">hours</Item>
|
||||
<Item Name="minutes" ExcludeView="simple">minutes</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::v2::value<*>">
|
||||
<Type Name="toml::v2::stdopt::date_time">
|
||||
<DisplayString Condition="offset._Has_value">{date}T{time}{offset}</DisplayString>
|
||||
<DisplayString>{date}T{time}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="date" ExcludeView="simple">date</Item>
|
||||
<Item Name="time" ExcludeView="simple">time</Item>
|
||||
<Item Name="offset" ExcludeView="simple">offset</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="toml::v2::value<*>" Priority="MediumLow">
|
||||
<DisplayString>{{ {val_} }}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="val_" ExcludeView="simple">val_</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::v2::source_position">
|
||||
<Type Name="toml::v2::value<std::basic_string<char,*>>">
|
||||
<DisplayString>{{ {val_,s8} }}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="val_" ExcludeView="simple">val_,s8</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="toml::v2::source_position">
|
||||
<DisplayString>line {line}, column {column}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="line" ExcludeView="simple">line</Item>
|
||||
@ -46,11 +90,11 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::v2::impl::utf8_codepoint">
|
||||
<Type Name="toml::v2::impl::utf8_codepoint">
|
||||
<DisplayString>{&bytes,s8} ({position})</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::table">
|
||||
<Type Name="toml::v2::table">
|
||||
<DisplayString>{values}</DisplayString>
|
||||
<Expand>
|
||||
<!-- Modified from std::map visualizer in VS 2019 stl.natvis -->
|
||||
@ -59,12 +103,12 @@
|
||||
<HeadPointer>values._Mypair._Myval2._Myval2._Myhead->_Parent</HeadPointer>
|
||||
<LeftPointer>_Left</LeftPointer>
|
||||
<RightPointer>_Right</RightPointer>
|
||||
<ValueNode Condition="_Isnil == 0" Name="[{_Myval.first}]">*_Myval.second</ValueNode>
|
||||
<ValueNode Condition="_Isnil == 0" Name="[{_Myval.first,s8}]">*_Myval.second</ValueNode>
|
||||
</TreeItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::array">
|
||||
<Type Name="toml::v2::array">
|
||||
<DisplayString>{values}</DisplayString>
|
||||
<Expand>
|
||||
<!-- Modified from std::vector visualizer in VS 2019 stl.natvis -->
|
||||
@ -75,22 +119,23 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::abi_parse_noex::parse_result">
|
||||
<DisplayString Condition="!is_err">{*reinterpret_cast<::toml::table*>(&storage)}</DisplayString>
|
||||
<DisplayString Condition="is_err">{*reinterpret_cast<::toml::abi_sf::abi_noex::parse_error*>(&storage)}</DisplayString>
|
||||
<Type Name="toml::v2::noex::parse_error">
|
||||
<DisplayString>line {source_.begin.line}: {description_,s8b}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="toml::v2::ex::parse_error">
|
||||
<DisplayString>line {source_.begin.line}: {_Data._What,s8b}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="toml::v2::noex::parse_result">
|
||||
<DisplayString Condition="!is_err">{*reinterpret_cast<toml::v2::table*>(&storage)}</DisplayString>
|
||||
<DisplayString Condition="is_err">{*reinterpret_cast<toml::v2::noex::parse_error*>(&storage)}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[table]" Condition="!is_err">*reinterpret_cast<::toml::table*>(&storage)</Item>
|
||||
<Item Name="[error]" Condition="is_err">*reinterpret_cast<::toml::abi_sf::abi_noex::parse_error*>(&storage)</Item>
|
||||
<Item Name="[table]" Condition="!is_err">*reinterpret_cast<toml::v2::table*>(&storage)</Item>
|
||||
<Item Name="[error]" Condition="is_err">*reinterpret_cast<toml::v2::noex::parse_error*>(&storage)</Item>
|
||||
<Item Name="is_err" ExcludeView="simple">is_err</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::abi_sf::abi_noex::parse_error">
|
||||
<DisplayString>line {source_.begin.line}: {description_,sb}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="::toml::abi_lf::abi_noex::parse_error">
|
||||
<DisplayString>line {source_.begin.line}: {description_,sb}</DisplayString>
|
||||
</Type>
|
||||
|
||||
</AutoVisualizer>
|
||||
|
Loading…
x
Reference in New Issue
Block a user