mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-22 04:20:06 +00:00
fix typo
This commit is contained in:
parent
5e6d699452
commit
9e9a5a7253
@ -102,8 +102,8 @@ BOOST_AUTO_TEST_CASE(test_basic_inline_string)
|
||||
BOOST_CHECK(is_valid::invoke(invalid_escape.cbegin(), invalid_escape.cend()) == invalid_escape.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string invalid_charactor("\"foo\10bar\"");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_charactor.cbegin(), invalid_charactor.cend()) == invalid_charactor.cbegin());
|
||||
const std::string invalid_character("\"foo\10bar\"");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_character.cbegin(), invalid_character.cend()) == invalid_character.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string multi("\"\"\"multiline\"\"\"");
|
||||
@ -144,8 +144,8 @@ BOOST_AUTO_TEST_CASE(test_basic_multiline_string)
|
||||
BOOST_CHECK(is_valid::invoke(invalid_escape.cbegin(), invalid_escape.cend()) == invalid_escape.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string invalid_charactor("\"\"\"foo\10bar\"\"\"");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_charactor.cbegin(), invalid_charactor.cend()) == invalid_charactor.cbegin());
|
||||
const std::string invalid_character("\"\"\"foo\10bar\"\"\"");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_character.cbegin(), invalid_character.cend()) == invalid_character.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string single("\"singleline\"");
|
||||
@ -178,8 +178,8 @@ BOOST_AUTO_TEST_CASE(test_literal_inline_string)
|
||||
BOOST_CHECK(is_valid::invoke(newline.cbegin(), newline.cend()) == newline.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string invalid_charactor("'foo\10bar'");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_charactor.cbegin(), invalid_charactor.cend()) == invalid_charactor.cbegin());
|
||||
const std::string invalid_character("'foo\10bar'");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_character.cbegin(), invalid_character.cend()) == invalid_character.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string multi("'''multiline'''");
|
||||
@ -212,8 +212,8 @@ BOOST_AUTO_TEST_CASE(test_literal_multiline_string)
|
||||
}
|
||||
|
||||
{
|
||||
const std::string invalid_charactor("'''foo\10bar'''");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_charactor.cbegin(), invalid_charactor.cend()) == invalid_charactor.cbegin());
|
||||
const std::string invalid_character("'''foo\10bar'''");
|
||||
BOOST_CHECK(is_valid::invoke(invalid_character.cbegin(), invalid_character.cend()) == invalid_character.cbegin());
|
||||
}
|
||||
{
|
||||
const std::string single("'singleline'");
|
||||
|
@ -14,7 +14,7 @@
|
||||
BOOST_AUTO_TEST_CASE(test_parse_basic_inline_string)
|
||||
{
|
||||
typedef toml::parse_basic_inline_string parser;
|
||||
typedef toml::is_basic_inline_string<toml::charactor> acceptor;
|
||||
typedef toml::is_basic_inline_string<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("\"simple\"");
|
||||
const std::string expected("simple");
|
||||
@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(test_parse_basic_inline_string)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_basic_multiline_string)
|
||||
{
|
||||
typedef toml::parse_basic_multiline_string parser;
|
||||
typedef toml::is_basic_multiline_string<toml::charactor> acceptor;
|
||||
typedef toml::is_basic_multiline_string<toml::character> acceptor;
|
||||
{
|
||||
//XXX ifdef windows platform
|
||||
const std::string source("\"\"\"\nRoses are red\nViolets are blue\"\"\"");
|
||||
@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(test_parse_basic_multiline_string)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_literal_inline_string)
|
||||
{
|
||||
typedef toml::parse_literal_inline_string parser;
|
||||
typedef toml::is_literal_inline_string<toml::charactor> acceptor;
|
||||
typedef toml::is_literal_inline_string<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("'C:\\Users\\nodejs\\templates'");
|
||||
const std::string expected("C:\\Users\\nodejs\\templates");
|
||||
@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(test_parse_literal_inline_string)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_literal_multiline_string)
|
||||
{
|
||||
typedef toml::parse_literal_multiline_string parser;
|
||||
typedef toml::is_literal_multiline_string<toml::charactor> acceptor;
|
||||
typedef toml::is_literal_multiline_string<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("'''I [dw]on't need \\d{2} apples'''");
|
||||
const std::string expected("I [dw]on't need \\d{2} apples");
|
||||
@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(test_parse_literal_multiline_string)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_string)
|
||||
{
|
||||
typedef toml::parse_string parser;
|
||||
typedef toml::is_string<toml::charactor> acceptor;
|
||||
typedef toml::is_string<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("\"string\"");
|
||||
const std::string expected("string");
|
||||
@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(test_parse_string)
|
||||
BOOST_AUTO_TEST_CASE(test_integer)
|
||||
{
|
||||
typedef toml::parse_integer parser;
|
||||
typedef toml::is_integer<toml::charactor> acceptor;
|
||||
typedef toml::is_integer<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("42");
|
||||
const toml::Integer expected(42);
|
||||
@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(test_integer)
|
||||
BOOST_AUTO_TEST_CASE(test_float)
|
||||
{
|
||||
typedef toml::parse_float parser;
|
||||
typedef toml::is_float<toml::charactor> acceptor;
|
||||
typedef toml::is_float<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("42.0");
|
||||
const toml::Float expected(42.0);
|
||||
@ -305,7 +305,7 @@ BOOST_AUTO_TEST_CASE(test_float)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_boolean)
|
||||
{
|
||||
typedef toml::parse_boolean parser;
|
||||
typedef toml::is_boolean<toml::charactor> acceptor;
|
||||
typedef toml::is_boolean<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("true");
|
||||
const toml::Boolean expected(true);
|
||||
@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(test_parse_boolean)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_local_time)
|
||||
{
|
||||
typedef toml::parse_local_time parser;
|
||||
typedef toml::is_local_time<toml::charactor> acceptor;
|
||||
typedef toml::is_local_time<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("12:34:56");
|
||||
const toml::Datetime expected(12, 34, 56, 0, 0);
|
||||
@ -371,7 +371,7 @@ BOOST_AUTO_TEST_CASE(test_parse_local_time)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_local_date)
|
||||
{
|
||||
typedef toml::parse_local_date parser;
|
||||
typedef toml::is_local_date<toml::charactor> acceptor;
|
||||
typedef toml::is_local_date<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("1979-09-27");
|
||||
const toml::Datetime expected(1979, 9, 27);
|
||||
@ -391,7 +391,7 @@ BOOST_AUTO_TEST_CASE(test_parse_local_date)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_local_date_time)
|
||||
{
|
||||
typedef toml::parse_local_date_time parser;
|
||||
typedef toml::is_local_date_time<toml::charactor> acceptor;
|
||||
typedef toml::is_local_date_time<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("1979-09-27T12:34:56");
|
||||
const toml::Datetime expected(1979, 9, 27, 12, 34, 56, 0, 0);
|
||||
@ -419,7 +419,7 @@ BOOST_AUTO_TEST_CASE(test_parse_local_date_time)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_offset_date_time)
|
||||
{
|
||||
typedef toml::parse_offset_date_time parser;
|
||||
typedef toml::is_offset_date_time<toml::charactor> acceptor;
|
||||
typedef toml::is_offset_date_time<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("1979-09-27T12:34:56Z");
|
||||
const toml::Datetime expected(1979, 9, 27, 12, 34, 56, 0, 0, 0, 0);
|
||||
@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(test_parse_offset_date_time)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_datetime)
|
||||
{
|
||||
typedef toml::parse_datetime parser;
|
||||
typedef toml::is_datetime<toml::charactor> acceptor;
|
||||
typedef toml::is_datetime<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("1979-09-27T12:34:56Z");
|
||||
const toml::Datetime expected(1979, 9, 27, 12, 34, 56, 0, 0, 0, 0);
|
||||
@ -525,8 +525,8 @@ BOOST_AUTO_TEST_CASE(test_parse_datetime)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_parse_array)
|
||||
{
|
||||
typedef toml::parse_array<toml::charactor> parser;
|
||||
typedef toml::is_array<toml::charactor> acceptor;
|
||||
typedef toml::parse_array<toml::character> parser;
|
||||
typedef toml::is_array<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("[1,2,3]");
|
||||
const toml::Array expected{1, 2, 3};
|
||||
@ -630,8 +630,8 @@ BOOST_AUTO_TEST_CASE(test_parse_array)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_parse_inline_table)
|
||||
{
|
||||
typedef toml::parse_inline_table<toml::charactor> parser;
|
||||
typedef toml::is_inline_table<toml::charactor> acceptor;
|
||||
typedef toml::parse_inline_table<toml::character> parser;
|
||||
typedef toml::is_inline_table<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("{foo=1,bar=2.0,baz='str'}");
|
||||
const toml::Table expected{{"foo", 1}, {"bar", 2.0}, {"baz", "str"}};
|
||||
@ -679,7 +679,7 @@ BOOST_AUTO_TEST_CASE(test_parse_inline_table)
|
||||
BOOST_AUTO_TEST_CASE(test_parse_barekey)
|
||||
{
|
||||
typedef toml::parse_barekey parser;
|
||||
typedef toml::is_barekey<toml::charactor> acceptor;
|
||||
typedef toml::is_barekey<toml::character> acceptor;
|
||||
{
|
||||
const std::string source("hoge");
|
||||
const toml::key expected("hoge");
|
||||
|
@ -9,7 +9,7 @@ namespace toml
|
||||
{
|
||||
|
||||
template<typename charT, charT c>
|
||||
struct is_charactor
|
||||
struct is_character
|
||||
{
|
||||
typedef charT value_type;
|
||||
constexpr static value_type target = c;
|
||||
@ -240,9 +240,9 @@ struct is_not_but
|
||||
};
|
||||
|
||||
template<typename charT>
|
||||
using is_space = is_charactor<charT, ' '>;
|
||||
using is_space = is_character<charT, ' '>;
|
||||
template<typename charT>
|
||||
using is_tab = is_charactor<charT, '\t'>;
|
||||
using is_tab = is_character<charT, '\t'>;
|
||||
template<typename charT>
|
||||
using is_number = is_in_range<charT, '0', '9'>;
|
||||
template<typename charT>
|
||||
@ -261,17 +261,17 @@ using is_any_num_of_ws =
|
||||
is_ignorable<is_repeat_of<is_whitespace<charT>, repeat_infinite()>>;
|
||||
|
||||
template<typename charT>
|
||||
using is_newline = is_one_of<is_charactor<charT, '\n'>,
|
||||
is_chain_of<is_charactor<charT, '\r'>, is_charactor<charT, '\n'>>>;
|
||||
using is_newline = is_one_of<is_character<charT, '\n'>,
|
||||
is_chain_of<is_character<charT, '\r'>, is_character<charT, '\n'>>>;
|
||||
template<typename charT>
|
||||
using is_barekey_component = is_one_of<is_alphabet<charT>, is_number<charT>,
|
||||
is_charactor<charT, '_'>, is_charactor<charT, '-'>>;
|
||||
is_character<charT, '_'>, is_character<charT, '-'>>;
|
||||
template<typename charT>
|
||||
using is_barekey = is_repeat_of<is_barekey_component<charT>, repeat_infinite()>;
|
||||
template<typename charT>
|
||||
using is_comment =
|
||||
is_chain_of<
|
||||
is_charactor<charT, '#'>,
|
||||
is_character<charT, '#'>,
|
||||
is_repeat_of<is_none_of<is_newline<charT>>, repeat_infinite()>,
|
||||
is_newline<charT>
|
||||
>;
|
||||
@ -279,73 +279,73 @@ using is_comment =
|
||||
template<typename charT>
|
||||
using is_basic_inline_string_component =
|
||||
is_one_of<
|
||||
is_none_of< is_in_range<charT, '\0', '\31'>, is_charactor<charT, '\"'>,
|
||||
is_charactor<charT, '\\'>, is_newline<charT>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, '\"'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, '\\'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'b'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 't'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'n'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'f'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'r'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'u'>,
|
||||
is_none_of< is_in_range<charT, '\0', '\31'>, is_character<charT, '\"'>,
|
||||
is_character<charT, '\\'>, is_newline<charT>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, '\"'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, '\\'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'b'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 't'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'n'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'f'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'r'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'u'>,
|
||||
is_repeat_of<is_hex<charT>, 4>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'U'>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'U'>,
|
||||
is_repeat_of<is_hex<charT>, 8>>
|
||||
>;
|
||||
template<typename charT>
|
||||
using is_basic_inline_string =
|
||||
is_not_but<
|
||||
is_repeat_of<is_charactor<charT, '\"'>, 3>, // not multiline
|
||||
is_repeat_of<is_character<charT, '\"'>, 3>, // not multiline
|
||||
is_chain_of<
|
||||
is_charactor<charT, '\"'>,
|
||||
is_character<charT, '\"'>,
|
||||
is_ignorable<is_repeat_of<is_basic_inline_string_component<charT>,
|
||||
repeat_infinite()>>,
|
||||
is_charactor<charT, '\"'>
|
||||
is_character<charT, '\"'>
|
||||
>
|
||||
>;
|
||||
template<typename charT>
|
||||
using is_basic_multiline_string_component =
|
||||
is_one_of<
|
||||
is_none_of< is_in_range<charT, '\0', '\31'>,
|
||||
is_repeat_of<is_charactor<charT, '\"'>, 3>,
|
||||
is_charactor<charT, '\\'>>,
|
||||
is_repeat_of<is_character<charT, '\"'>, 3>,
|
||||
is_character<charT, '\\'>>,
|
||||
is_newline<charT>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_newline<charT>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, '\"'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, '\\'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'b'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 't'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'n'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'f'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'r'>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'u'>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_newline<charT>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, '\"'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, '\\'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'b'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 't'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'n'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'f'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'r'>>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'u'>,
|
||||
is_repeat_of<is_hex<charT>, 4>>,
|
||||
is_chain_of<is_charactor<charT, '\\'>, is_charactor<charT, 'U'>,
|
||||
is_chain_of<is_character<charT, '\\'>, is_character<charT, 'U'>,
|
||||
is_repeat_of<is_hex<charT>, 8>>
|
||||
>;
|
||||
template<typename charT>
|
||||
using is_basic_multiline_string =
|
||||
is_chain_of<
|
||||
is_repeat_of<is_charactor<charT, '\"'>, 3>,
|
||||
is_repeat_of<is_character<charT, '\"'>, 3>,
|
||||
is_ignorable<is_repeat_of<is_basic_multiline_string_component<charT>,
|
||||
repeat_infinite()>>,
|
||||
is_repeat_of<is_charactor<charT, '\"'>, 3>
|
||||
is_repeat_of<is_character<charT, '\"'>, 3>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
using is_literal_inline_string_component =
|
||||
is_none_of<is_in_range<charT, '\0', '\31'>, is_charactor<charT, '\''>>;
|
||||
is_none_of<is_in_range<charT, '\0', '\31'>, is_character<charT, '\''>>;
|
||||
|
||||
template<typename charT>
|
||||
using is_literal_inline_string =
|
||||
is_not_but<
|
||||
is_repeat_of<is_charactor<charT, '\''>, 3>,
|
||||
is_repeat_of<is_character<charT, '\''>, 3>,
|
||||
is_chain_of<
|
||||
is_charactor<charT, '\''>,
|
||||
is_character<charT, '\''>,
|
||||
is_ignorable<is_repeat_of<is_literal_inline_string_component<charT>,
|
||||
repeat_infinite()>>,
|
||||
is_charactor<charT, '\''>
|
||||
is_character<charT, '\''>
|
||||
>
|
||||
>;
|
||||
|
||||
@ -353,17 +353,17 @@ template<typename charT>
|
||||
using is_literal_multiline_string_component =
|
||||
is_one_of<
|
||||
is_none_of<is_in_range<charT, '\0', '\31'>,
|
||||
is_repeat_of<is_charactor<charT, '\''>, 3>>,
|
||||
is_repeat_of<is_character<charT, '\''>, 3>>,
|
||||
is_newline<charT>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
using is_literal_multiline_string =
|
||||
is_chain_of<
|
||||
is_repeat_of<is_charactor<charT, '\''>, 3>,
|
||||
is_repeat_of<is_character<charT, '\''>, 3>,
|
||||
is_ignorable<is_repeat_of<is_literal_multiline_string_component<charT>,
|
||||
repeat_infinite()>>,
|
||||
is_repeat_of<is_charactor<charT, '\''>, 3>
|
||||
is_repeat_of<is_character<charT, '\''>, 3>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
@ -377,16 +377,16 @@ using is_string =
|
||||
|
||||
|
||||
template<typename charT>
|
||||
using is_sign = is_one_of<is_charactor<charT, '+'>, is_charactor<charT, '-'>>;
|
||||
using is_sign = is_one_of<is_character<charT, '+'>, is_character<charT, '-'>>;
|
||||
template<typename charT>
|
||||
using is_nonzero_number = is_in_range<charT, '1', '9'>;
|
||||
|
||||
template<typename charT>
|
||||
using is_integer_component =
|
||||
is_not_but<
|
||||
is_repeat_of<is_charactor<charT, '_'>, 2>,
|
||||
is_repeat_of<is_character<charT, '_'>, 2>,
|
||||
is_one_of<
|
||||
is_charactor<charT, '_'>, is_number<charT>
|
||||
is_character<charT, '_'>, is_number<charT>
|
||||
>
|
||||
>;
|
||||
template<typename charT>
|
||||
@ -394,7 +394,7 @@ using is_integer =
|
||||
is_chain_of<
|
||||
is_ignorable<is_sign<charT>>,
|
||||
is_one_of<
|
||||
is_charactor<charT, '0'>,
|
||||
is_character<charT, '0'>,
|
||||
is_chain_of<
|
||||
is_nonzero_number<charT>,
|
||||
is_ignorable<is_repeat_of<is_integer_component<charT>,
|
||||
@ -407,13 +407,13 @@ using is_integer =
|
||||
template<typename charT>
|
||||
using is_fractional_part =
|
||||
is_chain_of<
|
||||
is_charactor<charT, '.'>,
|
||||
is_character<charT, '.'>,
|
||||
is_repeat_of<is_integer_component<charT>, repeat_infinite()>
|
||||
>;
|
||||
template<typename charT>
|
||||
using is_exponent_part =
|
||||
is_chain_of<
|
||||
is_one_of<is_charactor<charT, 'e'>, is_charactor<charT, 'E'>>,
|
||||
is_one_of<is_character<charT, 'e'>, is_character<charT, 'E'>>,
|
||||
is_integer<charT>
|
||||
>;
|
||||
template<typename charT>
|
||||
@ -438,17 +438,17 @@ template<typename charT>
|
||||
using is_boolean =
|
||||
is_one_of<
|
||||
is_chain_of<
|
||||
is_charactor<charT, 't'>,
|
||||
is_charactor<charT, 'r'>,
|
||||
is_charactor<charT, 'u'>,
|
||||
is_charactor<charT, 'e'>
|
||||
is_character<charT, 't'>,
|
||||
is_character<charT, 'r'>,
|
||||
is_character<charT, 'u'>,
|
||||
is_character<charT, 'e'>
|
||||
>,
|
||||
is_chain_of<
|
||||
is_charactor<charT, 'f'>,
|
||||
is_charactor<charT, 'a'>,
|
||||
is_charactor<charT, 'l'>,
|
||||
is_charactor<charT, 's'>,
|
||||
is_charactor<charT, 'e'>
|
||||
is_character<charT, 'f'>,
|
||||
is_character<charT, 'a'>,
|
||||
is_character<charT, 'l'>,
|
||||
is_character<charT, 's'>,
|
||||
is_character<charT, 'e'>
|
||||
>
|
||||
>;
|
||||
|
||||
@ -456,13 +456,13 @@ template<typename charT>
|
||||
using is_local_time =
|
||||
is_chain_of<
|
||||
is_repeat_of<is_number<charT>, 2>,
|
||||
is_charactor<charT, ':'>,
|
||||
is_character<charT, ':'>,
|
||||
is_repeat_of<is_number<charT>, 2>,
|
||||
is_charactor<charT, ':'>,
|
||||
is_character<charT, ':'>,
|
||||
is_repeat_of<is_number<charT>, 2>,
|
||||
is_ignorable<
|
||||
is_chain_of<
|
||||
is_charactor<charT, '.'>,
|
||||
is_character<charT, '.'>,
|
||||
is_repeat_of<is_number<charT>, repeat_infinite()>
|
||||
>
|
||||
>
|
||||
@ -472,9 +472,9 @@ template<typename charT>
|
||||
using is_local_date =
|
||||
is_chain_of<
|
||||
is_repeat_of<is_number<charT>, 4>,
|
||||
is_charactor<charT, '-'>,
|
||||
is_character<charT, '-'>,
|
||||
is_repeat_of<is_number<charT>, 2>,
|
||||
is_charactor<charT, '-'>,
|
||||
is_character<charT, '-'>,
|
||||
is_repeat_of<is_number<charT>, 2>
|
||||
>;
|
||||
|
||||
@ -482,18 +482,18 @@ template<typename charT>
|
||||
using is_local_date_time =
|
||||
is_chain_of<
|
||||
is_local_date<charT>,
|
||||
is_charactor<charT, 'T'>,
|
||||
is_character<charT, 'T'>,
|
||||
is_local_time<charT>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
using is_offset =
|
||||
is_one_of<
|
||||
is_charactor<charT, 'Z'>,
|
||||
is_character<charT, 'Z'>,
|
||||
is_chain_of<
|
||||
is_sign<charT>,
|
||||
is_repeat_of<is_number<charT>, 2>,
|
||||
is_charactor<charT, ':'>,
|
||||
is_character<charT, ':'>,
|
||||
is_repeat_of<is_number<charT>, 2>
|
||||
>
|
||||
>;
|
||||
@ -551,14 +551,14 @@ using is_key =
|
||||
template<typename charT, typename is_array_component>
|
||||
using is_fixed_type_array =
|
||||
is_chain_of<
|
||||
is_charactor<charT, '['>,
|
||||
is_character<charT, '['>,
|
||||
is_ignorable<
|
||||
is_repeat_of<
|
||||
is_chain_of<
|
||||
is_ignorable<is_skippable_in_array<charT>>,
|
||||
is_array_component,
|
||||
is_ignorable<is_skippable_in_array<charT>>,
|
||||
is_charactor<charT, ','>
|
||||
is_character<charT, ','>
|
||||
>,
|
||||
repeat_infinite()
|
||||
>
|
||||
@ -568,11 +568,11 @@ using is_fixed_type_array =
|
||||
is_ignorable<is_skippable_in_array<charT>>,
|
||||
is_array_component,
|
||||
is_ignorable<is_skippable_in_array<charT>>,
|
||||
is_ignorable<is_charactor<charT, ','>>
|
||||
is_ignorable<is_character<charT, ','>>
|
||||
>
|
||||
>,
|
||||
is_ignorable<is_skippable_in_array<charT>>,
|
||||
is_charactor<charT, ']'>
|
||||
is_character<charT, ']'>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
@ -614,21 +614,21 @@ struct is_inline_table
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '='>,
|
||||
is_character<charT, '='>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_component,
|
||||
is_any_num_of_ws<charT>
|
||||
> is_inline_key_value_pair;
|
||||
|
||||
typedef is_chain_of<
|
||||
is_charactor<charT, '{'>,
|
||||
is_character<charT, '{'>,
|
||||
is_ignorable<
|
||||
is_repeat_of<
|
||||
is_chain_of<
|
||||
is_any_num_of_ws<charT>,
|
||||
is_inline_key_value_pair,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, ','>
|
||||
is_character<charT, ','>
|
||||
>,
|
||||
repeat_infinite()
|
||||
>
|
||||
@ -638,11 +638,11 @@ struct is_inline_table
|
||||
is_any_num_of_ws<charT>,
|
||||
is_inline_key_value_pair,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_ignorable<is_charactor<charT, ','>>
|
||||
is_ignorable<is_character<charT, ','>>
|
||||
>
|
||||
>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '}'>
|
||||
is_character<charT, '}'>
|
||||
> entity;
|
||||
return entity::invoke(iter, end);
|
||||
}
|
||||
@ -657,42 +657,42 @@ template<typename charT>
|
||||
using is_table_definition =
|
||||
is_chain_of<
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '['>,
|
||||
is_character<charT, '['>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_ignorable<
|
||||
is_repeat_of<
|
||||
is_chain_of<
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '.'>,
|
||||
is_character<charT, '.'>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_any_num_of_ws<charT>
|
||||
>,
|
||||
repeat_infinite()>
|
||||
>,
|
||||
is_charactor<charT, ']'>
|
||||
is_character<charT, ']'>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
using is_array_of_table_definition =
|
||||
is_chain_of<
|
||||
is_any_num_of_ws<charT>,
|
||||
is_repeat_of<is_charactor<charT, '['>, 2>,
|
||||
is_repeat_of<is_character<charT, '['>, 2>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_ignorable<
|
||||
is_repeat_of<
|
||||
is_chain_of<
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '.'>,
|
||||
is_character<charT, '.'>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_any_num_of_ws<charT>
|
||||
>,
|
||||
repeat_infinite()>
|
||||
>,
|
||||
is_repeat_of<is_charactor<charT, ']'>, 2>
|
||||
is_repeat_of<is_character<charT, ']'>, 2>
|
||||
>;
|
||||
|
||||
template<typename charT>
|
||||
@ -701,7 +701,7 @@ using is_key_value_pair =
|
||||
is_any_num_of_ws<charT>,
|
||||
is_key<charT>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_charactor<charT, '='>,
|
||||
is_character<charT, '='>,
|
||||
is_any_num_of_ws<charT>,
|
||||
is_value<charT>,
|
||||
is_any_num_of_ws<charT>
|
||||
|
151
toml/format.hpp
151
toml/format.hpp
@ -2,8 +2,8 @@
|
||||
#define TOML11_FORMAT
|
||||
#include "value.hpp"
|
||||
#include <type_traits>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
|
||||
@ -16,24 +16,24 @@ namespace toml
|
||||
// std::cout << toml::make_inline(80) << value;
|
||||
// std::cout << toml::forceinline << value;
|
||||
|
||||
template<typename traits = std::char_traits<toml::charactor>,
|
||||
typename alloc = std::allocator<toml::charactor>>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
template<typename traits = std::char_traits<toml::character>,
|
||||
typename alloc = std::allocator<toml::character>>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const value& v);
|
||||
|
||||
template<typename traits = std::char_traits<toml::charactor>,
|
||||
typename alloc = std::allocator<toml::charactor>>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
template<typename traits = std::char_traits<toml::character>,
|
||||
typename alloc = std::allocator<toml::character>>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const value& v, std::size_t mk);
|
||||
|
||||
template<typename traits = std::char_traits<toml::charactor>,
|
||||
typename alloc = std::allocator<toml::charactor>>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
template<typename traits = std::char_traits<toml::character>,
|
||||
typename alloc = std::allocator<toml::character>>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const toml::key& k, const value& v);
|
||||
|
||||
template<typename traits = std::char_traits<toml::charactor>,
|
||||
typename alloc = std::allocator<toml::charactor>>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
template<typename traits = std::char_traits<toml::character>,
|
||||
typename alloc = std::allocator<toml::character>>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const toml::key& k, const value& v, std::size_t mk);
|
||||
|
||||
template<value_t Type>
|
||||
@ -43,7 +43,7 @@ template<> struct format_impl<value_t::Boolean>
|
||||
{
|
||||
typedef detail::toml_default_type<value_t::Boolean>::type type;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
return val ? "true" : "false";
|
||||
@ -54,7 +54,7 @@ template<> struct format_impl<value_t::Integer>
|
||||
{
|
||||
typedef detail::toml_default_type<value_t::Integer>::type type;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
return std::to_string(val);
|
||||
@ -65,10 +65,10 @@ template<> struct format_impl<value_t::Float>
|
||||
{
|
||||
typedef detail::toml_default_type<value_t::Float>::type type;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
std::basic_ostringstream<toml::charactor> oss;
|
||||
std::basic_ostringstream<toml::character> oss;
|
||||
oss << std::showpoint << val;
|
||||
if(oss.str().back() == '.') oss << '0';
|
||||
return oss.str();
|
||||
@ -84,7 +84,7 @@ template<> struct format_impl<value_t::String>
|
||||
format_impl() : max_length(80){}
|
||||
format_impl(std::size_t mx) : max_length(mx){}
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
auto tmp = make_inline(val);
|
||||
@ -95,10 +95,10 @@ template<> struct format_impl<value_t::String>
|
||||
|
||||
private:
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
make_inline(std::basic_string<toml::charactor>&& val)
|
||||
std::basic_string<toml::character>
|
||||
make_inline(const std::basic_string<toml::character>& val)
|
||||
{
|
||||
std::basic_string<toml::charactor> str;
|
||||
std::basic_string<toml::character> str;
|
||||
str += '"';
|
||||
for(const auto& c : val)
|
||||
{
|
||||
@ -114,11 +114,11 @@ template<> struct format_impl<value_t::String>
|
||||
default:
|
||||
{
|
||||
str += 'u';
|
||||
std::basic_ostringstream<toml::charactor> oss;
|
||||
std::basic_ostringstream<toml::character> oss;
|
||||
oss << std::setw(4) << std::setfill('0') << std::hex
|
||||
<< static_cast<std::int8_t>(c);
|
||||
auto hexdig = oss.str();
|
||||
std::transform(hexdig.begin(), hexdig.end(), std::toupper);
|
||||
std::transform(hexdig.begin(), hexdig.end(), hexdig.begin(), ::toupper);
|
||||
str += oss.str();
|
||||
break;
|
||||
}
|
||||
@ -141,10 +141,10 @@ template<> struct format_impl<value_t::String>
|
||||
return str;
|
||||
}
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
convert_multiline(std::basic_string<toml::charactor>&& val)
|
||||
std::basic_string<toml::character>
|
||||
convert_multiline(std::basic_string<toml::character>&& val)
|
||||
{
|
||||
std::basic_string<toml::charactor> str; str.reserve(val.size() + 6);
|
||||
std::basic_string<toml::character> str; str.reserve(val.size() + 6);
|
||||
str += "\"\"\"\n";
|
||||
std::size_t current = 0;
|
||||
for(auto iter = val.begin()+1; iter != val.end()-1; ++iter)
|
||||
@ -178,10 +178,10 @@ template<> struct format_impl<value_t::Datetime>
|
||||
{
|
||||
typedef detail::toml_default_type<value_t::Datetime>::type type;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
std::basic_ostringstream<toml::charactor> oss;
|
||||
std::basic_ostringstream<toml::character> oss;
|
||||
oss << val;
|
||||
return oss.str();
|
||||
}
|
||||
@ -194,12 +194,15 @@ template<> struct format_impl<value_t::Array>
|
||||
|
||||
std::size_t max_length;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
format_impl() : max_length(80){}
|
||||
format_impl(std::size_t mx) : max_length(mx){}
|
||||
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
std::basic_string<toml::charactor> retval;
|
||||
std::basic_string<toml::character> retval;
|
||||
retval += '[';
|
||||
for(const auto&& item : val)
|
||||
for(const auto& item : val)
|
||||
{
|
||||
auto tmp = format(val, max_length - 1);
|
||||
retval += tmp;
|
||||
@ -207,7 +210,7 @@ template<> struct format_impl<value_t::Array>
|
||||
if(tmp.size() * 2 > max_length) retval += '\n';
|
||||
}
|
||||
retval += ']';
|
||||
return ;
|
||||
return retval;
|
||||
}
|
||||
};
|
||||
|
||||
@ -216,23 +219,28 @@ template<> struct format_impl<value_t::Table>
|
||||
{
|
||||
typedef detail::toml_default_type<value_t::Table>::type type;
|
||||
|
||||
std::basic_string<toml::charactor>
|
||||
std::size_t max_length;
|
||||
|
||||
format_impl() : max_length(80){}
|
||||
format_impl(std::size_t mx) : max_length(mx){}
|
||||
|
||||
std::basic_string<toml::character>
|
||||
operator()(const type& val)
|
||||
{
|
||||
std::basic_string<toml::charactor> retval;
|
||||
for(const auto&& item : val)
|
||||
std::basic_string<toml::character> retval;
|
||||
for(const auto& item : val)
|
||||
{
|
||||
retval += val.first;
|
||||
retval += " = "
|
||||
retval += format(val.second);
|
||||
retval += item.first;
|
||||
retval += " = ";
|
||||
retval += format(item.second);
|
||||
retval += '\n';
|
||||
}
|
||||
return ;
|
||||
return retval;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename traits, typename alloc>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const value& v)
|
||||
{
|
||||
switch(v.type())
|
||||
@ -244,23 +252,52 @@ format(const value& v)
|
||||
case value_t::Datetime: return format_impl<value_t::Datetime>{}(v.template cast<value_t::Datetime>());
|
||||
case value_t::Array : return format_impl<value_t::Array >{}(v.template cast<value_t::Array >());
|
||||
case value_t::Table : return format_impl<value_t::Table >{}(v.template cast<value_t::Table >());
|
||||
case value_t::Empty : return format_impl<value_t::Empty >{}(v.template cast<value_t::Empty >());
|
||||
case value_t::Unknown : return format_impl<value_t::Unknown >{}(v.template cast<value_t::Unknown >());
|
||||
default throw std::logic_error("toml::format: unknown enum value");
|
||||
case value_t::Empty : throw std::runtime_error("toml::format: empty value");
|
||||
case value_t::Unknown : throw std::runtime_error("toml::format: unknown value");
|
||||
default: throw std::logic_error("toml::format: unknown enum value");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename traits, typename alloc>
|
||||
std::basic_string<toml::charactor, traits, alloc>
|
||||
format(std::basic_string<toml::charactor, traits, alloc>&& key, const value& val)
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(const value& v, std::size_t inl)
|
||||
{
|
||||
std::basic_string<charT, traits, alloc> retval(
|
||||
std::forward<std::basic_string<charT, traits, alloc>>(key));
|
||||
switch(v.type())
|
||||
{
|
||||
case value_t::Boolean : return format_impl<value_t::Boolean >{}(v.template cast<value_t::Boolean>());
|
||||
case value_t::Integer : return format_impl<value_t::Integer >{}(v.template cast<value_t::Integer>());
|
||||
case value_t::Float : return format_impl<value_t::Float >{}(v.template cast<value_t::Float>());
|
||||
case value_t::String : return format_impl<value_t::String >{inl}(v.template cast<value_t::String>());
|
||||
case value_t::Datetime: return format_impl<value_t::Datetime>{}(v.template cast<value_t::Datetime>());
|
||||
case value_t::Array : return format_impl<value_t::Array >{inl}(v.template cast<value_t::Array>());
|
||||
case value_t::Table : return format_impl<value_t::Table >{inl}(v.template cast<value_t::Table>());
|
||||
case value_t::Empty : throw std::runtime_error("toml::format: empty value");
|
||||
case value_t::Unknown : throw std::runtime_error("toml::format: unknown value");
|
||||
default: throw std::logic_error("toml::format: unknown enum value");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename traits, typename alloc>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(std::basic_string<toml::character, traits, alloc> key, const value& val)
|
||||
{
|
||||
std::basic_string<toml::character, traits, alloc> retval(std::move(key));
|
||||
retval += " = ";
|
||||
retval += format(val);
|
||||
return retval;
|
||||
}
|
||||
|
||||
template<typename traits, typename alloc>
|
||||
std::basic_string<toml::character, traits, alloc>
|
||||
format(std::basic_string<toml::character, traits, alloc> key, const value& val, std::size_t mk)
|
||||
{
|
||||
std::basic_string<toml::character, traits, alloc> retval(std::move(key));
|
||||
retval += " = ";
|
||||
retval += format(val, mk);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------- stream operators -----------------------------
|
||||
|
||||
namespace detail
|
||||
@ -274,7 +311,7 @@ struct inline_limit
|
||||
T limit;
|
||||
inline_limit() = default;
|
||||
~inline_limit() = default;
|
||||
constexpr make_inline(T i): limit(i){}
|
||||
constexpr inline_limit(T i): limit(i){}
|
||||
constexpr operator T() const {return limit;}
|
||||
|
||||
static void callback(std::ios_base::event ev, std::ios_base& ios, int idx)
|
||||
@ -305,9 +342,9 @@ const int inline_limit<T>::index = std::ios_base::xalloc();
|
||||
|
||||
} //detail
|
||||
|
||||
template<typename sizeT, typename traits = std::char_traits<toml::charactor>>
|
||||
std::basic_ostream<toml::charactor, traits>&
|
||||
operator<<(std::basic_ostream<toml::charactor, traits>& os,
|
||||
template<typename sizeT, typename traits = std::char_traits<toml::character>>
|
||||
std::basic_ostream<toml::character, traits>&
|
||||
operator<<(std::basic_ostream<toml::character, traits>& os,
|
||||
const detail::inline_limit<sizeT>& inl)
|
||||
{
|
||||
void*& info = os.pword(detail::inline_limit<sizeT>::index);
|
||||
@ -327,21 +364,21 @@ operator<<(std::basic_ostream<toml::charactor, traits>& os,
|
||||
return os;
|
||||
}
|
||||
|
||||
constexpr static detail::inline_limit<std::size_t> forceinline =
|
||||
detail::inline_limit(std::numeric_limits<std::size_t>::max());
|
||||
constexpr static detail::inline_limit<std::size_t> forceinline(
|
||||
std::numeric_limits<std::size_t>::max());
|
||||
|
||||
inline detail::inline_limit<std::size_t> make_inline(std::size_t sz)
|
||||
{
|
||||
return detail::inline_limit<std::size_t>(sz);
|
||||
}
|
||||
|
||||
template<typename T, typename traits = std::char_traits>
|
||||
std::basic_ostream<toml::charactor, traits>&
|
||||
operator<<(std::basic_ostream<toml::charactor, traits>& os,
|
||||
template<typename T, typename traits = std::char_traits<toml::character>>
|
||||
std::basic_ostream<toml::character, traits>&
|
||||
operator<<(std::basic_ostream<toml::character, traits>& os,
|
||||
const toml::value& v)
|
||||
{
|
||||
std::size_t* info =
|
||||
static_cast<std::size_t*>(os.pword(inline_limit<std::size_t>::index));
|
||||
static_cast<std::size_t*>(os.pword(detail::inline_limit<std::size_t>::index));
|
||||
return os << (info == nullptr ? toml::format(v) : toml::format(v, *info));
|
||||
}
|
||||
|
||||
|
108
toml/parser.hpp
108
toml/parser.hpp
@ -56,7 +56,7 @@ struct result
|
||||
|
||||
struct parse_escape_sequence
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef toml::String string_type;
|
||||
typedef detail::result<string_type> result_type;
|
||||
|
||||
@ -105,36 +105,36 @@ struct parse_escape_sequence
|
||||
|
||||
static string_type utf8_to_char(const unsigned int codepoint)
|
||||
{
|
||||
string_type charactor;
|
||||
string_type character;
|
||||
if(codepoint < 0x80)
|
||||
{
|
||||
charactor += static_cast<unsigned char>(codepoint);
|
||||
character += static_cast<unsigned char>(codepoint);
|
||||
}
|
||||
else if(codepoint < 0x800)
|
||||
{
|
||||
charactor += static_cast<unsigned char>(0xC0| codepoint >> 6);
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
character += static_cast<unsigned char>(0xC0| codepoint >> 6);
|
||||
character += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
}
|
||||
else if(codepoint < 0x10000)
|
||||
{
|
||||
charactor += static_cast<unsigned char>(0xE0| codepoint >>12);
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint >>6&0x3F));
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
character += static_cast<unsigned char>(0xE0| codepoint >>12);
|
||||
character += static_cast<unsigned char>(0x80|(codepoint >>6&0x3F));
|
||||
character += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
}
|
||||
else
|
||||
{
|
||||
charactor += static_cast<unsigned char>(0xF0| codepoint >>18);
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint >>12&0x3F));
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint >>6 &0x3F));
|
||||
charactor += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
character += static_cast<unsigned char>(0xF0| codepoint >>18);
|
||||
character += static_cast<unsigned char>(0x80|(codepoint >>12&0x3F));
|
||||
character += static_cast<unsigned char>(0x80|(codepoint >>6 &0x3F));
|
||||
character += static_cast<unsigned char>(0x80|(codepoint & 0x3F));
|
||||
}
|
||||
return charactor;
|
||||
return character;
|
||||
}
|
||||
};
|
||||
|
||||
struct parse_basic_inline_string
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::String> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -174,11 +174,11 @@ struct parse_basic_inline_string
|
||||
|
||||
struct parse_basic_multiline_string
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef toml::String string_type;
|
||||
typedef detail::result<string_type> result_type;
|
||||
|
||||
typedef is_chain_of<is_charactor<value_type, '\\'>, is_newline<value_type>>
|
||||
typedef is_chain_of<is_character<value_type, '\\'>, is_newline<value_type>>
|
||||
is_line_ending_backslash;
|
||||
typedef is_repeat_of<is_one_of<is_whitespace<value_type>, is_newline<value_type>>,
|
||||
repeat_infinite()> ws_nl_after_backslash_remover;
|
||||
@ -228,7 +228,7 @@ struct parse_basic_multiline_string
|
||||
|
||||
struct parse_literal_inline_string
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::String> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -257,10 +257,10 @@ struct parse_literal_inline_string
|
||||
|
||||
struct parse_literal_multiline_string
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::String> result_type;
|
||||
|
||||
typedef is_chain_of<is_charactor<value_type, '\\'>, is_newline<value_type>>
|
||||
typedef is_chain_of<is_character<value_type, '\\'>, is_newline<value_type>>
|
||||
is_line_ending_backslash;
|
||||
typedef is_repeat_of<is_one_of<is_whitespace<value_type>, is_newline<value_type>>,
|
||||
repeat_infinite()> ws_nl_after_backslash_remover;
|
||||
@ -292,7 +292,7 @@ struct parse_literal_multiline_string
|
||||
|
||||
struct parse_string
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::String> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -317,7 +317,7 @@ struct parse_string
|
||||
|
||||
struct parse_integer
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Integer> result_type;
|
||||
|
||||
@ -337,7 +337,7 @@ struct parse_integer
|
||||
|
||||
struct parse_float
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Float> result_type;
|
||||
|
||||
@ -366,7 +366,7 @@ struct parse_float
|
||||
|
||||
struct parse_boolean
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::Boolean> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -383,14 +383,14 @@ struct parse_boolean
|
||||
|
||||
struct parse_local_time
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Datetime> result_type;
|
||||
typedef typename toml::Datetime::number_type number_type;
|
||||
template<std::size_t N>
|
||||
using nums = is_repeat_of<is_number<toml::charactor>, N>;
|
||||
typedef is_charactor<toml::charactor, ':'> delim;
|
||||
typedef is_charactor<toml::charactor, '.'> fract;
|
||||
using nums = is_repeat_of<is_number<toml::character>, N>;
|
||||
typedef is_character<toml::character, ':'> delim;
|
||||
typedef is_character<toml::character, '.'> fract;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
std::is_same<typename std::iterator_traits<Iterator>::value_type,
|
||||
@ -445,12 +445,12 @@ struct parse_local_time
|
||||
|
||||
struct parse_local_date
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Datetime> result_type;
|
||||
template<std::size_t N>
|
||||
using nums = is_repeat_of<is_number<value_type>, N>;
|
||||
typedef is_charactor<value_type, '-'> delim;
|
||||
typedef is_character<value_type, '-'> delim;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
std::is_same<typename std::iterator_traits<Iterator>::value_type,
|
||||
@ -481,12 +481,12 @@ struct parse_local_date
|
||||
|
||||
struct parse_local_date_time
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Datetime> result_type;
|
||||
template<std::size_t N>
|
||||
using nums = is_repeat_of<is_number<toml::charactor>, N>;
|
||||
typedef is_charactor<toml::charactor, 'T'> delim;
|
||||
using nums = is_repeat_of<is_number<toml::character>, N>;
|
||||
typedef is_character<toml::character, 'T'> delim;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
std::is_same<typename std::iterator_traits<Iterator>::value_type,
|
||||
@ -517,12 +517,12 @@ struct parse_local_date_time
|
||||
|
||||
struct parse_offset_date_time
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef detail::result<toml::Datetime> result_type;
|
||||
template<std::size_t N>
|
||||
using nums = is_repeat_of<is_number<toml::charactor>, N>;
|
||||
typedef is_charactor<toml::charactor, ':'> delim;
|
||||
using nums = is_repeat_of<is_number<toml::character>, N>;
|
||||
typedef is_character<toml::character, ':'> delim;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
std::is_same<typename std::iterator_traits<Iterator>::value_type,
|
||||
@ -561,7 +561,7 @@ struct parse_offset_date_time
|
||||
|
||||
struct parse_datetime
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::Datetime> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -587,7 +587,7 @@ struct parse_datetime
|
||||
template<typename acceptorT, typename parserT>
|
||||
struct parse_fixed_type_array
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::Array> result_type;
|
||||
typedef acceptorT acceptor_type;
|
||||
typedef parserT parser_type;
|
||||
@ -614,7 +614,7 @@ struct parse_fixed_type_array
|
||||
result.emplace_back(next.first.move());
|
||||
iter = tmp;
|
||||
iter = skippable::invoke(iter, last);
|
||||
iter = is_charactor<value_type, ','>::invoke(iter, last);
|
||||
iter = is_character<value_type, ','>::invoke(iter, last);
|
||||
iter = skippable::invoke(iter, last);
|
||||
}
|
||||
return std::make_pair(result, end);
|
||||
@ -628,7 +628,7 @@ template<typename charT>
|
||||
struct parse_array
|
||||
{
|
||||
typedef charT value_type;
|
||||
static_assert(std::is_same<charT, toml::charactor>::value, "");
|
||||
static_assert(std::is_same<charT, toml::character>::value, "");
|
||||
typedef detail::result<toml::Array> result_type;
|
||||
typedef is_skippable_in_array<value_type> skippable;
|
||||
|
||||
@ -669,7 +669,7 @@ template<typename charT>
|
||||
struct parse_value
|
||||
{
|
||||
typedef charT value_type;
|
||||
static_assert(std::is_same<charT, toml::charactor>::value, "");
|
||||
static_assert(std::is_same<charT, toml::character>::value, "");
|
||||
typedef detail::result<toml::value> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -700,7 +700,7 @@ struct parse_value
|
||||
|
||||
struct parse_barekey
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::key> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -717,7 +717,7 @@ struct parse_barekey
|
||||
|
||||
struct parse_key
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<toml::key> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -739,7 +739,7 @@ template<typename charT>
|
||||
struct parse_key_value_pair
|
||||
{
|
||||
typedef charT value_type;
|
||||
static_assert(std::is_same<charT, toml::charactor>::value, "");
|
||||
static_assert(std::is_same<charT, toml::character>::value, "");
|
||||
typedef detail::result<std::pair<toml::key, toml::value>> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -755,7 +755,7 @@ struct parse_key_value_pair
|
||||
if(*iter != '=') throw syntax_error("invalid key value pair");
|
||||
iter = is_any_num_of_ws<charT>::invoke(std::next(iter), range_end);
|
||||
|
||||
auto tmp_value = parse_value<toml::charactor>::invoke(iter, range_end);
|
||||
auto tmp_value = parse_value<toml::character>::invoke(iter, range_end);
|
||||
if(!tmp_value.first.ok())
|
||||
throw syntax_error("invalid key value pair");
|
||||
|
||||
@ -771,7 +771,7 @@ template<typename charT>
|
||||
struct parse_inline_table
|
||||
{
|
||||
typedef charT value_type;
|
||||
static_assert(std::is_same<charT, toml::charactor>::value, "");
|
||||
static_assert(std::is_same<charT, toml::character>::value, "");
|
||||
typedef detail::result<toml::Table> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -796,7 +796,7 @@ struct parse_inline_table
|
||||
iter = tmp.second;
|
||||
|
||||
iter = is_any_num_of_ws<value_type>::invoke(iter, last);
|
||||
iter = is_charactor<value_type, ','>::invoke(iter, last);
|
||||
iter = is_character<value_type, ','>::invoke(iter, last);
|
||||
iter = is_any_num_of_ws<value_type>::invoke(iter, last);
|
||||
}
|
||||
return std::make_pair(result, end);
|
||||
@ -805,7 +805,7 @@ struct parse_inline_table
|
||||
|
||||
struct parse_table_definition
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<std::vector<toml::key>> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -832,7 +832,7 @@ struct parse_table_definition
|
||||
|
||||
while(iter != last)
|
||||
{
|
||||
iter = is_charactor<value_type, '.'>::invoke(iter, last);
|
||||
iter = is_character<value_type, '.'>::invoke(iter, last);
|
||||
iter = is_any_num_of_ws<value_type>::invoke(iter, last);
|
||||
|
||||
tmp = parse_key::invoke(iter, last);
|
||||
@ -846,7 +846,7 @@ struct parse_table_definition
|
||||
|
||||
struct parse_array_of_table_definition
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef detail::result<std::vector<toml::key>> result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -876,7 +876,7 @@ struct parse_array_of_table_definition
|
||||
|
||||
while(iter != last)
|
||||
{
|
||||
iter = is_charactor<value_type, '.'>::invoke(iter, last);
|
||||
iter = is_character<value_type, '.'>::invoke(iter, last);
|
||||
iter = is_any_num_of_ws<value_type>::invoke(iter, last);
|
||||
|
||||
tmp = parse_key::invoke(iter, last);
|
||||
@ -890,7 +890,7 @@ struct parse_array_of_table_definition
|
||||
|
||||
struct parse_data
|
||||
{
|
||||
typedef toml::charactor value_type;
|
||||
typedef toml::character value_type;
|
||||
typedef toml::Table result_type;
|
||||
|
||||
template<typename Iterator, class = typename std::enable_if<
|
||||
@ -1055,15 +1055,15 @@ struct parse_data
|
||||
|
||||
};
|
||||
|
||||
template<typename traits = std::char_traits<toml::charactor>>
|
||||
toml::Table parse(std::basic_istream<toml::charactor, traits>& is)
|
||||
template<typename traits = std::char_traits<toml::character>>
|
||||
toml::Table parse(std::basic_istream<toml::character, traits>& is)
|
||||
{
|
||||
const auto initial = is.tellg();
|
||||
is.seekg(0, std::ios::end);
|
||||
const auto eofpos = is.tellg();
|
||||
const std::size_t size = eofpos - initial;
|
||||
is.seekg(initial);
|
||||
std::vector<toml::charactor> contents(size);
|
||||
std::vector<toml::character> contents(size);
|
||||
is.read(contents.data(), size);
|
||||
return parse_data::invoke(contents.cbegin(), contents.cend());
|
||||
}
|
||||
|
@ -13,15 +13,15 @@
|
||||
namespace toml
|
||||
{
|
||||
|
||||
using charactor = char;
|
||||
using character = char;
|
||||
|
||||
class value;
|
||||
using key = std::basic_string<charactor>;
|
||||
using key = std::basic_string<character>;
|
||||
|
||||
using Boolean = bool;
|
||||
using Integer = std::int64_t;
|
||||
using Float = double;
|
||||
using String = std::basic_string<charactor>;
|
||||
using String = std::basic_string<character>;
|
||||
using Datetime = basic_datetime<unsigned int, int>;
|
||||
using Array = std::vector<value>;
|
||||
using Table = std::unordered_map<key, value>;
|
||||
@ -39,7 +39,7 @@ enum class value_t : std::uint8_t
|
||||
Unknown = 255,
|
||||
};
|
||||
|
||||
template<typename charT = charactor, typename traits = std::char_traits<charT>>
|
||||
template<typename charT = character, typename traits = std::char_traits<charT>>
|
||||
inline std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, value_t t)
|
||||
{
|
||||
@ -58,7 +58,7 @@ operator<<(std::basic_ostream<charT, traits>& os, value_t t)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename charT = charactor, typename traits = std::char_traits<charT>,
|
||||
template<typename charT = character, typename traits = std::char_traits<charT>,
|
||||
typename alloc = std::allocator<charT>>
|
||||
inline std::basic_string<charT, traits, alloc>
|
||||
stringize(value_t t)
|
||||
|
Loading…
Reference in New Issue
Block a user