2020-03-12 15:23:25 +00:00
|
|
|
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
|
2021-01-02 15:48:47 +00:00
|
|
|
//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
|
2020-03-12 15:23:25 +00:00
|
|
|
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
2020-04-10 16:46:00 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-01-04 14:21:38 +00:00
|
|
|
#pragma once
|
2021-10-24 22:04:23 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#include "preprocessor.h"
|
2021-10-30 12:56:14 +00:00
|
|
|
#if TOML_ENABLE_PARSER
|
2021-10-24 22:04:23 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#include "table.h"
|
|
|
|
#include "parse_result.h"
|
2021-10-24 10:21:32 +00:00
|
|
|
#include "header_start.h"
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-07-25 17:37:30 +00:00
|
|
|
TOML_NAMESPACE_START
|
2020-01-04 14:21:38 +00:00
|
|
|
{
|
2021-05-06 08:03:25 +00:00
|
|
|
TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, ex, noex);
|
2020-03-28 16:56:59 +00:00
|
|
|
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \brief Parses a TOML document from a string view.
|
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// auto tbl = toml::parse("a = 3"sv);
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::string_view doc, std::string_view source_path = {});
|
2020-02-03 09:12:43 +00:00
|
|
|
|
|
|
|
/// \brief Parses a TOML document from a string view.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// auto tbl = toml::parse("a = 3"sv, "foo.toml");
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
2020-07-13 18:18:04 +00:00
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::string_view doc, std::string && source_path);
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a file.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// toml::parse_result get_foo_toml()
|
|
|
|
/// {
|
|
|
|
/// return toml::parse_file("foo.toml");
|
|
|
|
/// }
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \param file_path The TOML document to parse. Must be valid UTF-8.
|
2020-07-13 18:18:04 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse_file(std::string_view file_path);
|
2020-07-13 18:18:04 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#if TOML_HAS_CHAR8
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \brief Parses a TOML document from a char8_t string view.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// auto tbl = toml::parse(u8"a = 3"sv);
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::u8string_view doc, std::string_view source_path = {});
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \brief Parses a TOML document from a char8_t string view.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// auto tbl = toml::parse(u8"a = 3"sv, "foo.toml");
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
2020-07-13 18:18:04 +00:00
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::u8string_view doc, std::string && source_path);
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a file.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// toml::parse_result get_foo_toml()
|
|
|
|
/// {
|
|
|
|
/// return toml::parse_file(u8"foo.toml");
|
|
|
|
/// }
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \param file_path The TOML document to parse. Must be valid UTF-8.
|
2020-07-13 18:18:04 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse_file(std::u8string_view file_path);
|
2020-07-13 18:18:04 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#endif // TOML_HAS_CHAR8
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2021-10-30 14:26:05 +00:00
|
|
|
#if TOML_ENABLE_WINDOWS_COMPAT
|
2021-10-24 22:04:23 +00:00
|
|
|
|
|
|
|
/// \brief Parses a TOML document from a string view.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-10-30 14:26:05 +00:00
|
|
|
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
2021-10-30 12:56:14 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// auto tbl = toml::parse("a = 3"sv, L"foo.toml");
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::string_view doc, std::wstring_view source_path);
|
2020-01-04 14:21:38 +00:00
|
|
|
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \brief Parses a TOML document from a stream.
|
|
|
|
///
|
2021-10-30 14:26:05 +00:00
|
|
|
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
2021-10-30 12:56:14 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// std::stringstream ss;
|
|
|
|
/// ss << "a = 3"sv;
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// auto tbl = toml::parse(ss);
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-03 09:12:43 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
2020-07-13 18:18:04 +00:00
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::istream & doc, std::wstring_view source_path);
|
2020-07-13 18:18:04 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a file.
|
2020-07-13 18:18:04 +00:00
|
|
|
///
|
2021-10-30 14:26:05 +00:00
|
|
|
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
2021-10-30 12:56:14 +00:00
|
|
|
///
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// toml::parse_result get_foo_toml()
|
|
|
|
/// {
|
|
|
|
/// return toml::parse_file(L"foo.toml");
|
|
|
|
/// }
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \param file_path The TOML document to parse. Must be valid UTF-8.
|
2020-07-13 18:18:04 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse_file(std::wstring_view file_path);
|
2020-07-13 18:18:04 +00:00
|
|
|
|
2021-10-30 14:26:05 +00:00
|
|
|
#endif // TOML_ENABLE_WINDOWS_COMPAT
|
2020-07-13 18:18:04 +00:00
|
|
|
|
2021-10-30 14:26:05 +00:00
|
|
|
#if TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
|
2020-06-08 15:31:23 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a char8_t string view.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-10-30 14:26:05 +00:00
|
|
|
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
2021-10-30 12:56:14 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// auto tbl = toml::parse(u8"a = 3"sv, L"foo.toml");
|
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
|
|
|
///
|
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2020-02-03 09:12:43 +00:00
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::u8string_view doc, std::wstring_view source_path);
|
2021-05-19 11:36:25 +00:00
|
|
|
|
2021-10-30 14:26:05 +00:00
|
|
|
#endif // TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
|
2021-05-19 11:36:25 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a stream.
|
2021-05-19 11:36:25 +00:00
|
|
|
///
|
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// std::stringstream ss;
|
|
|
|
/// ss << "a = 3"sv;
|
|
|
|
///
|
|
|
|
/// auto tbl = toml::parse(ss);
|
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2021-05-19 11:36:25 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
|
|
|
///
|
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2021-05-19 11:36:25 +00:00
|
|
|
///
|
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::istream & doc, std::string_view source_path = {});
|
2020-02-03 09:12:43 +00:00
|
|
|
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \brief Parses a TOML document from a stream.
|
2021-05-19 11:36:25 +00:00
|
|
|
///
|
|
|
|
/// \detail \cpp
|
2021-10-24 22:04:23 +00:00
|
|
|
/// std::stringstream ss;
|
|
|
|
/// ss << "a = 3"sv;
|
|
|
|
///
|
|
|
|
/// auto tbl = toml::parse(ss, "foo.toml");
|
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2021-05-19 11:36:25 +00:00
|
|
|
/// \ecpp
|
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-05-19 11:36:25 +00:00
|
|
|
///
|
2021-10-24 22:04:23 +00:00
|
|
|
/// \param doc The TOML document to parse. Must be valid UTF-8.
|
|
|
|
/// \param source_path The path used to initialize each node's `source().path`.
|
|
|
|
/// If you don't have a path (or you have no intention of using paths in diagnostics)
|
|
|
|
/// then this parameter can safely be left blank.
|
2021-05-19 11:36:25 +00:00
|
|
|
///
|
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-02-12 12:25:43 +00:00
|
|
|
TOML_EXPORTED_FREE_FUNCTION
|
2022-06-06 09:21:46 +00:00
|
|
|
parse_result TOML_CALLCONV parse(std::istream & doc, std::string && source_path);
|
2020-02-16 13:11:57 +00:00
|
|
|
|
2021-04-18 12:04:46 +00:00
|
|
|
TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS
|
2020-10-22 13:25:26 +00:00
|
|
|
|
2020-02-16 13:11:57 +00:00
|
|
|
inline namespace literals
|
|
|
|
{
|
2021-05-06 08:03:25 +00:00
|
|
|
TOML_ABI_NAMESPACE_BOOL(TOML_EXCEPTIONS, lit_ex, lit_noex);
|
2020-10-22 13:25:26 +00:00
|
|
|
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \brief Parses TOML data from a string literal.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// using namespace toml::literals;
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// auto tbl = "a = 3"_toml;
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \param str The string data. Must be valid UTF-8.
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \param len The string length.
|
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-06-06 09:21:46 +00:00
|
|
|
TOML_ALWAYS_INLINE
|
2022-06-06 20:46:04 +00:00
|
|
|
parse_result operator"" _toml(const char* str, size_t len)
|
2021-10-24 22:04:23 +00:00
|
|
|
{
|
|
|
|
return parse(std::string_view{ str, len });
|
|
|
|
}
|
2020-02-16 13:11:57 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#if TOML_HAS_CHAR8
|
2020-02-16 13:11:57 +00:00
|
|
|
|
2020-07-30 20:31:08 +00:00
|
|
|
/// \brief Parses TOML data from a UTF-8 string literal.
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \detail \cpp
|
|
|
|
/// using namespace toml::literals;
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-16 13:11:57 +00:00
|
|
|
/// auto tbl = u8"a = 3"_toml;
|
2020-08-11 13:34:03 +00:00
|
|
|
/// std::cout << tbl["a"] << "\n";
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \ecpp
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-02-18 21:29:59 +00:00
|
|
|
/// \out
|
|
|
|
/// 3
|
|
|
|
/// \eout
|
2021-10-23 09:22:41 +00:00
|
|
|
///
|
2020-07-13 18:18:04 +00:00
|
|
|
/// \param str The string data. Must be valid UTF-8.
|
2020-02-16 13:11:57 +00:00
|
|
|
/// \param len The string length.
|
|
|
|
///
|
2021-04-18 12:04:46 +00:00
|
|
|
/// \returns \conditional_return{With exceptions}
|
|
|
|
/// A toml::table.
|
|
|
|
/// \conditional_return{Without exceptions}
|
|
|
|
/// A toml::parse_result.
|
2021-10-23 09:22:41 +00:00
|
|
|
TOML_NODISCARD
|
2022-06-06 09:21:46 +00:00
|
|
|
TOML_ALWAYS_INLINE
|
2022-06-06 20:46:04 +00:00
|
|
|
parse_result operator"" _toml(const char8_t* str, size_t len)
|
2021-10-24 22:04:23 +00:00
|
|
|
{
|
|
|
|
return parse(std::u8string_view{ str, len });
|
|
|
|
}
|
2020-02-16 13:11:57 +00:00
|
|
|
|
2021-10-23 09:22:41 +00:00
|
|
|
#endif // TOML_HAS_CHAR8
|
2020-02-16 13:11:57 +00:00
|
|
|
|
2021-04-18 12:04:46 +00:00
|
|
|
TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS
|
2020-02-16 13:11:57 +00:00
|
|
|
}
|
2020-01-04 14:21:38 +00:00
|
|
|
}
|
2021-04-18 12:04:46 +00:00
|
|
|
TOML_NAMESPACE_END;
|
2021-10-24 10:21:32 +00:00
|
|
|
|
|
|
|
#include "header_end.h"
|
2021-10-30 12:56:14 +00:00
|
|
|
#endif // TOML_ENABLE_PARSER
|