diff --git a/README.md b/README.md index 04225da..5b453d1 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ FetchContent_MakeAvailable(tomlplusplus) ### Other environments and package managers `toml++` is a fairly new project and I'm not up-to-speed with all of the available packaging and integration options -in the modern C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing be +in the C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing be assured that I fully support it being added, and welcome [pull requests](./CONTRIBUTING.md)!
diff --git a/docs/images/banner.ai b/docs/images/banner.ai index 8bb8a4f..7dc7444 100644 Binary files a/docs/images/banner.ai and b/docs/images/banner.ai differ diff --git a/docs/images/banner_large.png b/docs/images/banner_large.png index 108e662..7bea5ee 100644 Binary files a/docs/images/banner_large.png and b/docs/images/banner_large.png differ diff --git a/docs/images/banner_small.png b/docs/images/banner_small.png index 78640f6..5a0a097 100644 Binary files a/docs/images/banner_small.png and b/docs/images/banner_small.png differ diff --git a/docs/pages/main_page.dox b/docs/pages/main_page.dox index da075a4..24b1909 100644 --- a/docs/pages/main_page.dox +++ b/docs/pages/main_page.dox @@ -473,7 +473,7 @@ \subsection mainpage-adding-lib-other Other environments and package managers toml++ is a fairly new project and I'm not up-to-speed with all of the available packaging and integration options - in the modern C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing + in the C++ ecosystem. I'm also a cmake novice, for better or worse. If there's an integration option missing be assured that I fully support it being added, and welcome pull requests! diff --git a/docs/poxy.toml b/docs/poxy.toml index f020cdf..ba25955 100644 --- a/docs/poxy.toml +++ b/docs/poxy.toml @@ -3,7 +3,7 @@ name = 'toml++' author = 'Mark Gillard' -description = 'TOML for modern C++' +description = 'TOML for C++' cpp = 17 github = 'marzer/tomlplusplus' license = [ 'MIT', 'https://github.com/marzer/tomlplusplus/blob/master/LICENSE' ] diff --git a/external/toml-test b/external/toml-test index 51f2e53..f2f2280 160000 --- a/external/toml-test +++ b/external/toml-test @@ -1 +1 @@ -Subproject commit 51f2e538628727ca749e10701aaf8d53a4d81bac +Subproject commit f2f2280c83f74212860fe0f12ee84581836c066c diff --git a/meson.build b/meson.build index 3f03f6c..5ab9365 100644 --- a/meson.build +++ b/meson.build @@ -514,7 +514,7 @@ pkgc = import('pkgconfig') pkgc.generate( name: meson.project_name(), version: meson.project_version(), - description: 'Header-only TOML config file parser and serializer for modern C++', + description: 'Header-only TOML config file parser and serializer for C++', install_dir: join_paths(get_option('datadir'), 'pkgconfig'), ) diff --git a/tests/conformance_burntsushi_invalid.cpp b/tests/conformance_burntsushi_invalid.cpp index cc72d8b..3736a32 100644 --- a/tests/conformance_burntsushi_invalid.cpp +++ b/tests/conformance_burntsushi_invalid.cpp @@ -259,6 +259,18 @@ c = 2)"sv; static constexpr auto table_empty_implicit_table = R"([naughty..naughty])"sv; static constexpr auto table_empty = R"([])"sv; static constexpr auto table_equals_sign = R"([name=bad])"sv; + static constexpr auto table_injection_1 = R"([a.b.c] + z = 9 +[a] + b.c.t = "Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed" + +# see https://github.com/toml-lang/toml/issues/846)"sv; + static constexpr auto table_injection_2 = R"([a.b.c.d] + z = 9 +[a] + b.c.d.k.t = "Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed" + +# see https://github.com/toml-lang/toml/issues/846)"sv; static constexpr auto table_llbrace = R"([ [table]])"sv; static constexpr auto table_nested_brackets_close = R"([a]b] zyx = 42)"sv; @@ -595,6 +607,10 @@ TEST_CASE("conformance - burntsushi/invalid") parsing_should_fail(FILE_LINE_ARGS, table_equals_sign); // table-equals-sign + parsing_should_fail(FILE_LINE_ARGS, table_injection_1); // table-injection-1 + + parsing_should_fail(FILE_LINE_ARGS, table_injection_2); // table-injection-2 + parsing_should_fail(FILE_LINE_ARGS, table_llbrace); // table-llbrace parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close); // table-nested-brackets-close diff --git a/tests/conformance_burntsushi_valid.cpp b/tests/conformance_burntsushi_valid.cpp index d94c421..c1c4d29 100644 --- a/tests/conformance_burntsushi_valid.cpp +++ b/tests/conformance_burntsushi_valid.cpp @@ -447,6 +447,52 @@ two_space = """ ""two quotes"" """ mismatch1 = """aaa'''bbb""" mismatch2 = '''aaa"""bbb''')"sv; + static constexpr auto string_multiline = R"(# NOTE: this file includes some literal tab characters. + +multiline_empty_one = """""" +multiline_empty_two = """ +""" +multiline_empty_three = """\ + """ +multiline_empty_four = """\ + \ + \ + """ + +equivalent_one = "The quick brown fox jumps over the lazy dog." +equivalent_two = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +equivalent_three = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +whitespace-after-bs = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ + +no-space = """a\ + b""" + +keep-ws-before = """a \ + b""" + +escape-bs-1 = """a \\ +b""" + +escape-bs-2 = """a \\\ +b""" + +escape-bs-3 = """a \\\\ + b""")"sv; static constexpr auto string_nl = R"(nl_mid = "val\nue" nl_end = """value\n""" @@ -1622,8 +1668,8 @@ another line)"sv }, parsing_should_succeed(FILE_LINE_ARGS, integer_long, [](toml::table&& tbl) // integer-long { const auto expected = toml::table{{ - { R"(int64-max)"sv, INT64_MAX }, - { R"(int64-max-neg)"sv, INT64_MIN }, + { R"(int64-max)"sv, std::numeric_limits::max() }, + { R"(int64-max-neg)"sv, std::numeric_limits::min() }, }}; REQUIRE(tbl == expected); }); @@ -1817,7 +1863,7 @@ another line)"sv }, parsing_should_succeed(FILE_LINE_ARGS, key_empty, [](toml::table&& tbl) // key-empty { const auto expected = toml::table{{ - { R"()"sv, R"(blank)"sv }, + { ""sv, R"(blank)"sv }, }}; REQUIRE(tbl == expected); }); @@ -2063,7 +2109,7 @@ another line)"sv }, parsing_should_succeed(FILE_LINE_ARGS, string_empty, [](toml::table&& tbl) // string-empty { const auto expected = toml::table{{ - { R"(answer)"sv, R"()"sv }, + { R"(answer)"sv, ""sv }, }}; REQUIRE(tbl == expected); }); @@ -2093,6 +2139,28 @@ another line)"sv }, REQUIRE(tbl == expected); }); + parsing_should_succeed(FILE_LINE_ARGS, string_multiline, [](toml::table&& tbl) // string-multiline + { + const auto expected = toml::table{{ + { R"(equivalent_one)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(equivalent_three)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(equivalent_two)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + { R"(escape-bs-1)"sv, R"(a \ +b)"sv }, + { R"(escape-bs-2)"sv, R"(a \b)"sv }, + { R"(escape-bs-3)"sv, R"(a \\ + b)"sv }, + { R"(keep-ws-before)"sv, R"(a b)"sv }, + { R"(multiline_empty_four)"sv, ""sv }, + { R"(multiline_empty_one)"sv, ""sv }, + { R"(multiline_empty_three)"sv, ""sv }, + { R"(multiline_empty_two)"sv, ""sv }, + { R"(no-space)"sv, R"(ab)"sv }, + { R"(whitespace-after-bs)"sv, R"(The quick brown fox jumps over the lazy dog.)"sv }, + }}; + REQUIRE(tbl == expected); + }); + parsing_should_succeed(FILE_LINE_ARGS, string_nl, [](toml::table&& tbl) // string-nl { const auto expected = toml::table{{ diff --git a/tests/conformance_iarna_valid.cpp b/tests/conformance_iarna_valid.cpp index 801edd8..8dc9195 100644 --- a/tests/conformance_iarna_valid.cpp +++ b/tests/conformance_iarna_valid.cpp @@ -204,6 +204,8 @@ The quick brown \ fox jumps over \ the lazy dog.\ """)"sv; + static constexpr auto spec_string_basic_multiline_4 = R"(a = """abc\ +def""")"sv; static constexpr auto spec_string_basic_multiline_5 = R"(ml-escaped-nl = """ foo \ bar \\ @@ -665,7 +667,7 @@ TEST_CASE("conformance - iarna/valid") parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_1, [](toml::table&& tbl) // spec-empty-key-name-1 { const auto expected = toml::table{{ - { R"()"sv, R"(blank)"sv }, + { ""sv, R"(blank)"sv }, }}; REQUIRE(tbl == expected); }); @@ -673,7 +675,7 @@ TEST_CASE("conformance - iarna/valid") parsing_should_succeed(FILE_LINE_ARGS, spec_empty_key_name_2, [](toml::table&& tbl) // spec-empty-key-name-2 { const auto expected = toml::table{{ - { R"()"sv, R"(blank)"sv }, + { ""sv, R"(blank)"sv }, }}; REQUIRE(tbl == expected); }); @@ -964,7 +966,7 @@ TEST_CASE("conformance - iarna/valid") parsing_should_succeed(FILE_LINE_ARGS, spec_int_max, [](toml::table&& tbl) // spec-int-max { const auto expected = toml::table{{ - { R"(max)"sv, INT64_MAX }, + { R"(max)"sv, std::numeric_limits::max() }, }}; REQUIRE(tbl == expected); }); @@ -972,7 +974,7 @@ TEST_CASE("conformance - iarna/valid") parsing_should_succeed(FILE_LINE_ARGS, spec_int_min, [](toml::table&& tbl) // spec-int-min { const auto expected = toml::table{{ - { R"(min)"sv, INT64_MIN }, + { R"(min)"sv, std::numeric_limits::min() }, }}; REQUIRE(tbl == expected); }); @@ -1168,6 +1170,14 @@ Violets are blue)"sv }, REQUIRE(tbl == expected); }); + parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_4, [](toml::table&& tbl) // spec-string-basic-multiline-4 + { + const auto expected = toml::table{{ + { R"(a)"sv, R"(abcdef)"sv }, + }}; + REQUIRE(tbl == expected); + }); + parsing_should_succeed(FILE_LINE_ARGS, spec_string_basic_multiline_5, [](toml::table&& tbl) // spec-string-basic-multiline-5 { const auto expected = toml::table{{ diff --git a/tools/generate_conformance_tests.py b/tools/generate_conformance_tests.py index 8db5fc7..d82a0d4 100644 --- a/tools/generate_conformance_tests.py +++ b/tools/generate_conformance_tests.py @@ -29,8 +29,10 @@ def python_value_to_tomlpp(val): if isinstance(val, str): if re.fullmatch(r'^[+-]?[0-9]+[eE][+-]?[0-9]+$', val, re.M): return str(float(val)) + elif not val: + return r'""sv' else: - return 'R"({})"sv'.format(val) + return rf'R"({val})"sv' elif isinstance(val, bool): return 'true' if val else 'false' elif isinstance(val, float): @@ -42,9 +44,9 @@ def python_value_to_tomlpp(val): return str(val) elif isinstance(val, int): if val == 9223372036854775807: - return 'INT64_MAX' + return 'std::numeric_limits::max()' elif val == -9223372036854775808: - return 'INT64_MIN' + return 'std::numeric_limits::min()' else: return str(val) elif isinstance(val, (TomlPPArray, TomlPPTable)): @@ -216,6 +218,7 @@ class TomlTest: self.__identifier = sanitize(self.__name) self.__group = self.__identifier.strip('_').split('_')[0] self.__data = utils.read_all_text_from_file(file_path, logger=True).strip() + self.__data = re.sub(r'\\[ \t]+?\n', '\\\n', self.__data, re.S) # C++ compilers don't like whitespace after trailing slashes self.__conditions = [] if is_valid_case: self.__expected = True @@ -323,8 +326,6 @@ def load_valid_inputs(tests, extern_root): 'string-escapes', # broken by the json reader 'key-alphanum', - # whitespace after trailing slash in raw strings breaks GCC - 'string-multiline' )) add_condition(tests['valid']['burntsushi'], '!TOML_MSVC', ( 'inline-table-key-dotted', # causes MSVC to run out of heap space during compilation O_o @@ -349,8 +350,6 @@ def load_valid_inputs(tests, extern_root): 'spec-date-time-6', 'spec-date-time-local-2', 'spec-time-2', - # whitespace after trailing slash in raw strings breaks GCC - 'spec-string-basic-multiline-4', ))