|
52 | 52 | #undef TOML_STRING_PREFIX
|
53 | 53 | #undef TOML_UNDEF_MACROS
|
54 | 54 | #undef TOML_DOXYGEN
|
| 55 | + #undef TOML_RELOPS_REORDERING |
| 56 | + #undef TOML_ASYMMETRICAL_EQUALITY_OPS |
55 | 57 | #endif
|
56 | 58 |
|
57 | 59 | /// \mainpage toml++
|
58 | 60 | ///
|
59 |
| -/// This is the home of the API documentation for toml++, a [TOML](https://github.com/toml-lang/toml) parser for C++17 and later. |
60 |
| -/// If you're looking for information about how to add toml++ to your project etc, see the |
61 |
| -/// see [README](https://github.com/marzer/tomlplusplus/blob/master/README.md) on GitHub. |
62 |
| -/// Otherwise, browse the docs using the links at the top of the page. You can search from anywhere by pressing the TAB key. |
| 61 | +/// This is the home of toml++, a header-only [TOML](https://github.com/toml-lang/toml) parser and serializer for C++17 and later. |
| 62 | +/// |
| 63 | +/// \tableofcontents |
63 | 64 | ///
|
64 |
| -/// <em>Obviously this page is pretty sparse and could do with some more content. If you have concrete suggestions for what |
65 |
| -/// should go here, please [let me know](https://github.com/marzer/tomlplusplus/issues)!</em> |
| 65 | +/////////////////////////////////////////////////////////////////////// |
66 | 66 | ///
|
| 67 | +/// \section mainpage-features Features |
| 68 | +/// - C++17 (plus some C++20 features where supported, e.g. char8_t strings) |
| 69 | +/// - Proper UTF-8 handling (incl. BOM) |
| 70 | +/// - Works with or without exceptions |
| 71 | +/// - Doesn't require RTTI |
| 72 | +/// - First-class support for serializing to JSON |
| 73 | +/// - Fully [TOML v0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md)-compliant |
| 74 | +/// - Supports a number of 'unreleased' TOML features (optional; these can be disabled) |
| 75 | +/// |
| 76 | +/////////////////////////////////////////////////////////////////////// |
| 77 | +/// |
| 78 | +/// \section mainpage-adding-lib Adding toml++ to your project |
| 79 | +/// 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, |
| 80 | +/// other than some very minor (optional) configuration. See the [README](https://github.com/marzer/tomlplusplus/blob/master/README.md) for more info. |
| 81 | +/// |
| 82 | +/////////////////////////////////////////////////////////////////////// |
| 83 | +/// |
| 84 | +/// \section mainpage-api-documentation API Documentation |
| 85 | +/// 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. |
| 86 | +/// |
| 87 | +/// <em>toml++ is still pretty hot off the presses so there's going to be some omissions, typos and general sparseness throughout the docs. |
| 88 | +/// If you spot something or have a suggestion, please [let me know](https://github.com/marzer/tomlplusplus/issues)!</em> |
| 89 | +/// |
| 90 | +/////////////////////////////////////////////////////////////////////// |
| 91 | +/// |
| 92 | +/// \section mainpage-example Basic examples |
| 93 | +/// |
| 94 | +/////////////////////////////////// |
| 95 | +/// |
| 96 | +/// \subsection mainpage-example-parsing-files Parsing TOML files |
| 97 | +/// toml++ works whether you have exceptions enabled or not. For the most part the usage is the same, |
| 98 | +/// the main difference being how parsing errors are reported to the caller. When exceptions are enabled |
| 99 | +/// a toml::parse_error is thrown directly from the site of the error: |
67 | 100 | /// \cpp
|
68 | 101 | /// #include <iostream>
|
| 102 | +/// #include <fstream> //required for parse_file() |
69 | 103 | /// #include <toml++/toml.h>
|
| 104 | +/// using namespace std::string_view_literals; |
70 | 105 | ///
|
71 | 106 | /// int main()
|
72 | 107 | /// {
|
| 108 | +/// toml::table tbl; |
| 109 | +/// try |
| 110 | +/// { |
| 111 | +/// tbl = toml::parse_file("configuration.toml"); |
| 112 | +/// } |
| 113 | +/// catch (const toml::parse_error& err) |
| 114 | +/// { |
| 115 | +/// std::cerr |
| 116 | +/// << "Error parsing file '"sv << *err.source().path |
| 117 | +/// << "':\n"sv << err.description() |
| 118 | +/// << "\n ("sv << err.source().begin << ")"sv |
| 119 | +/// << std::endl; |
| 120 | +/// return 1; |
| 121 | +/// } |
| 122 | +/// |
| 123 | +/// do_stuff_with_your_config(tbl); |
| 124 | +/// return 0; |
| 125 | +/// } |
| 126 | +/// |
| 127 | +/// \ecpp |
| 128 | +/// |
| 129 | +/// When exceptions are disabled parsing methods return a toml::parse_error and it is up to the caller |
| 130 | +/// to check if parsing has been successful by examining the return value: |
| 131 | +/// \cpp |
| 132 | +/// #include <iostream> |
| 133 | +/// #include <fstream> //required for parse_file() |
| 134 | +/// #include <toml++/toml.h> |
| 135 | +/// using namespace std::string_view_literals; |
| 136 | +/// |
| 137 | +/// int main() |
| 138 | +/// { |
| 139 | +/// toml::parse_result tbl = toml::parse_file("configuration.toml"); |
| 140 | +/// if (!tbl) |
| 141 | +/// { |
| 142 | +/// std::cerr |
| 143 | +/// << "Error parsing file '"sv << *tbl.error().source().path |
| 144 | +/// << "':\n"sv << tbl.error().description() |
| 145 | +/// << "\n ("sv << tbl.error().source().begin << ")"sv |
| 146 | +/// << std::endl; |
| 147 | +/// return 1; |
| 148 | +/// } |
| 149 | +/// |
| 150 | +/// do_stuff_with_your_config(tbl); //toml::parse_result is convertible to toml::table |
| 151 | +/// return 0; |
| 152 | +/// } |
| 153 | +/// \ecpp |
| 154 | +/// \see toml::parse_file() |
| 155 | +/// |
| 156 | +/////////////////////////////////// |
| 157 | +/// |
| 158 | +/// \subsection mainpage-example-parsing-strings Parsing TOML directly from strings |
| 159 | +/// |
| 160 | +/// \cpp |
| 161 | +/// #include <iostream> |
| 162 | +/// #include <toml++/toml.h> |
| 163 | +/// using namespace std::string_view_literals; |
| 164 | +/// |
| 165 | +/// int main() |
| 166 | +/// { |
| 167 | +/// // parse error handling omitted for brevity. |
| 168 | +/// static constexpr auto source = R"( |
| 169 | +/// [library] |
| 170 | +/// name = "toml++" |
| 171 | +/// version = "0.1.0" |
| 172 | +/// authors = ["Mark Gillard <[email protected]>"] |
| 173 | +/// |
| 174 | +/// [dependencies] |
| 175 | +/// cpp = 17 |
| 176 | +/// )"sv; |
| 177 | +/// auto tbl = toml::parse(source); |
| 178 | +/// std::cout << tbl << std::endl; |
| 179 | +/// return 0; |
| 180 | +/// } |
| 181 | +/// \ecpp |
| 182 | +/// |
| 183 | +/// \out |
| 184 | +/// [dependencies] |
| 185 | +/// cpp = 17 |
| 186 | +/// |
| 187 | +/// [library] |
| 188 | +/// authors = ["Mark Gillard <[email protected]>"] |
| 189 | +/// name = "toml++" |
| 190 | +/// version = "0.1.0" |
| 191 | +/// \eout |
| 192 | +/// \see toml::parse() |
| 193 | +/// |
| 194 | +/////////////////////////////////// |
| 195 | +/// |
| 196 | +/// \subsection mainpage-example-manipulations Traversing and manipulating data |
| 197 | +/// |
| 198 | +/// \cpp |
| 199 | +/// #include <iostream> |
| 200 | +/// #include <toml++/toml.h> |
| 201 | +/// using namespace std::string_view_literals; |
| 202 | +/// |
| 203 | +/// int main() |
| 204 | +/// { |
| 205 | +/// static constexpr auto source = R"( |
| 206 | +/// numbers = [ 1, 2, 3, "four", 5.0 ] |
| 207 | +/// vegetables = [ "tomato", "onion", "mushroom", "lettuce" ] |
| 208 | +/// minerals = [ "quartz", "iron", "copper", "diamond" ] |
| 209 | +/// |
| 210 | +/// [animals] |
| 211 | +/// cats = [ "tiger", "lion", "puma" ] |
| 212 | +/// birds = [ "macaw", "pigeon", "canary" ] |
| 213 | +/// fish = [ "salmon", "trout", "carp" ] |
| 214 | +/// |
| 215 | +/// )"sv; |
| 216 | +/// auto tbl = toml::parse(source); |
| 217 | +/// |
| 218 | +/// auto numbers = tbl["numbers"]; |
| 219 | +/// std::cout << "table has 'numbers': "sv << !!numbers << std::endl; |
| 220 | +/// if (numbers) |
| 221 | +/// { |
| 222 | +/// std::cout << "'numbers' is a: "sv << numbers.type() << std::endl; |
| 223 | +/// std::cout << "'numbers': "sv << numbers << std::endl; |
| 224 | +/// for (auto& node : *numbers.as_array()) |
| 225 | +/// { |
| 226 | +/// node.visit([=](auto&& n) noexcept |
| 227 | +/// { |
| 228 | +/// if constexpr (toml::is_number<decltype(n)>) |
| 229 | +/// (*n)++; |
| 230 | +/// else if constexpr (toml::is_string<decltype(n)>) |
| 231 | +/// n = "five"sv; |
| 232 | +/// }); |
| 233 | +/// } |
| 234 | +/// numbers.as_array()->push_back(7); |
| 235 | +/// numbers.as_array()->emplace_back<toml::array>(8, 9); |
| 236 | +/// std::cout << "'numbers': "sv << numbers << std::endl; |
| 237 | +/// } |
| 238 | +/// |
| 239 | +/// std::cout << "'cats': "sv << tbl["animals"]["cats"] << std::endl; |
| 240 | +/// std::cout << "'dinosaurs': "sv << tbl["animals"]["dinosaurs"] << std::endl; //no dinosaurs :( |
| 241 | +/// |
| 242 | +/// return 0; |
| 243 | +/// } |
| 244 | +/// \ecpp |
| 245 | +/// |
| 246 | +/// \out |
| 247 | +/// table has 'numbers': true |
| 248 | +/// 'numbers' is an: array |
| 249 | +/// 'numbers': [1, 2, 3, "four", 5.0] |
| 250 | +/// 'numbers': [2, 3, 4, "five", 6.0, 7, [8, 9]] |
| 251 | +/// 'cats': ["tiger", "lion", "puma"] |
| 252 | +/// 'dinosaurs': |
| 253 | +/// \eout |
| 254 | +/// |
| 255 | +/// \see toml::node, toml::node_view, toml::array, toml::table |
| 256 | +/// |
| 257 | +/////////////////////////////////// |
| 258 | +/// |
| 259 | +/// \subsection mainpage-example-serialization Serializing as TOML and JSON |
| 260 | +/// \cpp |
| 261 | +/// #include <iostream> |
| 262 | +/// #include <toml++/toml.h> |
| 263 | +/// |
| 264 | +/// int main() |
| 265 | +/// { |
73 | 266 | /// auto tbl = toml::table{{
|
74 | 267 | /// { "lib", "toml++" },
|
75 | 268 | /// { "cpp", toml::array{ 17, 20, "and beyond" } },
|
|
82 | 275 | /// }}
|
83 | 276 | /// },
|
84 | 277 | /// }};
|
| 278 | +/// |
| 279 | +/// std::cout << "###### TOML ######"sv << std::endl; |
| 280 | +/// std::cout << tbl << std::endl << std::endl; |
85 | 281 | ///
|
86 |
| -/// std::cout << tbl << std::endl; |
| 282 | +/// std::cout << "###### JSON ######"sv << std::endl; |
| 283 | +/// std::cout << toml::json_formatter{ tbl } << std::endl; |
87 | 284 | /// return 0;
|
88 | 285 | /// }
|
89 | 286 | /// \ecpp
|
90 |
| -/// |
| 287 | +/// |
91 | 288 | /// \out
|
92 |
| -/// cpp = [ 17, 20, "and beyond" ] |
| 289 | +/// ###### TOML ###### |
| 290 | +/// cpp = [17, 20, "and beyond"] |
93 | 291 | /// lib = "toml++"
|
94 | 292 | /// repo = "https://github.com/marzer/tomlplusplus/"
|
95 |
| -/// toml = [ "0.5.0", "and beyond" ] |
| 293 | +/// toml = ["0.5.0", "and beyond"] |
96 | 294 | ///
|
97 | 295 | /// [author]
|
98 | 296 | /// github = "https://github.com/marzer"
|
99 | 297 | /// name = "Mark Gillard"
|
100 | 298 | /// twitter = "https://twitter.com/marzer8789"
|
| 299 | +/// |
| 300 | +/// ###### JSON ###### |
| 301 | +/// { |
| 302 | +/// "author" : { |
| 303 | +/// "github" : "https://github.com/marzer", |
| 304 | +/// "name" : "Mark Gillard", |
| 305 | +/// "twitter" : "https://twitter.com/marzer8789" |
| 306 | +/// }, |
| 307 | +/// "cpp" : [ |
| 308 | +/// 17, |
| 309 | +/// 20, |
| 310 | +/// "and beyond" |
| 311 | +/// ], |
| 312 | +/// "lib" : "toml++", |
| 313 | +/// "repo" : "https://github.com/marzer/tomlplusplus/", |
| 314 | +/// "toml" : [ |
| 315 | +/// "0.5.0", |
| 316 | +/// "and beyond" |
| 317 | +/// ] |
| 318 | +/// } |
101 | 319 | /// \eout
|
| 320 | +/// \see toml::default_formatter, toml::json_formatter |
| 321 | +/// |
| 322 | +/////////////////////////////////////////////////////////////////////// |
| 323 | +/// |
| 324 | +/// \section mainpage-contributing Contributing |
| 325 | +/// See the [Contributing](https://github.com/marzer/tomlplusplus/blob/master/README.md#contributing) section of the repository README. |
| 326 | +/// |
| 327 | +/////////////////////////////////////////////////////////////////////// |
| 328 | +/// |
| 329 | +/// \section mainpage-license License |
| 330 | +/// |
| 331 | +/// toml++ is licensed under the terms of the MIT license - see [LICENSE](https://github.com/marzer/tomlplusplus/blob/master/LICENSE). |
| 332 | +/// |
| 333 | +/// UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's 'Flexible and Economical UTF - 8 Decoder', which is also subject |
| 334 | +/// to the terms of the MIT license - see [LICENSE-utf8-decoder](https://github.com/marzer/tomlplusplus/blob/master/LICENSE-utf8-decoder). |
| 335 | +/// |
102 | 336 | ///
|
0 commit comments