mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
Compare commits
12 Commits
v4.1.0
...
key-format
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da98b6558d | ||
|
|
c433577120 | ||
|
|
a39300f9d9 | ||
|
|
2193c5c201 | ||
|
|
e2bbf550a0 | ||
|
|
1809484542 | ||
|
|
0571dd74ca | ||
|
|
19199ac82c | ||
|
|
572781971f | ||
|
|
0072e740d5 | ||
|
|
4dd83fe778 | ||
|
|
fe19e7ee0a |
15
README.md
15
README.md
@@ -109,7 +109,7 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
toml11
|
toml11
|
||||||
GIT_REPOSITORY https://github.com/ToruNiina/toml11.git
|
GIT_REPOSITORY https://github.com/ToruNiina/toml11.git
|
||||||
GIT_TAG v4.0.3
|
GIT_TAG v4.1.0
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(toml11)
|
FetchContent_MakeAvailable(toml11)
|
||||||
|
|
||||||
@@ -117,6 +117,19 @@ add_executable(main main.cpp)
|
|||||||
target_link_libraries(main PRIVATE toml11::toml11)
|
target_link_libraries(main PRIVATE toml11::toml11)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### CMake Package Manager (CPM)
|
||||||
|
|
||||||
|
After [adding cpm to your project](https://github.com/cpm-cmake/CPM.cmake?tab=readme-ov-file#adding-cpm), you can use toml11 by doing:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
|
CPMAddPackage("gh:ToruNiina/toml11@4.1.0")
|
||||||
|
|
||||||
|
add_executable(main main.cpp)
|
||||||
|
target_link_libraries(main PUBLIC toml11::toml11)
|
||||||
|
```
|
||||||
|
|
||||||
### Install Using CMake
|
### Install Using CMake
|
||||||
|
|
||||||
You can install toml11 using CMake with the following steps:
|
You can install toml11 using CMake with the following steps:
|
||||||
|
|||||||
13
README_ja.md
13
README_ja.md
@@ -114,6 +114,19 @@ add_executable(main main.cpp)
|
|||||||
target_link_libraries(main PRIVATE toml11::toml11)
|
target_link_libraries(main PRIVATE toml11::toml11)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### CMake Package Manager (CPM)
|
||||||
|
|
||||||
|
[CMake package manager](https://github.com/cpm-cmake/CPM.cmake)を導入すると、以下のようにして使用することができます。
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
|
CPMAddPackage("gh:ToruNiina/toml11@4.1.0")
|
||||||
|
|
||||||
|
add_executable(main main.cpp)
|
||||||
|
target_link_libraries(main PUBLIC toml11::toml11)
|
||||||
|
```
|
||||||
|
|
||||||
### Install using CMake
|
### Install using CMake
|
||||||
|
|
||||||
以下の手順で、CMakeを使ってインストールすることができます。
|
以下の手順で、CMakeを使ってインストールすることができます。
|
||||||
|
|||||||
@@ -214,6 +214,29 @@ struct table_format_info
|
|||||||
bool operator==(const table_format_info&, const table_format_info&) noexcept;
|
bool operator==(const table_format_info&, const table_format_info&) noexcept;
|
||||||
bool operator!=(const table_format_info&, const table_format_info&) noexcept;
|
bool operator!=(const table_format_info&, const table_format_info&) noexcept;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// key
|
||||||
|
|
||||||
|
enum class key_format : std::uint8_t
|
||||||
|
{
|
||||||
|
bare = 0,
|
||||||
|
quoted = 1, // ""
|
||||||
|
quoted_literal = 2 // ''
|
||||||
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const key_format f);
|
||||||
|
std::string to_string(const key_format);
|
||||||
|
|
||||||
|
struct key_format_info
|
||||||
|
{
|
||||||
|
key_format fmt = key_format::bare;
|
||||||
|
std::int32_t spaces_before_equal = 1;
|
||||||
|
std::int32_t spaces_after_equal = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const key_format_info&, const key_format_info&) noexcept;
|
||||||
|
bool operator!=(const key_format_info&, const key_format_info&) noexcept;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wrapper
|
// wrapper
|
||||||
|
|
||||||
|
|||||||
@@ -293,5 +293,41 @@ TOML11_INLINE bool operator!=(const table_format_info& lhs, const table_format_i
|
|||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// key
|
||||||
|
|
||||||
|
TOML11_INLINE std::ostream& operator<<(std::ostream& os, const key_format f)
|
||||||
|
{
|
||||||
|
switch(f)
|
||||||
|
{
|
||||||
|
case key_format::bare : {os << "bare" ; break;}
|
||||||
|
case key_format::quoted : {os << "quoted" ; break;}
|
||||||
|
case key_format::quoted_literal : {os << "quoted_literal"; break;}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
os << "unknown key_format: " << static_cast<std::uint8_t>(f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
TOML11_INLINE std::string to_string(const key_format c)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << c;
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
TOML11_INLINE bool operator==(const key_format_info& lhs, const key_format_info& rhs) noexcept
|
||||||
|
{
|
||||||
|
return lhs.fmt == rhs.fmt &&
|
||||||
|
lhs.spaces_before_equal == rhs.spaces_before_equal &&
|
||||||
|
lhs.spaces_after_equal == rhs.spaces_after_equal ;
|
||||||
|
}
|
||||||
|
TOML11_INLINE bool operator!=(const key_format_info& lhs, const key_format_info& rhs) noexcept
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace toml
|
} // namespace toml
|
||||||
#endif // TOML11_FORMAT_IMPL_HPP
|
#endif // TOML11_FORMAT_IMPL_HPP
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ parse_boolean(location& loc, const context<TC>& ctx)
|
|||||||
// no format info for boolean
|
// no format info for boolean
|
||||||
boolean_format_info fmt;
|
boolean_format_info fmt;
|
||||||
|
|
||||||
return ok(basic_value<TC>(val, std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val, std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================================
|
/* ============================================================================
|
||||||
@@ -221,7 +221,7 @@ parse_bin_integer(location& loc, const context<TC>& ctx)
|
|||||||
const auto val = TC::parse_int(str, source_location(region(loc)), 2);
|
const auto val = TC::parse_int(str, source_location(region(loc)), 2);
|
||||||
if(val.is_ok())
|
if(val.is_ok())
|
||||||
{
|
{
|
||||||
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -273,7 +273,7 @@ parse_oct_integer(location& loc, const context<TC>& ctx)
|
|||||||
const auto val = TC::parse_int(str, source_location(region(loc)), 8);
|
const auto val = TC::parse_int(str, source_location(region(loc)), 8);
|
||||||
if(val.is_ok())
|
if(val.is_ok())
|
||||||
{
|
{
|
||||||
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -331,7 +331,7 @@ parse_hex_integer(location& loc, const context<TC>& ctx)
|
|||||||
const auto val = TC::parse_int(str, source_location(region(loc)), 16);
|
const auto val = TC::parse_int(str, source_location(region(loc)), 16);
|
||||||
if(val.is_ok())
|
if(val.is_ok())
|
||||||
{
|
{
|
||||||
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -402,7 +402,7 @@ parse_dec_integer(location& loc, const context<TC>& ctx)
|
|||||||
fmt.suffix = sfx;
|
fmt.suffix = sfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val.as_ok(), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
@@ -667,7 +667,7 @@ parse_floating(location& loc, const context<TC>& ctx)
|
|||||||
fmt.suffix = sfx;
|
fmt.suffix = sfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok(basic_value<TC>(val, std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val, std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================================
|
/* ============================================================================
|
||||||
@@ -785,7 +785,7 @@ parse_local_date(location& loc, const context<TC>& ctx)
|
|||||||
auto fmt = std::move(std::get<1>(val_fmt_reg.unwrap()));
|
auto fmt = std::move(std::get<1>(val_fmt_reg.unwrap()));
|
||||||
auto reg = std::move(std::get<2>(val_fmt_reg.unwrap()));
|
auto reg = std::move(std::get<2>(val_fmt_reg.unwrap()));
|
||||||
|
|
||||||
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// all the offset_datetime, local_datetime, local_time parses date part.
|
// all the offset_datetime, local_datetime, local_time parses date part.
|
||||||
@@ -954,7 +954,7 @@ parse_local_time(location& loc, const context<TC>& ctx)
|
|||||||
auto fmt = std::move(std::get<1>(val_fmt_reg.unwrap()));
|
auto fmt = std::move(std::get<1>(val_fmt_reg.unwrap()));
|
||||||
auto reg = std::move(std::get<2>(val_fmt_reg.unwrap()));
|
auto reg = std::move(std::get<2>(val_fmt_reg.unwrap()));
|
||||||
|
|
||||||
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
@@ -1013,7 +1013,7 @@ parse_local_datetime(location& loc, const context<TC>& ctx)
|
|||||||
local_datetime val(std::get<0>(date_fmt_reg.unwrap()),
|
local_datetime val(std::get<0>(date_fmt_reg.unwrap()),
|
||||||
std::get<0>(time_fmt_reg.unwrap()));
|
std::get<0>(time_fmt_reg.unwrap()));
|
||||||
|
|
||||||
return ok(basic_value<TC>(val, std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val, std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
@@ -1140,7 +1140,7 @@ parse_offset_datetime(location& loc, const context<TC>& ctx)
|
|||||||
std::get<0>(time_fmt_reg.unwrap())),
|
std::get<0>(time_fmt_reg.unwrap())),
|
||||||
offset);
|
offset);
|
||||||
|
|
||||||
return ok(basic_value<TC>(val, std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(val, std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================================
|
/* ============================================================================
|
||||||
@@ -1401,7 +1401,7 @@ parse_ml_basic_string(location& loc, const context<TC>& ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ok(basic_value<TC>(
|
return ok(basic_value<TC>(
|
||||||
std::move(val), std::move(fmt), {}, std::move(reg)
|
std::move(val), std::move(fmt), {}, {}, std::move(reg)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1481,7 +1481,7 @@ parse_basic_string(location& loc, const context<TC>& ctx)
|
|||||||
auto val = std::move(val_res.unwrap().first );
|
auto val = std::move(val_res.unwrap().first );
|
||||||
auto reg = std::move(val_res.unwrap().second);
|
auto reg = std::move(val_res.unwrap().second);
|
||||||
|
|
||||||
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, std::move(reg)));
|
return ok(basic_value<TC>(std::move(val), std::move(fmt), {}, {}, std::move(reg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
@@ -1528,7 +1528,7 @@ parse_ml_literal_string(location& loc, const context<TC>& ctx)
|
|||||||
string_type val(str.begin(), str.end());
|
string_type val(str.begin(), str.end());
|
||||||
|
|
||||||
return ok(basic_value<TC>(
|
return ok(basic_value<TC>(
|
||||||
std::move(val), std::move(fmt), {}, std::move(reg)
|
std::move(val), std::move(fmt), {}, {}, std::move(reg)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1581,7 +1581,7 @@ parse_literal_string(location& loc, const context<TC>& ctx)
|
|||||||
auto reg = std::move(val_res.unwrap().second);
|
auto reg = std::move(val_res.unwrap().second);
|
||||||
|
|
||||||
return ok(basic_value<TC>(
|
return ok(basic_value<TC>(
|
||||||
std::move(val), std::move(fmt), {}, std::move(reg)
|
std::move(val), std::move(fmt), {}, {}, std::move(reg)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1793,6 +1793,9 @@ parse_key_value_pair(location& loc, context<TC>& ctx)
|
|||||||
// loc = first;
|
// loc = first;
|
||||||
return err(v_res.unwrap_err());
|
return err(v_res.unwrap_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set key reg/fmt
|
||||||
|
|
||||||
return ok(std::make_pair(std::move(key_res.unwrap()), std::move(v_res.unwrap())));
|
return ok(std::make_pair(std::move(key_res.unwrap()), std::move(v_res.unwrap())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2049,7 +2052,7 @@ parse_array(location& loc, context<TC>& ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ok(basic_value<TC>(
|
return ok(basic_value<TC>(
|
||||||
std::move(val), std::move(fmt), {}, region(first, loc)
|
std::move(val), std::move(fmt), {}, {}, region(first, loc)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2206,7 +2209,7 @@ insert_value(const inserting_value_kind kind,
|
|||||||
fmt.fmt = table_format::implicit;
|
fmt.fmt = table_format::implicit;
|
||||||
}
|
}
|
||||||
current_table.emplace(key, value_type(
|
current_table.emplace(key, value_type(
|
||||||
table_type{}, fmt, std::vector<std::string>{}, key_reg));
|
table_type{}, fmt, std::vector<std::string>{}, {}, key_reg));
|
||||||
|
|
||||||
assert(current_table.at(key).is_table());
|
assert(current_table.at(key).is_table());
|
||||||
current_table_ptr = std::addressof(current_table.at(key).as_table());
|
current_table_ptr = std::addressof(current_table.at(key).as_table());
|
||||||
@@ -2353,7 +2356,8 @@ insert_value(const inserting_value_kind kind,
|
|||||||
|
|
||||||
current_table.emplace(key, value_type(
|
current_table.emplace(key, value_type(
|
||||||
array_type{ std::move(val) }, std::move(fmt),
|
array_type{ std::move(val) }, std::move(fmt),
|
||||||
std::vector<std::string>{}, std::move(key_reg)
|
std::vector<std::string>{}, key_format_info{},
|
||||||
|
key_reg, key_reg
|
||||||
));
|
));
|
||||||
|
|
||||||
assert( ! current_table.at(key).as_array().empty());
|
assert( ! current_table.at(key).as_array().empty());
|
||||||
@@ -2604,7 +2608,7 @@ parse_inline_table(location& loc, context<TC>& ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
basic_value<TC> retval(
|
basic_value<TC> retval(
|
||||||
std::move(table), std::move(fmt), {}, region(first, loc));
|
std::move(table), std::move(fmt), {}, {}, region(first, loc));
|
||||||
|
|
||||||
return ok(std::move(retval));
|
return ok(std::move(retval));
|
||||||
}
|
}
|
||||||
@@ -3171,10 +3175,10 @@ parse_file(location& loc, context<TC>& ctx)
|
|||||||
|
|
||||||
if(loc.eof())
|
if(loc.eof())
|
||||||
{
|
{
|
||||||
return ok(value_type(table_type(), table_format_info{}, {}, region(loc)));
|
return ok(value_type(table_type(), table_format_info{}, {}, {}, region(loc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type root(table_type(), table_format_info{}, {}, region(loc));
|
value_type root(table_type(), table_format_info{}, {}, {}, region(loc));
|
||||||
root.as_table_fmt().fmt = table_format::multiline;
|
root.as_table_fmt().fmt = table_format::multiline;
|
||||||
root.as_table_fmt().indent_type = indent_char::none;
|
root.as_table_fmt().indent_type = indent_char::none;
|
||||||
|
|
||||||
@@ -3279,7 +3283,7 @@ parse_file(location& loc, context<TC>& ctx)
|
|||||||
table_format_info fmt;
|
table_format_info fmt;
|
||||||
fmt.fmt = table_format::multiline;
|
fmt.fmt = table_format::multiline;
|
||||||
fmt.indent_type = indent_char::none;
|
fmt.indent_type = indent_char::none;
|
||||||
auto tab = value_type(table_type{}, std::move(fmt), std::move(com), reg);
|
auto tab = value_type(table_type{}, std::move(fmt), std::move(com), {}, reg);
|
||||||
|
|
||||||
auto inserted = insert_value(inserting_value_kind::array_table,
|
auto inserted = insert_value(inserting_value_kind::array_table,
|
||||||
std::addressof(root.as_table()),
|
std::addressof(root.as_table()),
|
||||||
@@ -3366,7 +3370,7 @@ parse_file(location& loc, context<TC>& ctx)
|
|||||||
table_format_info fmt;
|
table_format_info fmt;
|
||||||
fmt.fmt = table_format::multiline;
|
fmt.fmt = table_format::multiline;
|
||||||
fmt.indent_type = indent_char::none;
|
fmt.indent_type = indent_char::none;
|
||||||
auto tab = value_type(table_type{}, std::move(fmt), std::move(com), reg);
|
auto tab = value_type(table_type{}, std::move(fmt), std::move(com), {}, reg);
|
||||||
|
|
||||||
auto inserted = insert_value(inserting_value_kind::std_table,
|
auto inserted = insert_value(inserting_value_kind::std_table,
|
||||||
std::addressof(root.as_table()),
|
std::addressof(root.as_table()),
|
||||||
@@ -3441,7 +3445,7 @@ parse_impl(std::vector<location::char_type> cs, std::string fname, const spec& s
|
|||||||
{
|
{
|
||||||
auto src = std::make_shared<std::vector<location::char_type>>(std::move(cs));
|
auto src = std::make_shared<std::vector<location::char_type>>(std::move(cs));
|
||||||
location loc(std::move(src), std::move(fname));
|
location loc(std::move(src), std::move(fname));
|
||||||
return ok(value_type(table_type(), table_format_info{}, std::vector<std::string>{}, region(loc)));
|
return ok(value_type(table_type(), table_format_info{}, std::vector<std::string>{}, {}, region(loc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// to simplify parser, add newline at the end if there is no LF.
|
// to simplify parser, add newline at the end if there is no LF.
|
||||||
@@ -3526,7 +3530,7 @@ try_parse(std::istream& is, std::string fname = "unknown file", spec s = spec::d
|
|||||||
// read whole file as a sequence of char
|
// read whole file as a sequence of char
|
||||||
assert(fsize >= 0);
|
assert(fsize >= 0);
|
||||||
std::vector<detail::location::char_type> letters(static_cast<std::size_t>(fsize), '\0');
|
std::vector<detail::location::char_type> letters(static_cast<std::size_t>(fsize), '\0');
|
||||||
is.read(reinterpret_cast<char*>(letters.data()), fsize);
|
is.read(reinterpret_cast<char*>(letters.data()), static_cast<std::streamsize>(fsize));
|
||||||
|
|
||||||
return detail::parse_impl<TC>(std::move(letters), std::move(fname), std::move(s));
|
return detail::parse_impl<TC>(std::move(letters), std::move(fname), std::move(s));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ error_info make_not_found_error(const basic_value<TC>&, const std::string&, cons
|
|||||||
template<typename TC>
|
template<typename TC>
|
||||||
void change_region_of_value(basic_value<TC>&, const basic_value<TC>&);
|
void change_region_of_value(basic_value<TC>&, const basic_value<TC>&);
|
||||||
|
|
||||||
|
template<typename TC>
|
||||||
|
void change_region_of_key(basic_value<TC>&, region);
|
||||||
|
|
||||||
template<typename TC, value_t V>
|
template<typename TC, value_t V>
|
||||||
struct getter;
|
struct getter;
|
||||||
} // detail
|
} // detail
|
||||||
@@ -85,14 +88,14 @@ class basic_value
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
basic_value() noexcept
|
basic_value() noexcept
|
||||||
: type_(value_t::empty), empty_('\0'), region_{}, comments_{}
|
: type_(value_t::empty), empty_('\0'), region_{}, comments_{}, key_region_{}, key_fmt_{}
|
||||||
{}
|
{}
|
||||||
~basic_value() noexcept {this->cleanup();}
|
~basic_value() noexcept {this->cleanup();}
|
||||||
|
|
||||||
// copy/move constructor/assigner ===================================== {{{
|
// copy/move constructor/assigner ===================================== {{{
|
||||||
|
|
||||||
basic_value(const basic_value& v)
|
basic_value(const basic_value& v)
|
||||||
: type_(v.type_), region_(v.region_), comments_(v.comments_)
|
: type_(v.type_), region_(v.region_), comments_(v.comments_), key_region_(v.key_region_), key_fmt_(v.key_fmt_)
|
||||||
{
|
{
|
||||||
switch(this->type_)
|
switch(this->type_)
|
||||||
{
|
{
|
||||||
@@ -111,7 +114,8 @@ class basic_value
|
|||||||
}
|
}
|
||||||
basic_value(basic_value&& v)
|
basic_value(basic_value&& v)
|
||||||
: type_(v.type()), region_(std::move(v.region_)),
|
: type_(v.type()), region_(std::move(v.region_)),
|
||||||
comments_(std::move(v.comments_))
|
comments_(std::move(v.comments_)),
|
||||||
|
key_region_(v.key_region_), key_fmt_(v.key_fmt_)
|
||||||
{
|
{
|
||||||
switch(this->type_)
|
switch(this->type_)
|
||||||
{
|
{
|
||||||
@@ -137,6 +141,8 @@ class basic_value
|
|||||||
this->type_ = v.type_;
|
this->type_ = v.type_;
|
||||||
this->region_ = v.region_;
|
this->region_ = v.region_;
|
||||||
this->comments_ = v.comments_;
|
this->comments_ = v.comments_;
|
||||||
|
this->key_region_ = v.key_region_;
|
||||||
|
this->key_fmt_ = v.key_fmt_;
|
||||||
switch(this->type_)
|
switch(this->type_)
|
||||||
{
|
{
|
||||||
case value_t::boolean : assigner(boolean_ , v.boolean_ ); break;
|
case value_t::boolean : assigner(boolean_ , v.boolean_ ); break;
|
||||||
@@ -161,6 +167,8 @@ class basic_value
|
|||||||
this->type_ = v.type_;
|
this->type_ = v.type_;
|
||||||
this->region_ = std::move(v.region_);
|
this->region_ = std::move(v.region_);
|
||||||
this->comments_ = std::move(v.comments_);
|
this->comments_ = std::move(v.comments_);
|
||||||
|
this->key_region_ = std::move(v.key_region_);
|
||||||
|
this->key_fmt_ = std::move(v.key_fmt_);
|
||||||
switch(this->type_)
|
switch(this->type_)
|
||||||
{
|
{
|
||||||
case value_t::boolean : assigner(boolean_ , std::move(v.boolean_ )); break;
|
case value_t::boolean : assigner(boolean_ , std::move(v.boolean_ )); break;
|
||||||
@@ -183,7 +191,8 @@ class basic_value
|
|||||||
|
|
||||||
basic_value(basic_value v, std::vector<std::string> com)
|
basic_value(basic_value v, std::vector<std::string> com)
|
||||||
: type_(v.type()), region_(std::move(v.region_)),
|
: type_(v.type()), region_(std::move(v.region_)),
|
||||||
comments_(std::move(com))
|
comments_(std::move(com)),
|
||||||
|
key_region_(v.key_region_), key_fmt_(v.key_fmt_)
|
||||||
{
|
{
|
||||||
switch(this->type_)
|
switch(this->type_)
|
||||||
{
|
{
|
||||||
@@ -208,7 +217,9 @@ class basic_value
|
|||||||
basic_value(basic_value<TI> other)
|
basic_value(basic_value<TI> other)
|
||||||
: type_(other.type_),
|
: type_(other.type_),
|
||||||
region_(std::move(other.region_)),
|
region_(std::move(other.region_)),
|
||||||
comments_(std::move(other.comments_))
|
comments_(std::move(other.comments_)),
|
||||||
|
key_region_(std::move(other.key_region_)),
|
||||||
|
key_fmt_(std::move(other.key_fmt_))
|
||||||
{
|
{
|
||||||
switch(other.type_)
|
switch(other.type_)
|
||||||
{
|
{
|
||||||
@@ -253,7 +264,9 @@ class basic_value
|
|||||||
basic_value(basic_value<TI> other, std::vector<std::string> com)
|
basic_value(basic_value<TI> other, std::vector<std::string> com)
|
||||||
: type_(other.type_),
|
: type_(other.type_),
|
||||||
region_(std::move(other.region_)),
|
region_(std::move(other.region_)),
|
||||||
comments_(std::move(com))
|
comments_(std::move(com)),
|
||||||
|
key_region_(std::move(other.key_region_)),
|
||||||
|
key_fmt_(std::move(other.key_fmt_))
|
||||||
{
|
{
|
||||||
switch(other.type_)
|
switch(other.type_)
|
||||||
{
|
{
|
||||||
@@ -299,6 +312,8 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->region_ = other.region_;
|
this->region_ = other.region_;
|
||||||
this->comments_ = comment_type(other.comments_);
|
this->comments_ = comment_type(other.comments_);
|
||||||
|
this->key_region_ = other.key_region_;
|
||||||
|
this->key_fmt_ = other.key_fmt_;
|
||||||
this->type_ = other.type_;
|
this->type_ = other.type_;
|
||||||
switch(other.type_)
|
switch(other.type_)
|
||||||
{
|
{
|
||||||
@@ -343,22 +358,18 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (boolean) ============================================== {{{
|
// constructor (boolean) ============================================== {{{
|
||||||
|
|
||||||
basic_value(boolean_type x)
|
|
||||||
: basic_value(x, boolean_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(boolean_type x, boolean_format_info fmt)
|
|
||||||
: basic_value(x, fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(boolean_type x, std::vector<std::string> com)
|
basic_value(boolean_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, boolean_format_info{}, std::move(com), region_type{})
|
: basic_value(x, boolean_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(boolean_type x, boolean_format_info fmt, std::vector<std::string> com)
|
basic_value(boolean_type x,
|
||||||
: basic_value(x, fmt, std::move(com), region_type{})
|
boolean_format_info fmt = boolean_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(boolean_type x, boolean_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::boolean), boolean_(boolean_storage(x, fmt)),
|
: type_(value_t::boolean), boolean_(boolean_storage(x, fmt)),
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(key_reg), key_fmt_(key_fmt)
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(boolean_type x)
|
basic_value& operator=(boolean_type x)
|
||||||
{
|
{
|
||||||
@@ -370,6 +381,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::boolean;
|
this->type_ = value_t::boolean;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->boolean_, boolean_storage(x, fmt));
|
assigner(this->boolean_, boolean_storage(x, fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -378,21 +390,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (integer) ============================================== {{{
|
// constructor (integer) ============================================== {{{
|
||||||
|
|
||||||
basic_value(integer_type x)
|
|
||||||
: basic_value(std::move(x), integer_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(integer_type x, integer_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(integer_type x, std::vector<std::string> com)
|
basic_value(integer_type x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), integer_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), integer_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(integer_type x, integer_format_info fmt, std::vector<std::string> com)
|
basic_value(integer_type x,
|
||||||
: basic_value(std::move(x), std::move(fmt), std::move(com), region_type{})
|
integer_format_info fmt = integer_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(integer_type x, integer_format_info fmt, std::vector<std::string> com, region_type reg)
|
key_format_info key_fmt = key_format_info{},
|
||||||
: type_(value_t::integer), integer_(integer_storage(std::move(x), std::move(fmt))),
|
region_type reg = region_type{},
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_type key_reg = region_type{})
|
||||||
|
: type_(value_t::integer),
|
||||||
|
integer_(integer_storage(std::move(x), std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(integer_type x)
|
basic_value& operator=(integer_type x)
|
||||||
{
|
{
|
||||||
@@ -404,6 +414,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::integer;
|
this->type_ = value_t::integer;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->integer_, integer_storage(std::move(x), std::move(fmt)));
|
assigner(this->integer_, integer_storage(std::move(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -419,26 +430,21 @@ class basic_value
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
|
||||||
basic_value(T x)
|
|
||||||
: basic_value(std::move(x), integer_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
|
||||||
basic_value(T x, integer_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
||||||
basic_value(T x, std::vector<std::string> com)
|
basic_value(T x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), integer_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), integer_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
||||||
basic_value(T x, integer_format_info fmt, std::vector<std::string> com)
|
basic_value(T x,
|
||||||
: basic_value(std::move(x), std::move(fmt), std::move(com), region_type{})
|
integer_format_info fmt = integer_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
key_format_info key_fmt = key_format_info{},
|
||||||
basic_value(T x, integer_format_info fmt, std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::integer), integer_(integer_storage(std::move(x), std::move(fmt))),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::integer),
|
||||||
|
integer_(integer_storage(std::move(x), std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
template<typename T, enable_if_integer_like_t<T> = nullptr>
|
||||||
basic_value& operator=(T x)
|
basic_value& operator=(T x)
|
||||||
@@ -451,6 +457,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::integer;
|
this->type_ = value_t::integer;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->integer_, integer_storage(x, std::move(fmt)));
|
assigner(this->integer_, integer_storage(x, std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -459,21 +466,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (floating) ============================================= {{{
|
// constructor (floating) ============================================= {{{
|
||||||
|
|
||||||
basic_value(floating_type x)
|
|
||||||
: basic_value(std::move(x), floating_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(floating_type x, floating_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(floating_type x, std::vector<std::string> com)
|
basic_value(floating_type x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), floating_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), floating_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(floating_type x, floating_format_info fmt, std::vector<std::string> com)
|
basic_value(floating_type x,
|
||||||
: basic_value(std::move(x), std::move(fmt), std::move(com), region_type{})
|
floating_format_info fmt = floating_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(floating_type x, floating_format_info fmt, std::vector<std::string> com, region_type reg)
|
key_format_info key_fmt = key_format_info{},
|
||||||
: type_(value_t::floating), floating_(floating_storage(std::move(x), std::move(fmt))),
|
region_type reg = region_type{},
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_type key_reg = region_type{})
|
||||||
|
: type_(value_t::floating),
|
||||||
|
floating_(floating_storage(std::move(x), std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(floating_type x)
|
basic_value& operator=(floating_type x)
|
||||||
{
|
{
|
||||||
@@ -485,6 +490,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::floating;
|
this->type_ = value_t::floating;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key_region/fmt is kept
|
||||||
assigner(this->floating_, floating_storage(std::move(x), std::move(fmt)));
|
assigner(this->floating_, floating_storage(std::move(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -499,32 +505,22 @@ class basic_value
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
|
||||||
basic_value(T x)
|
|
||||||
: basic_value(x, floating_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
|
||||||
basic_value(T x, floating_format_info fmt)
|
|
||||||
: basic_value(x, std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
||||||
basic_value(T x, std::vector<std::string> com)
|
basic_value(T x, std::vector<std::string> com)
|
||||||
: basic_value(x, floating_format_info{}, std::move(com), region_type{})
|
: basic_value(x, floating_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
||||||
basic_value(T x, floating_format_info fmt, std::vector<std::string> com)
|
basic_value(T x,
|
||||||
: basic_value(x, std::move(fmt), std::move(com), region_type{})
|
floating_format_info fmt = floating_format_info{},
|
||||||
|
std::vector<std::string> com = {},
|
||||||
|
key_format_info key_fmt = key_format_info{},
|
||||||
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
|
: type_(value_t::floating),
|
||||||
|
floating_(floating_storage(x, std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
|
||||||
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))
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
template<typename T, enable_if_floating_like_t<T> = nullptr>
|
||||||
basic_value& operator=(T x)
|
basic_value& operator=(T x)
|
||||||
{
|
{
|
||||||
@@ -536,6 +532,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::floating;
|
this->type_ = value_t::floating;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->floating_, floating_storage(x, std::move(fmt)));
|
assigner(this->floating_, floating_storage(x, std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -544,22 +541,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (string) =============================================== {{{
|
// constructor (string) =============================================== {{{
|
||||||
|
|
||||||
basic_value(string_type x)
|
|
||||||
: basic_value(std::move(x), string_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(string_type x, string_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(string_type x, std::vector<std::string> com)
|
basic_value(string_type x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), string_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), string_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(string_type x, string_format_info fmt, std::vector<std::string> com)
|
basic_value(string_type x,
|
||||||
: basic_value(std::move(x), std::move(fmt), std::move(com), region_type{})
|
string_format_info fmt = string_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(string_type x, string_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::string), string_(string_storage(std::move(x), std::move(fmt))),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::string),
|
||||||
|
string_(string_storage(std::move(x), std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(string_type x)
|
basic_value& operator=(string_type x)
|
||||||
{
|
{
|
||||||
@@ -571,28 +565,26 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::string;
|
this->type_ = value_t::string;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->string_, string_storage(x, std::move(fmt)));
|
assigner(this->string_, string_storage(x, std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "string literal"
|
// "string literal"
|
||||||
|
|
||||||
basic_value(const typename string_type::value_type* x)
|
|
||||||
: basic_value(x, string_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(const typename string_type::value_type* x, string_format_info fmt)
|
|
||||||
: basic_value(x, std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(const typename string_type::value_type* x, std::vector<std::string> com)
|
basic_value(const typename string_type::value_type* x, std::vector<std::string> com)
|
||||||
: basic_value(x, string_format_info{}, std::move(com), region_type{})
|
: basic_value(x, string_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(const typename string_type::value_type* x, string_format_info fmt, std::vector<std::string> com)
|
basic_value(const typename string_type::value_type* x,
|
||||||
: basic_value(x, std::move(fmt), std::move(com), region_type{})
|
string_format_info fmt = string_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(const typename string_type::value_type* x, string_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::string), string_(string_storage(string_type(x), std::move(fmt))),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::string),
|
||||||
|
string_(string_storage(string_type(x), std::move(fmt))),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(const typename string_type::value_type* x)
|
basic_value& operator=(const typename string_type::value_type* x)
|
||||||
{
|
{
|
||||||
@@ -604,6 +596,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::string;
|
this->type_ = value_t::string;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
|
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -612,22 +605,18 @@ class basic_value
|
|||||||
using string_view_type = std::basic_string_view<
|
using string_view_type = std::basic_string_view<
|
||||||
typename string_type::value_type, typename string_type::traits_type>;
|
typename string_type::value_type, typename string_type::traits_type>;
|
||||||
|
|
||||||
basic_value(string_view_type x)
|
|
||||||
: basic_value(x, string_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(string_view_type x, string_format_info fmt)
|
|
||||||
: basic_value(x, std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(string_view_type x, std::vector<std::string> com)
|
basic_value(string_view_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, string_format_info{}, std::move(com), region_type{})
|
: basic_value(x, string_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(string_view_type x, string_format_info fmt, std::vector<std::string> com)
|
basic_value(string_view_type x,
|
||||||
: basic_value(x, std::move(fmt), std::move(com), region_type{})
|
string_format_info fmt = string_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(string_view_type x, string_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::string), string_(string_storage(string_type(x), std::move(fmt))),
|
: type_(value_t::string), string_(string_storage(string_type(x), std::move(fmt))),
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(string_view_type x)
|
basic_value& operator=(string_view_type x)
|
||||||
{
|
{
|
||||||
@@ -639,49 +628,34 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::string;
|
this->type_ = value_t::string;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
|
assigner(this->string_, string_storage(string_type(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOML11_HAS_STRING_VIEW
|
#endif // TOML11_HAS_STRING_VIEW
|
||||||
|
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
|
||||||
detail::is_1byte_std_basic_string<T>
|
|
||||||
>::value, std::nullptr_t> = nullptr>
|
|
||||||
basic_value(const T& x)
|
|
||||||
: basic_value(x, string_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
|
||||||
detail::is_1byte_std_basic_string<T>
|
|
||||||
>::value, std::nullptr_t> = nullptr>
|
|
||||||
basic_value(const T& x, string_format_info fmt)
|
|
||||||
: basic_value(x, std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
||||||
detail::is_1byte_std_basic_string<T>
|
detail::is_1byte_std_basic_string<T>
|
||||||
>::value, std::nullptr_t> = nullptr>
|
>::value, std::nullptr_t> = nullptr>
|
||||||
basic_value(const T& x, std::vector<std::string> com)
|
basic_value(const T& x, std::vector<std::string> com)
|
||||||
: basic_value(x, string_format_info{}, std::move(com), region_type{})
|
: basic_value(x, string_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
||||||
detail::is_1byte_std_basic_string<T>
|
detail::is_1byte_std_basic_string<T>
|
||||||
>::value, std::nullptr_t> = nullptr>
|
>::value, std::nullptr_t> = nullptr>
|
||||||
basic_value(const T& x, string_format_info fmt, std::vector<std::string> com)
|
basic_value(const T& x,
|
||||||
: basic_value(x, std::move(fmt), std::move(com), region_type{})
|
string_format_info fmt = string_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
key_format_info key_fmt = key_format_info{},
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
region_type reg = region_type{},
|
||||||
detail::is_1byte_std_basic_string<T>
|
region_type key_reg = region_type{})
|
||||||
>::value, std::nullptr_t> = nullptr>
|
|
||||||
basic_value(const T& x, string_format_info fmt,
|
|
||||||
std::vector<std::string> com, region_type reg)
|
|
||||||
: type_(value_t::string),
|
: type_(value_t::string),
|
||||||
string_(string_storage(detail::string_conv<string_type>(x), std::move(fmt))),
|
string_(string_storage(detail::string_conv<string_type>(x), std::move(fmt))),
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
template<typename T, cxx::enable_if_t<cxx::conjunction<
|
||||||
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
cxx::negation<std::is_same<cxx::remove_cvref_t<T>, string_type>>,
|
||||||
@@ -697,6 +671,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::string;
|
this->type_ = value_t::string;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->string_, string_storage(detail::string_conv<string_type>(x), std::move(fmt)));
|
assigner(this->string_, string_storage(detail::string_conv<string_type>(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -705,22 +680,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (local_date) =========================================== {{{
|
// constructor (local_date) =========================================== {{{
|
||||||
|
|
||||||
basic_value(local_date_type x)
|
|
||||||
: basic_value(x, local_date_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_date_type x, local_date_format_info fmt)
|
|
||||||
: basic_value(x, fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_date_type x, std::vector<std::string> com)
|
basic_value(local_date_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, local_date_format_info{}, std::move(com), region_type{})
|
: basic_value(x, local_date_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(local_date_type x, local_date_format_info fmt, std::vector<std::string> com)
|
basic_value(local_date_type x,
|
||||||
: basic_value(x, fmt, std::move(com), region_type{})
|
local_date_format_info fmt = local_date_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(local_date_type x, local_date_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::local_date), local_date_(local_date_storage(x, fmt)),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::local_date),
|
||||||
|
local_date_(local_date_storage(x, fmt)),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(local_date_type x)
|
basic_value& operator=(local_date_type x)
|
||||||
{
|
{
|
||||||
@@ -732,6 +704,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::local_date;
|
this->type_ = value_t::local_date;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->local_date_, local_date_storage(x, fmt));
|
assigner(this->local_date_, local_date_storage(x, fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -740,22 +713,18 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (local_time) =========================================== {{{
|
// constructor (local_time) =========================================== {{{
|
||||||
|
|
||||||
basic_value(local_time_type x)
|
|
||||||
: basic_value(x, local_time_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_time_type x, local_time_format_info fmt)
|
|
||||||
: basic_value(x, fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_time_type x, std::vector<std::string> com)
|
basic_value(local_time_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, local_time_format_info{}, std::move(com), region_type{})
|
: basic_value(x, local_time_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(local_time_type x, local_time_format_info fmt, std::vector<std::string> com)
|
basic_value(local_time_type x,
|
||||||
: basic_value(x, fmt, std::move(com), region_type{})
|
local_time_format_info fmt = local_time_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(local_time_type x, local_time_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::local_time), local_time_(local_time_storage(x, fmt)),
|
: type_(value_t::local_time), local_time_(local_time_storage(x, fmt)),
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(local_time_type x)
|
basic_value& operator=(local_time_type x)
|
||||||
{
|
{
|
||||||
@@ -767,31 +736,24 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::local_time;
|
this->type_ = value_t::local_time;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->local_time_, local_time_storage(x, fmt));
|
assigner(this->local_time_, local_time_storage(x, fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Rep, typename Period>
|
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& x)
|
|
||||||
: basic_value(local_time_type(x), local_time_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename Rep, typename Period>
|
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& x, local_time_format_info fmt)
|
|
||||||
: basic_value(local_time_type(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename Rep, typename Period>
|
template<typename Rep, typename Period>
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& x, std::vector<std::string> com)
|
basic_value(const std::chrono::duration<Rep, Period>& x, std::vector<std::string> com)
|
||||||
: basic_value(local_time_type(x), local_time_format_info{}, std::move(com), region_type{})
|
: basic_value(local_time_type(x), local_time_format_info{}, std::move(com))
|
||||||
{}
|
|
||||||
template<typename Rep, typename Period>
|
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& x, local_time_format_info fmt, std::vector<std::string> com)
|
|
||||||
: basic_value(local_time_type(x), std::move(fmt), std::move(com), region_type{})
|
|
||||||
{}
|
{}
|
||||||
template<typename Rep, typename Period>
|
template<typename Rep, typename Period>
|
||||||
basic_value(const std::chrono::duration<Rep, Period>& x,
|
basic_value(const std::chrono::duration<Rep, Period>& x,
|
||||||
local_time_format_info fmt,
|
local_time_format_info fmt = local_time_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
std::vector<std::string> com = {},
|
||||||
: basic_value(local_time_type(x), std::move(fmt), std::move(com), std::move(reg))
|
key_format_info key_fmt = key_format_info{},
|
||||||
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
|
: basic_value(local_time_type(x), std::move(fmt), std::move(com), std::move(key_fmt),
|
||||||
|
std::move(reg), std::move(key_reg))
|
||||||
{}
|
{}
|
||||||
template<typename Rep, typename Period>
|
template<typename Rep, typename Period>
|
||||||
basic_value& operator=(const std::chrono::duration<Rep, Period>& x)
|
basic_value& operator=(const std::chrono::duration<Rep, Period>& x)
|
||||||
@@ -804,6 +766,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::local_time;
|
this->type_ = value_t::local_time;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->local_time_, local_time_storage(local_time_type(x), std::move(fmt)));
|
assigner(this->local_time_, local_time_storage(local_time_type(x), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -812,22 +775,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (local_datetime) =========================================== {{{
|
// constructor (local_datetime) =========================================== {{{
|
||||||
|
|
||||||
basic_value(local_datetime_type x)
|
|
||||||
: basic_value(x, local_datetime_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_datetime_type x, local_datetime_format_info fmt)
|
|
||||||
: basic_value(x, fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(local_datetime_type x, std::vector<std::string> com)
|
basic_value(local_datetime_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, local_datetime_format_info{}, std::move(com), region_type{})
|
: basic_value(x, local_datetime_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(local_datetime_type x, local_datetime_format_info fmt, std::vector<std::string> com)
|
basic_value(local_datetime_type x,
|
||||||
: basic_value(x, fmt, std::move(com), region_type{})
|
local_datetime_format_info fmt = local_datetime_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(local_datetime_type x, local_datetime_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::local_datetime), local_datetime_(local_datetime_storage(x, fmt)),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::local_datetime),
|
||||||
|
local_datetime_(local_datetime_storage(x, fmt)),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(local_datetime_type x)
|
basic_value& operator=(local_datetime_type x)
|
||||||
{
|
{
|
||||||
@@ -839,6 +799,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::local_datetime;
|
this->type_ = value_t::local_datetime;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->local_datetime_, local_datetime_storage(x, fmt));
|
assigner(this->local_datetime_, local_datetime_storage(x, fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -847,22 +808,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (offset_datetime) =========================================== {{{
|
// constructor (offset_datetime) =========================================== {{{
|
||||||
|
|
||||||
basic_value(offset_datetime_type x)
|
|
||||||
: basic_value(x, offset_datetime_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(offset_datetime_type x, offset_datetime_format_info fmt)
|
|
||||||
: basic_value(x, fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(offset_datetime_type x, std::vector<std::string> com)
|
basic_value(offset_datetime_type x, std::vector<std::string> com)
|
||||||
: basic_value(x, offset_datetime_format_info{}, std::move(com), region_type{})
|
: basic_value(x, offset_datetime_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(offset_datetime_type x, offset_datetime_format_info fmt, std::vector<std::string> com)
|
basic_value(offset_datetime_type x,
|
||||||
: basic_value(x, fmt, std::move(com), region_type{})
|
offset_datetime_format_info fmt = offset_datetime_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(offset_datetime_type x, offset_datetime_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: type_(value_t::offset_datetime), offset_datetime_(offset_datetime_storage(x, fmt)),
|
region_type key_reg = region_type{})
|
||||||
region_(std::move(reg)), comments_(std::move(com))
|
: type_(value_t::offset_datetime),
|
||||||
|
offset_datetime_(offset_datetime_storage(x, fmt)),
|
||||||
|
region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(offset_datetime_type x)
|
basic_value& operator=(offset_datetime_type x)
|
||||||
{
|
{
|
||||||
@@ -874,27 +832,24 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::offset_datetime;
|
this->type_ = value_t::offset_datetime;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->offset_datetime_, offset_datetime_storage(x, fmt));
|
assigner(this->offset_datetime_, offset_datetime_storage(x, fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// system_clock::time_point
|
// system_clock::time_point
|
||||||
|
|
||||||
basic_value(std::chrono::system_clock::time_point x)
|
|
||||||
: basic_value(offset_datetime_type(x), offset_datetime_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(std::chrono::system_clock::time_point x, offset_datetime_format_info fmt)
|
|
||||||
: basic_value(offset_datetime_type(x), fmt, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(std::chrono::system_clock::time_point x, std::vector<std::string> com)
|
basic_value(std::chrono::system_clock::time_point x, std::vector<std::string> com)
|
||||||
: basic_value(offset_datetime_type(x), offset_datetime_format_info{}, std::move(com), region_type{})
|
: basic_value(offset_datetime_type(x), offset_datetime_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(std::chrono::system_clock::time_point x, offset_datetime_format_info fmt, std::vector<std::string> com)
|
basic_value(std::chrono::system_clock::time_point x,
|
||||||
: basic_value(offset_datetime_type(x), fmt, std::move(com), region_type{})
|
offset_datetime_format_info fmt = offset_datetime_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(std::chrono::system_clock::time_point x, offset_datetime_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
: basic_value(offset_datetime_type(x), std::move(fmt), std::move(com), std::move(reg))
|
region_type key_reg = region_type{})
|
||||||
|
: basic_value(offset_datetime_type(x), std::move(fmt), std::move(com),
|
||||||
|
std::move(key_fmt), std::move(reg), std::move(key_reg))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(std::chrono::system_clock::time_point x)
|
basic_value& operator=(std::chrono::system_clock::time_point x)
|
||||||
{
|
{
|
||||||
@@ -906,6 +861,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::offset_datetime;
|
this->type_ = value_t::offset_datetime;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->offset_datetime_, offset_datetime_storage(offset_datetime_type(x), fmt));
|
assigner(this->offset_datetime_, offset_datetime_storage(offset_datetime_type(x), fmt));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -914,23 +870,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (array) ================================================ {{{
|
// constructor (array) ================================================ {{{
|
||||||
|
|
||||||
basic_value(array_type x)
|
|
||||||
: basic_value(std::move(x), array_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(array_type x, array_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(array_type x, std::vector<std::string> com)
|
basic_value(array_type x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), array_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), array_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(array_type x, array_format_info fmt, std::vector<std::string> com)
|
basic_value(array_type x,
|
||||||
: basic_value(std::move(x), fmt, std::move(com), region_type{})
|
array_format_info fmt = array_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(array_type x, array_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::array), array_(array_storage(
|
: type_(value_t::array), array_(array_storage(
|
||||||
detail::storage<array_type>(std::move(x)), std::move(fmt)
|
detail::storage<array_type>(std::move(x)), std::move(fmt)
|
||||||
)), region_(std::move(reg)), comments_(std::move(com))
|
)), region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(array_type x)
|
basic_value& operator=(array_type x)
|
||||||
{
|
{
|
||||||
@@ -942,6 +894,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::array;
|
this->type_ = value_t::array;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->array_, array_storage(
|
assigner(this->array_, array_storage(
|
||||||
detail::storage<array_type>(std::move(x)), std::move(fmt)));
|
detail::storage<array_type>(std::move(x)), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
@@ -963,31 +916,24 @@ class basic_value
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
|
||||||
basic_value(T x)
|
|
||||||
: basic_value(std::move(x), array_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
|
||||||
basic_value(T x, array_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
template<typename T, enable_if_array_like_t<T> = nullptr>
|
||||||
basic_value(T x, std::vector<std::string> com)
|
basic_value(T x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), array_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), array_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
template<typename T, enable_if_array_like_t<T> = nullptr>
|
||||||
basic_value(T x, array_format_info fmt, std::vector<std::string> com)
|
basic_value(T x,
|
||||||
: basic_value(std::move(x), fmt, std::move(com), region_type{})
|
array_format_info fmt = array_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
key_format_info key_fmt = key_format_info{},
|
||||||
basic_value(T x, array_format_info fmt,
|
region_type reg = region_type{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::array), array_(array_storage(
|
: type_(value_t::array), array_(array_storage(
|
||||||
detail::storage<array_type>(array_type(
|
detail::storage<array_type>(array_type(
|
||||||
std::make_move_iterator(x.begin()),
|
std::make_move_iterator(x.begin()),
|
||||||
std::make_move_iterator(x.end()))
|
std::make_move_iterator(x.end()))
|
||||||
), std::move(fmt)
|
), std::move(fmt)
|
||||||
)), region_(std::move(reg)), comments_(std::move(com))
|
)), region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_array_like_t<T> = nullptr>
|
template<typename T, enable_if_array_like_t<T> = nullptr>
|
||||||
basic_value& operator=(T x)
|
basic_value& operator=(T x)
|
||||||
@@ -1000,6 +946,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::array;
|
this->type_ = value_t::array;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
|
|
||||||
array_type a(std::make_move_iterator(x.begin()),
|
array_type a(std::make_move_iterator(x.begin()),
|
||||||
std::make_move_iterator(x.end()));
|
std::make_move_iterator(x.end()));
|
||||||
@@ -1012,23 +959,19 @@ class basic_value
|
|||||||
|
|
||||||
// constructor (table) ================================================ {{{
|
// constructor (table) ================================================ {{{
|
||||||
|
|
||||||
basic_value(table_type x)
|
|
||||||
: basic_value(std::move(x), table_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(table_type x, table_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
basic_value(table_type x, std::vector<std::string> com)
|
basic_value(table_type x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), table_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), table_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
basic_value(table_type x, table_format_info fmt, std::vector<std::string> com)
|
basic_value(table_type x,
|
||||||
: basic_value(std::move(x), fmt, std::move(com), region_type{})
|
table_format_info fmt = table_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
basic_value(table_type x, table_format_info fmt,
|
key_format_info key_fmt = key_format_info{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type reg = region_type{},
|
||||||
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::table), table_(table_storage(
|
: type_(value_t::table), table_(table_storage(
|
||||||
detail::storage<table_type>(std::move(x)), std::move(fmt)
|
detail::storage<table_type>(std::move(x)), std::move(fmt)
|
||||||
)), region_(std::move(reg)), comments_(std::move(com))
|
)), region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
basic_value& operator=(table_type x)
|
basic_value& operator=(table_type x)
|
||||||
{
|
{
|
||||||
@@ -1040,6 +983,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::table;
|
this->type_ = value_t::table;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
assigner(this->table_, table_storage(
|
assigner(this->table_, table_storage(
|
||||||
detail::storage<table_type>(std::move(x)), std::move(fmt)));
|
detail::storage<table_type>(std::move(x)), std::move(fmt)));
|
||||||
return *this;
|
return *this;
|
||||||
@@ -1059,31 +1003,24 @@ class basic_value
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
|
||||||
basic_value(T x)
|
|
||||||
: basic_value(std::move(x), table_format_info{}, std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
|
||||||
basic_value(T x, table_format_info fmt)
|
|
||||||
: basic_value(std::move(x), std::move(fmt), std::vector<std::string>{}, region_type{})
|
|
||||||
{}
|
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
template<typename T, enable_if_table_like_t<T> = nullptr>
|
||||||
basic_value(T x, std::vector<std::string> com)
|
basic_value(T x, std::vector<std::string> com)
|
||||||
: basic_value(std::move(x), table_format_info{}, std::move(com), region_type{})
|
: basic_value(std::move(x), table_format_info{}, std::move(com))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
template<typename T, enable_if_table_like_t<T> = nullptr>
|
||||||
basic_value(T x, table_format_info fmt, std::vector<std::string> com)
|
basic_value(T x,
|
||||||
: basic_value(std::move(x), fmt, std::move(com), region_type{})
|
table_format_info fmt = table_format_info{},
|
||||||
{}
|
std::vector<std::string> com = {},
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
key_format_info key_fmt = key_format_info{},
|
||||||
basic_value(T x, table_format_info fmt,
|
region_type reg = region_type{},
|
||||||
std::vector<std::string> com, region_type reg)
|
region_type key_reg = region_type{})
|
||||||
: type_(value_t::table), table_(table_storage(
|
: type_(value_t::table), table_(table_storage(
|
||||||
detail::storage<table_type>(table_type(
|
detail::storage<table_type>(table_type(
|
||||||
std::make_move_iterator(x.begin()),
|
std::make_move_iterator(x.begin()),
|
||||||
std::make_move_iterator(x.end())
|
std::make_move_iterator(x.end())
|
||||||
)), std::move(fmt)
|
)), std::move(fmt)
|
||||||
)), region_(std::move(reg)), comments_(std::move(com))
|
)), region_(std::move(reg)), comments_(std::move(com)),
|
||||||
|
key_region_(std::move(key_reg)), key_fmt_(std::move(key_fmt))
|
||||||
{}
|
{}
|
||||||
template<typename T, enable_if_table_like_t<T> = nullptr>
|
template<typename T, enable_if_table_like_t<T> = nullptr>
|
||||||
basic_value& operator=(T x)
|
basic_value& operator=(T x)
|
||||||
@@ -1096,6 +1033,7 @@ class basic_value
|
|||||||
this->cleanup();
|
this->cleanup();
|
||||||
this->type_ = value_t::table;
|
this->type_ = value_t::table;
|
||||||
this->region_ = region_type{};
|
this->region_ = region_type{};
|
||||||
|
// key region/fmt is kept
|
||||||
|
|
||||||
table_type t(std::make_move_iterator(x.begin()),
|
table_type t(std::make_move_iterator(x.begin()),
|
||||||
std::make_move_iterator(x.end()));
|
std::make_move_iterator(x.end()));
|
||||||
@@ -1180,7 +1118,8 @@ class basic_value
|
|||||||
|
|
||||||
// mainly for `null` extension
|
// mainly for `null` extension
|
||||||
basic_value(detail::none_t, region_type reg) noexcept
|
basic_value(detail::none_t, region_type reg) noexcept
|
||||||
: type_(value_t::empty), empty_('\0'), region_(std::move(reg)), comments_{}
|
: type_(value_t::empty), empty_('\0'), region_(std::move(reg)), comments_{},
|
||||||
|
key_region_{}, key_fmt_{}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
@@ -1856,6 +1795,13 @@ class basic_value
|
|||||||
comment_type const& comments() const noexcept {return this->comments_;}
|
comment_type const& comments() const noexcept {return this->comments_;}
|
||||||
comment_type& comments() noexcept {return this->comments_;}
|
comment_type& comments() noexcept {return this->comments_;}
|
||||||
|
|
||||||
|
source_location key_location() const
|
||||||
|
{
|
||||||
|
return source_location(this->key_region_);
|
||||||
|
}
|
||||||
|
key_format_info& key_fmt() noexcept {return this->key_fmt_;}
|
||||||
|
key_format_info const& key_fmt() const noexcept {return this->key_fmt_;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// private helper functions =========================================== {{{
|
// private helper functions =========================================== {{{
|
||||||
@@ -1905,6 +1851,9 @@ class basic_value
|
|||||||
template<typename TC>
|
template<typename TC>
|
||||||
friend void detail::change_region_of_value(basic_value<TC>&, const basic_value<TC>&);
|
friend void detail::change_region_of_value(basic_value<TC>&, const basic_value<TC>&);
|
||||||
|
|
||||||
|
template<typename TC>
|
||||||
|
friend void change_region_of_key(basic_value<TC>&, detail::region);
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
friend class basic_value;
|
friend class basic_value;
|
||||||
|
|
||||||
@@ -1942,6 +1891,8 @@ class basic_value
|
|||||||
};
|
};
|
||||||
region_type region_;
|
region_type region_;
|
||||||
comment_type comments_;
|
comment_type comments_;
|
||||||
|
region_type key_region_;
|
||||||
|
key_format_info key_fmt_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename TC>
|
template<typename TC>
|
||||||
@@ -2249,6 +2200,13 @@ template<typename TC>
|
|||||||
void change_region_of_value(basic_value<TC>& dst, const basic_value<TC>& src)
|
void change_region_of_value(basic_value<TC>& dst, const basic_value<TC>& src)
|
||||||
{
|
{
|
||||||
dst.region_ = std::move(src.region_);
|
dst.region_ = std::move(src.region_);
|
||||||
|
dst.key_region_ = std::move(src.key_region_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
template<typename TC>
|
||||||
|
void change_region_of_key(basic_value<TC>& dst, region src)
|
||||||
|
{
|
||||||
|
dst.key_region_ = std::move(src);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ enum class string_format : std::uint8_t;
|
|||||||
enum class datetime_delimiter_kind : std::uint8_t;
|
enum class datetime_delimiter_kind : std::uint8_t;
|
||||||
enum class array_format : std::uint8_t;
|
enum class array_format : std::uint8_t;
|
||||||
enum class table_format : std::uint8_t;
|
enum class table_format : std::uint8_t;
|
||||||
|
enum class key_format : std::uint8_t;
|
||||||
|
|
||||||
struct boolean_format_info;
|
struct boolean_format_info;
|
||||||
struct integer_format_info;
|
struct integer_format_info;
|
||||||
@@ -51,6 +52,7 @@ struct local_date_format_info;
|
|||||||
struct local_time_format_info;
|
struct local_time_format_info;
|
||||||
struct array_format_info;
|
struct array_format_info;
|
||||||
struct table_format_info;
|
struct table_format_info;
|
||||||
|
struct key_format_info;
|
||||||
|
|
||||||
template<typename Key, typename Val, typename Cmp, typename Allocator>
|
template<typename Key, typename Val, typename Cmp, typename Allocator>
|
||||||
class ordered_map;
|
class ordered_map;
|
||||||
|
|||||||
@@ -15344,7 +15344,7 @@ try_parse(std::istream& is, std::string fname = "unknown file", spec s = spec::d
|
|||||||
// read whole file as a sequence of char
|
// read whole file as a sequence of char
|
||||||
assert(fsize >= 0);
|
assert(fsize >= 0);
|
||||||
std::vector<detail::location::char_type> letters(static_cast<std::size_t>(fsize), '\0');
|
std::vector<detail::location::char_type> letters(static_cast<std::size_t>(fsize), '\0');
|
||||||
is.read(reinterpret_cast<char*>(letters.data()), fsize);
|
is.read(reinterpret_cast<char*>(letters.data()), static_cast<std::streamsize>(fsize));
|
||||||
|
|
||||||
return detail::parse_impl<TC>(std::move(letters), std::move(fname), std::move(s));
|
return detail::parse_impl<TC>(std::move(letters), std::move(fname), std::move(s));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user