NeBuild dev
Loading...
Searching...
No Matches
parser.hpp File Reference
#include "preprocessor.hpp"
#include "table.hpp"
#include "parse_result.hpp"
#include "header_start.hpp"
#include "header_end.hpp"

Go to the source code of this file.

Namespaces

namespace  literals
 

Functions

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::string_view doc, std::string_view source_path={})
 Parses a TOML document from a string view.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::string_view doc, std::string &&source_path)
 Parses a TOML document from a string view.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse_file (std::string_view file_path)
 Parses a TOML document from a file.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::string_view doc, std::wstring_view source_path)
 Parses a TOML document from a string view.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::istream &doc, std::wstring_view source_path)
 Parses a TOML document from a stream.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse_file (std::wstring_view file_path)
 Parses a TOML document from a file.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::istream &doc, std::string_view source_path={})
 Parses a TOML document from a stream.
 
TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse (std::istream &doc, std::string &&source_path)
 Parses a TOML document from a stream.
 
 literals::TOML_ABI_NAMESPACE_BOOL (TOML_EXCEPTIONS, lit_ex, lit_noex)
 
TOML_NODISCARD TOML_ALWAYS_INLINE parse_result literals::operator""_toml (const char *str, size_t len)
 Parses TOML data from a string literal.
 

Variables

 TOML_NAMESPACE_START
 
 TOML_ABI_NAMESPACE_END
 
 literals::TOML_ABI_NAMESPACE_END
 
 TOML_NAMESPACE_END
 

Function Documentation

◆ parse() [1/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::istream &  doc,
std::string &&  source_path 
)

Parses a TOML document from a stream.

\detail \cpp std::stringstream ss; ss << "a = 3"sv;

auto tbl = toml::parse(ss, "foo.toml"); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse() [2/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::istream &  doc,
std::string_view  source_path = {} 
)

Parses a TOML document from a stream.

\detail \cpp std::stringstream ss; ss << "a = 3"sv;

auto tbl = toml::parse(ss); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse() [3/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::istream &  doc,
std::wstring_view  source_path 
)

Parses a TOML document from a stream.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

\detail \cpp std::stringstream ss; ss << "a = 3"sv;

auto tbl = toml::parse(ss); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse() [4/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::string_view  doc,
std::string &&  source_path 
)

Parses a TOML document from a string view.

\detail \cpp auto tbl = toml::parse("a = 3"sv, "foo.toml"); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse() [5/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::string_view  doc,
std::string_view  source_path = {} 
)

Parses a TOML document from a string view.

\detail \cpp auto tbl = toml::parse("a = 3"sv); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse() [6/6]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse ( std::string_view  doc,
std::wstring_view  source_path 
)

Parses a TOML document from a string view.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

\detail \cpp auto tbl = toml::parse("a = 3"sv, L"foo.toml"); std::cout << tbl["a"] << "\n"; \ecpp

\out 3 \eout

Parameters
docThe TOML document to parse. Must be valid UTF-8.
source_pathThe 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.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse_file() [1/2]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse_file ( std::string_view  file_path)

Parses a TOML document from a file.

\detail \cpp toml::parse_result get_foo_toml() { return toml::parse_file("foo.toml"); } \ecpp

Parameters
file_pathThe TOML document to parse. Must be valid UTF-8.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

◆ parse_file() [2/2]

TOML_NODISCARD TOML_EXPORTED_FREE_FUNCTION parse_result TOML_CALLCONV parse_file ( std::wstring_view  file_path)

Parses a TOML document from a file.

\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.

\detail \cpp toml::parse_result get_foo_toml() { return toml::parse_file(L"foo.toml"); } \ecpp

Parameters
file_pathThe TOML document to parse. Must be valid UTF-8.
Returns
\conditional_return{With exceptions} A toml::table. \conditional_return{Without exceptions} A toml::parse_result.

Variable Documentation

◆ TOML_ABI_NAMESPACE_END

TOML_ABI_NAMESPACE_END

◆ TOML_NAMESPACE_END

TOML_NAMESPACE_END

◆ TOML_NAMESPACE_START

TOML_NAMESPACE_START
Initial value:
{
#define TOML_EXCEPTIONS
Sets whether the library uses exceptions to report parsing failures. \detail Defaults to 1 or 0 accor...
Definition preprocessor.hpp:1126
#define TOML_ABI_NAMESPACE_BOOL(cond, T, F)
Definition preprocessor.hpp:1323