Skip to content

Commit

Permalink
release 0.1.0
Browse files Browse the repository at this point in the history
- 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
marzer committed Feb 20, 2020
1 parent 0b4eca3 commit 2219fd2
Show file tree
Hide file tree
Showing 21 changed files with 1,019 additions and 513 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ addition of unreleased features from the [TOML master] and some sane cherry-pick
[TOML issues list] where the discussion strongly indicates inclusion in a near-future release.
The library advertises the most recent numbered language version it fully supports via the preprocessor
defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_REVISION`.
defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`.
### **🔸Unreleased TOML features:**
- [#356]: Allow leading zeros in the exponent part of a float
- [#516]: Allow newlines and trailing commas in inline tables
- [#562]: Allow hex floatingpoint values
- [#567]: Clarify that control characters are not permitted in comments
- [#571]: Allow raw tabs inside strings
- [#622]: Add short escaping alias `\s` for space (`\u0020`)
- [#644]: Support `+` in key names
- [#665]: Make arrays heterogeneous
- [#671]: Local time of day format should support `09:30` as opposed to `09:30:00`
Expand Down Expand Up @@ -167,7 +166,7 @@ cd ../build-clang && ninja && ninja test
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].

[API documentation]: https://marzer.github.io/tomlplusplus/namespacetoml.html
[API documentation]: https://marzer.github.io/tomlplusplus/
[unreleased TOML language features]: https://github.com/marzer/tomlplusplus#unreleased-features
[numbered version]: https://github.com/toml-lang/toml/releases
[char8_t]: https://en.cppreference.com/w/cpp/keyword/char8_t
Expand Down
3 changes: 2 additions & 1 deletion docs/tomlplusplus.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ pre.m-code + pre
{
margin-top: -1.0rem;
color: #bababa; /* is yououou */
background-color: #282e36aa;
background-color: #383e46;
border-top: 2px solid #181e26;
font-size: 0.8rem;
}

Expand Down
254 changes: 244 additions & 10 deletions include/toml++/toml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" } },
Expand All @@ -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).
///
///
Loading

0 comments on commit 2219fd2

Please sign in to comment.