-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added `toml::is_number<>` - added `toml::node_type::none` - added initializer_list and vector relops to `toml::array` - added constructors for `time_offset` and `date_time` - added much to `node_view` - added tests for `node_view` value relops - added lots more documentation - removed `time_offset::from_hh_mm` - removed the handling of `\s` literals (looks like it's not going be accepted as-is)
- Loading branch information
Showing
21 changed files
with
1,019 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,24 +52,217 @@ | |
#undef TOML_STRING_PREFIX | ||
#undef TOML_UNDEF_MACROS | ||
#undef TOML_DOXYGEN | ||
#undef TOML_RELOPS_REORDERING | ||
#undef TOML_ASYMMETRICAL_EQUALITY_OPS | ||
#endif | ||
|
||
/// \mainpage toml++ | ||
/// | ||
/// This is the home of the API documentation for toml++, a [TOML](https://github.com/toml-lang/toml) parser for C++17 and later. | ||
/// If you're looking for information about how to add toml++ to your project etc, see the | ||
/// see [README](https://github.com/marzer/tomlplusplus/blob/master/README.md) on GitHub. | ||
/// Otherwise, browse the docs using the links at the top of the page. You can search from anywhere by pressing the TAB key. | ||
/// This is the home of toml++, a header-only [TOML](https://github.com/toml-lang/toml) parser and serializer for C++17 and later. | ||
/// | ||
/// \tableofcontents | ||
/// | ||
/// <em>Obviously this page is pretty sparse and could do with some more content. If you have concrete suggestions for what | ||
/// should go here, please [let me know](https://github.com/marzer/tomlplusplus/issues)!</em> | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-features Features | ||
/// - C++17 (plus some C++20 features where supported, e.g. char8_t strings) | ||
/// - Proper UTF-8 handling (incl. BOM) | ||
/// - Works with or without exceptions | ||
/// - Doesn't require RTTI | ||
/// - First-class support for serializing to JSON | ||
/// - Fully [TOML v0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md)-compliant | ||
/// - Supports a number of 'unreleased' TOML features (optional; these can be disabled) | ||
/// | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-adding-lib Adding toml++ to your project | ||
/// Clone [the repository](https://github.com/marzer/tomlplusplus/) from GitHub. It's header-only so there's not much you have to do after that, | ||
/// other than some very minor (optional) configuration. See the [README](https://github.com/marzer/tomlplusplus/blob/master/README.md) for more info. | ||
/// | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-api-documentation API Documentation | ||
/// You're looking at it! Browse the docs using the links at the top of the page. You can search from anywhere by pressing the TAB key. | ||
/// | ||
/// <em>toml++ is still pretty hot off the presses so there's going to be some omissions, typos and general sparseness throughout the docs. | ||
/// If you spot something or have a suggestion, please [let me know](https://github.com/marzer/tomlplusplus/issues)!</em> | ||
/// | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-example Basic examples | ||
/// | ||
/////////////////////////////////// | ||
/// | ||
/// \subsection mainpage-example-parsing-files Parsing TOML files | ||
/// toml++ works whether you have exceptions enabled or not. For the most part the usage is the same, | ||
/// the main difference being how parsing errors are reported to the caller. When exceptions are enabled | ||
/// a toml::parse_error is thrown directly from the site of the error: | ||
/// \cpp | ||
/// #include <iostream> | ||
/// #include <fstream> //required for parse_file() | ||
/// #include <toml++/toml.h> | ||
/// using namespace std::string_view_literals; | ||
/// | ||
/// int main() | ||
/// { | ||
/// toml::table tbl; | ||
/// try | ||
/// { | ||
/// tbl = toml::parse_file("configuration.toml"); | ||
/// } | ||
/// catch (const toml::parse_error& err) | ||
/// { | ||
/// std::cerr | ||
/// << "Error parsing file '"sv << *err.source().path | ||
/// << "':\n"sv << err.description() | ||
/// << "\n ("sv << err.source().begin << ")"sv | ||
/// << std::endl; | ||
/// return 1; | ||
/// } | ||
/// | ||
/// do_stuff_with_your_config(tbl); | ||
/// return 0; | ||
/// } | ||
/// | ||
/// \ecpp | ||
/// | ||
/// When exceptions are disabled parsing methods return a toml::parse_error and it is up to the caller | ||
/// to check if parsing has been successful by examining the return value: | ||
/// \cpp | ||
/// #include <iostream> | ||
/// #include <fstream> //required for parse_file() | ||
/// #include <toml++/toml.h> | ||
/// using namespace std::string_view_literals; | ||
/// | ||
/// int main() | ||
/// { | ||
/// toml::parse_result tbl = toml::parse_file("configuration.toml"); | ||
/// if (!tbl) | ||
/// { | ||
/// std::cerr | ||
/// << "Error parsing file '"sv << *tbl.error().source().path | ||
/// << "':\n"sv << tbl.error().description() | ||
/// << "\n ("sv << tbl.error().source().begin << ")"sv | ||
/// << std::endl; | ||
/// return 1; | ||
/// } | ||
/// | ||
/// do_stuff_with_your_config(tbl); //toml::parse_result is convertible to toml::table | ||
/// return 0; | ||
/// } | ||
/// \ecpp | ||
/// \see toml::parse_file() | ||
/// | ||
/////////////////////////////////// | ||
/// | ||
/// \subsection mainpage-example-parsing-strings Parsing TOML directly from strings | ||
/// | ||
/// \cpp | ||
/// #include <iostream> | ||
/// #include <toml++/toml.h> | ||
/// using namespace std::string_view_literals; | ||
/// | ||
/// int main() | ||
/// { | ||
/// // parse error handling omitted for brevity. | ||
/// static constexpr auto source = R"( | ||
/// [library] | ||
/// name = "toml++" | ||
/// version = "0.1.0" | ||
/// authors = ["Mark Gillard <[email protected]>"] | ||
/// | ||
/// [dependencies] | ||
/// cpp = 17 | ||
/// )"sv; | ||
/// auto tbl = toml::parse(source); | ||
/// std::cout << tbl << std::endl; | ||
/// return 0; | ||
/// } | ||
/// \ecpp | ||
/// | ||
/// \out | ||
/// [dependencies] | ||
/// cpp = 17 | ||
/// | ||
/// [library] | ||
/// authors = ["Mark Gillard <[email protected]>"] | ||
/// name = "toml++" | ||
/// version = "0.1.0" | ||
/// \eout | ||
/// \see toml::parse() | ||
/// | ||
/////////////////////////////////// | ||
/// | ||
/// \subsection mainpage-example-manipulations Traversing and manipulating data | ||
/// | ||
/// \cpp | ||
/// #include <iostream> | ||
/// #include <toml++/toml.h> | ||
/// using namespace std::string_view_literals; | ||
/// | ||
/// int main() | ||
/// { | ||
/// static constexpr auto source = R"( | ||
/// numbers = [ 1, 2, 3, "four", 5.0 ] | ||
/// vegetables = [ "tomato", "onion", "mushroom", "lettuce" ] | ||
/// minerals = [ "quartz", "iron", "copper", "diamond" ] | ||
/// | ||
/// [animals] | ||
/// cats = [ "tiger", "lion", "puma" ] | ||
/// birds = [ "macaw", "pigeon", "canary" ] | ||
/// fish = [ "salmon", "trout", "carp" ] | ||
/// | ||
/// )"sv; | ||
/// auto tbl = toml::parse(source); | ||
/// | ||
/// auto numbers = tbl["numbers"]; | ||
/// std::cout << "table has 'numbers': "sv << !!numbers << std::endl; | ||
/// if (numbers) | ||
/// { | ||
/// std::cout << "'numbers' is a: "sv << numbers.type() << std::endl; | ||
/// std::cout << "'numbers': "sv << numbers << std::endl; | ||
/// for (auto& node : *numbers.as_array()) | ||
/// { | ||
/// node.visit([=](auto&& n) noexcept | ||
/// { | ||
/// if constexpr (toml::is_number<decltype(n)>) | ||
/// (*n)++; | ||
/// else if constexpr (toml::is_string<decltype(n)>) | ||
/// n = "five"sv; | ||
/// }); | ||
/// } | ||
/// numbers.as_array()->push_back(7); | ||
/// numbers.as_array()->emplace_back<toml::array>(8, 9); | ||
/// std::cout << "'numbers': "sv << numbers << std::endl; | ||
/// } | ||
/// | ||
/// std::cout << "'cats': "sv << tbl["animals"]["cats"] << std::endl; | ||
/// std::cout << "'dinosaurs': "sv << tbl["animals"]["dinosaurs"] << std::endl; //no dinosaurs :( | ||
/// | ||
/// return 0; | ||
/// } | ||
/// \ecpp | ||
/// | ||
/// \out | ||
/// table has 'numbers': true | ||
/// 'numbers' is an: array | ||
/// 'numbers': [1, 2, 3, "four", 5.0] | ||
/// 'numbers': [2, 3, 4, "five", 6.0, 7, [8, 9]] | ||
/// 'cats': ["tiger", "lion", "puma"] | ||
/// 'dinosaurs': | ||
/// \eout | ||
/// | ||
/// \see toml::node, toml::node_view, toml::array, toml::table | ||
/// | ||
/////////////////////////////////// | ||
/// | ||
/// \subsection mainpage-example-serialization Serializing as TOML and JSON | ||
/// \cpp | ||
/// #include <iostream> | ||
/// #include <toml++/toml.h> | ||
/// | ||
/// int main() | ||
/// { | ||
/// auto tbl = toml::table{{ | ||
/// { "lib", "toml++" }, | ||
/// { "cpp", toml::array{ 17, 20, "and beyond" } }, | ||
|
@@ -82,21 +275,62 @@ | |
/// }} | ||
/// }, | ||
/// }}; | ||
/// | ||
/// std::cout << "###### TOML ######"sv << std::endl; | ||
/// std::cout << tbl << std::endl << std::endl; | ||
/// | ||
/// std::cout << tbl << std::endl; | ||
/// std::cout << "###### JSON ######"sv << std::endl; | ||
/// std::cout << toml::json_formatter{ tbl } << std::endl; | ||
/// return 0; | ||
/// } | ||
/// \ecpp | ||
/// | ||
/// | ||
/// \out | ||
/// cpp = [ 17, 20, "and beyond" ] | ||
/// ###### TOML ###### | ||
/// cpp = [17, 20, "and beyond"] | ||
/// lib = "toml++" | ||
/// repo = "https://github.com/marzer/tomlplusplus/" | ||
/// toml = [ "0.5.0", "and beyond" ] | ||
/// toml = ["0.5.0", "and beyond"] | ||
/// | ||
/// [author] | ||
/// github = "https://github.com/marzer" | ||
/// name = "Mark Gillard" | ||
/// twitter = "https://twitter.com/marzer8789" | ||
/// | ||
/// ###### JSON ###### | ||
/// { | ||
/// "author" : { | ||
/// "github" : "https://github.com/marzer", | ||
/// "name" : "Mark Gillard", | ||
/// "twitter" : "https://twitter.com/marzer8789" | ||
/// }, | ||
/// "cpp" : [ | ||
/// 17, | ||
/// 20, | ||
/// "and beyond" | ||
/// ], | ||
/// "lib" : "toml++", | ||
/// "repo" : "https://github.com/marzer/tomlplusplus/", | ||
/// "toml" : [ | ||
/// "0.5.0", | ||
/// "and beyond" | ||
/// ] | ||
/// } | ||
/// \eout | ||
/// \see toml::default_formatter, toml::json_formatter | ||
/// | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-contributing Contributing | ||
/// See the [Contributing](https://github.com/marzer/tomlplusplus/blob/master/README.md#contributing) section of the repository README. | ||
/// | ||
/////////////////////////////////////////////////////////////////////// | ||
/// | ||
/// \section mainpage-license License | ||
/// | ||
/// toml++ is licensed under the terms of the MIT license - see [LICENSE](https://github.com/marzer/tomlplusplus/blob/master/LICENSE). | ||
/// | ||
/// UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's 'Flexible and Economical UTF - 8 Decoder', which is also subject | ||
/// to the terms of the MIT license - see [LICENSE-utf8-decoder](https://github.com/marzer/tomlplusplus/blob/master/LICENSE-utf8-decoder). | ||
/// | ||
/// |
Oops, something went wrong.