mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
Merge pull request #295 from franzpoeschel/undef-source-location
Add a way to optionally suppress usage of std::source_location b96acf96ba
This commit is contained in:
110
docs/reference/color/index.html
Normal file
110
docs/reference/color/index.html
Normal file
@@ -0,0 +1,110 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
color.hpp
|
||||
#
|
||||
|
||||
In color.hpp, functions related to colorizing error messages are defined.
|
||||
Colors are specified using ANSI escape code.
|
||||
In terminals or other output destinations that do not support ANSI escape code, the output may become difficult to read.
|
||||
|
||||
Macros
|
||||
#
|
||||
|
||||
|
||||
TOML11_COLORIZE_ERROR_MESSAGE
|
||||
#
|
||||
|
||||
If this macro is defined during compilation (-DTOML11_COLORIZE_ERROR_MESASGE), error messages are colored by default.
|
||||
If not defined, colors are not applied by default. You need to specify them using toml::color::enable()."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/color/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="color.hpp"><meta property="og:description" content="color.hpp # In color.hpp, functions related to colorizing error messages are defined.
|
||||
Colors are specified using ANSI escape code. In terminals or other output destinations that do not support ANSI escape code, the output may become difficult to read.
|
||||
Macros # TOML11_COLORIZE_ERROR_MESSAGE # If this macro is defined during compilation (-DTOML11_COLORIZE_ERROR_MESASGE), error messages are colored by default.
|
||||
If not defined, colors are not applied by default. You need to specify them using toml::color::enable()."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>color.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/color/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/color/ title=color.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/color/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/ class=active>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>color.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#colorhpp>color.hpp</a><ul><li><a href=#macros>Macros</a><ul><li><a href=#toml11_colorize_error_message><code>TOML11_COLORIZE_ERROR_MESSAGE</code></a></li><li><a href=#toml11_use_thread_local_colorization><code>TOML11_USE_THREAD_LOCAL_COLORIZATION</code></a></li></ul></li><li><a href=#functions>Functions</a><ul><li><a href=#enable><code>enable()</code></a></li><li><a href=#disable><code>disable()</code></a></li><li><a href=#should_color><code>should_color()</code></a></li></ul></li><li><a href=#manipulators>Manipulators</a><ul><li></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=colorhpp>color.hpp
|
||||
<a class=anchor href=#colorhpp>#</a></h1><p>In <code>color.hpp</code>, functions related to colorizing error messages are defined.</p><p>Colors are specified using ANSI escape code.
|
||||
In terminals or other output destinations that do not support ANSI escape code, the output may become difficult to read.</p><h2 id=macros>Macros
|
||||
<a class=anchor href=#macros>#</a></h2><h3 id=toml11_colorize_error_message><code>TOML11_COLORIZE_ERROR_MESSAGE</code>
|
||||
<a class=anchor href=#toml11_colorize_error_message>#</a></h3><p>If this macro is defined during compilation (<code>-DTOML11_COLORIZE_ERROR_MESASGE</code>), error messages are colored by default.</p><p>If not defined, colors are not applied by default. You need to specify them using <code>toml::color::enable()</code>.</p><h3 id=toml11_use_thread_local_colorization><code>TOML11_USE_THREAD_LOCAL_COLORIZATION</code>
|
||||
<a class=anchor href=#toml11_use_thread_local_colorization>#</a></h3><p>If this macro is defined during compilation (<code>-DTOML11_USE_THREAD_LOCAL_COLORIZATION</code>), the colorization flag becomes <code>thread_local</code>.
|
||||
In this case, <code>toml::color::enable()</code> or <code>toml::color::disable()</code> will only affect the colorization flag in the thread that called it.
|
||||
This means that if you want to use a different setting from the default, you will need to set it again when starting a new thread.
|
||||
This makes <code>toml::color::enable()</code> and <code>toml::color::disable()</code> thread safe.</p><p>By default, the setting is global.
|
||||
When it is global, if one thread executes <code>toml::color::enable()</code>, the error messages will be colored in all threads.
|
||||
However, if one thread executes <code>enable()</code> or <code>disable()</code> while another executes <code>enable()</code>, <code>disable()</code> or <code>should_color()</code>, the result is undefined.</p><h2 id=functions>Functions
|
||||
<a class=anchor href=#functions>#</a></h2><h3 id=enable><code>enable()</code>
|
||||
<a class=anchor href=#enable>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> color {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>enable</span>();
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// color
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><p>Enables colorization using ANSI escape code.</p><h4 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> toml<span style=color:#f92672>::</span>color<span style=color:#f92672>::</span>enable(); <span style=color:#75715e>// All subsequent errors will be colored.
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> input <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>parse(<span style=color:#e6db74>"input.toml"</span>);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h3 id=disable><code>disable()</code>
|
||||
<a class=anchor href=#disable>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> color {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>disable</span>();
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// color
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><p>Disables colorization using ANSI escape code.</p><h4 id=example-1>Example
|
||||
<a class=anchor href=#example-1>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> toml<span style=color:#f92672>::</span>color<span style=color:#f92672>::</span>disable(); <span style=color:#75715e>// All subsequent errors will not be colored.
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> input <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>parse(<span style=color:#e6db74>"input.toml"</span>);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h3 id=should_color><code>should_color()</code>
|
||||
<a class=anchor href=#should_color>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> color {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>should_color</span>();
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// color
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><p>Returns <code>true</code> if colorization is enabled, <code>false</code> otherwise.</p><h4 id=example-2>Example
|
||||
<a class=anchor href=#example-2>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><iomanip></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><iostream></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>cout <span style=color:#f92672><<</span> <span style=color:#e6db74>"colorized? : "</span> <span style=color:#f92672><<</span> std<span style=color:#f92672>::</span>boolalpha <span style=color:#f92672><<</span> toml<span style=color:#f92672>::</span>color<span style=color:#f92672>::</span>should_color() <span style=color:#f92672><<</span> std<span style=color:#f92672>::</span>endl;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=manipulators>Manipulators
|
||||
<a class=anchor href=#manipulators>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml {
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> color {
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> reset (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> bold (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> grey (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> gray (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> red (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> green (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> yellow (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> blue (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> magenta(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> cyan (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> white (std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// color
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><p>Colorizes the foreground with ANSI escape code.</p><h4 id=example-3>Example
|
||||
<a class=anchor href=#example-3>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><iostream></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>cout <span style=color:#f92672><<</span> toml<span style=color:#f92672>::</span>color<span style=color:#f92672>::</span>red <span style=color:#f92672><<</span> <span style=color:#e6db74>"red!"</span> <span style=color:#f92672><<</span> toml<span style=color:#f92672>::</span>color<span style=color:#f92672>::</span>reset <span style=color:#f92672><<</span> std<span style=color:#f92672>::</span>endl;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/error_info/>error_info.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#colorhpp>color.hpp</a><ul><li><a href=#macros>Macros</a><ul><li><a href=#toml11_colorize_error_message><code>TOML11_COLORIZE_ERROR_MESSAGE</code></a></li><li><a href=#toml11_use_thread_local_colorization><code>TOML11_USE_THREAD_LOCAL_COLORIZATION</code></a></li></ul></li><li><a href=#functions>Functions</a><ul><li><a href=#enable><code>enable()</code></a></li><li><a href=#disable><code>disable()</code></a></li><li><a href=#should_color><code>should_color()</code></a></li></ul></li><li><a href=#manipulators>Manipulators</a><ul><li></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
319
docs/reference/comments/index.html
Normal file
319
docs/reference/comments/index.html
Normal file
File diff suppressed because one or more lines are too long
52
docs/reference/conversion/index.html
Normal file
52
docs/reference/conversion/index.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
conversion.hpp
|
||||
#
|
||||
|
||||
Provides macros to automatically define conversion functions for supporting user-defined types with toml::get and toml::find.
|
||||
TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(NAME, ...)
|
||||
|
||||
Example
|
||||
#
|
||||
|
||||
namespace foo
|
||||
{
|
||||
struct Foo
|
||||
{
|
||||
std::string s;
|
||||
double d;
|
||||
int i;
|
||||
};
|
||||
} // foo
|
||||
|
||||
TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(foo::Foo, s, d, i)
|
||||
|
||||
Related
|
||||
#
|
||||
|
||||
|
||||
from.hpp
|
||||
into.hpp
|
||||
"><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/conversion/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="conversion.hpp"><meta property="og:description" content="conversion.hpp # Provides macros to automatically define conversion functions for supporting user-defined types with toml::get and toml::find.
|
||||
TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(NAME, ...) Example # namespace foo { struct Foo { std::string s; double d; int i; }; } // foo TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(foo::Foo, s, d, i) Related # from.hpp into.hpp"><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>conversion.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/conversion/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/conversion/ title=conversion.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/conversion/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/ class=active>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>conversion.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#conversionhpp>conversion.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=conversionhpp>conversion.hpp
|
||||
<a class=anchor href=#conversionhpp>#</a></h1><p>Provides macros to automatically define conversion functions for supporting user-defined types with <code>toml::get</code> and <code>toml::find</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(NAME, ...)
|
||||
</span></span></code></pre></div><h2 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> foo
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>Foo</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string s;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>double</span> d;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>int</span> i;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// foo
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span>TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(foo<span style=color:#f92672>::</span>Foo, s, d, i)
|
||||
</span></span></code></pre></div><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/from/>from.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/into/>into.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#conversionhpp>conversion.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
396
docs/reference/datetime/index.html
Normal file
396
docs/reference/datetime/index.html
Normal file
File diff suppressed because one or more lines are too long
120
docs/reference/error_info/index.html
Normal file
120
docs/reference/error_info/index.html
Normal file
@@ -0,0 +1,120 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content='
|
||||
error_info.hpp
|
||||
#
|
||||
|
||||
In error_info.hpp, definitions for error_info and functions to format it are provided.
|
||||
|
||||
toml::error_info
|
||||
#
|
||||
|
||||
namespace toml
|
||||
{
|
||||
struct error_info
|
||||
{
|
||||
error_info(std::string t, source_location l, std::string m, std::string s = "");
|
||||
error_info(std::string t, std::vector<std::pair<source_location, std::string>> l, std::string s = "");
|
||||
|
||||
std::string const& title() const noexcept;
|
||||
std::string & title() noexcept;
|
||||
|
||||
std::vector<std::pair<source_location, std::string>> const& locations() const noexcept;
|
||||
void add_locations(source_location loc, std::string msg) noexcept;
|
||||
|
||||
std::string const& suffix() const noexcept;
|
||||
std::string & suffix() noexcept;
|
||||
};
|
||||
|
||||
template<typename ... Ts>
|
||||
error_info make_error_info(
|
||||
std::string title, source_location loc, std::string msg, Ts&& ... tail);
|
||||
|
||||
std::string format_error(const std::string& errkind, const error_info& err);
|
||||
std::string format_error(const error_info& err);
|
||||
|
||||
template<typename ... Ts>
|
||||
std::string format_error(std::string title,
|
||||
source_location loc, std::string msg, Ts&& ... tail);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const error_info& e);
|
||||
}
|
||||
|
||||
Member Functions
|
||||
#
|
||||
|
||||
|
||||
Constructor (title, loc, msg, suffix)
|
||||
#
|
||||
|
||||
Constructs error_info with specified title, location information loc, message msg, and optional suffix.'><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/error_info/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="error_info.hpp"><meta property="og:description" content='error_info.hpp # In error_info.hpp, definitions for error_info and functions to format it are provided.
|
||||
toml::error_info # namespace toml { struct error_info { error_info(std::string t, source_location l, std::string m, std::string s = ""); error_info(std::string t, std::vector<std::pair<source_location, std::string>> l, std::string s = ""); std::string const& title() const noexcept; std::string & title() noexcept; std::vector<std::pair<source_location, std::string>> const& locations() const noexcept; void add_locations(source_location loc, std::string msg) noexcept; std::string const& suffix() const noexcept; std::string & suffix() noexcept; }; template<typename ... Ts> error_info make_error_info( std::string title, source_location loc, std::string msg, Ts&& ... tail); std::string format_error(const std::string& errkind, const error_info& err); std::string format_error(const error_info& err); template<typename ... Ts> std::string format_error(std::string title, source_location loc, std::string msg, Ts&& ... tail); std::ostream& operator<<(std::ostream& os, const error_info& e); } Member Functions # Constructor (title, loc, msg, suffix) # Constructs error_info with specified title, location information loc, message msg, and optional suffix.'><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>error_info.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/error_info/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/error_info/ title=error_info.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/error_info/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/ class=active>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>error_info.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#error_infohpp>error_info.hpp</a></li><li><a href=#tomlerror_info><code>toml::error_info</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor-title-loc-msg-suffix>Constructor (<code>title, loc, msg, suffix</code>)</a></li><li><a href=#constructor-title-loc-msg--suffix>Constructor (<code>title, [{loc, msg}, ...], suffix</code>)</a></li><li><a href=#stdstring-title><code>std::string title()</code></a></li><li><a href=#stdvectorstdpairsource_location-stdstring-locations><code>std::vector<std::pair<source_location, std::string>> locations()</code></a></li><li><a href=#stdstring-suffix><code>std::string suffix()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#make_error_info><code>make_error_info</code></a></li><li><a href=#format_error><code>format_error</code></a></li><li><a href=#stream-operator>Stream Operator</a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=error_infohpp>error_info.hpp
|
||||
<a class=anchor href=#error_infohpp>#</a></h1><p>In <code>error_info.hpp</code>, definitions for <code>error_info</code> and functions to format it are provided.</p><h1 id=tomlerror_info><code>toml::error_info</code>
|
||||
<a class=anchor href=#tomlerror_info>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>error_info</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> error_info(std<span style=color:#f92672>::</span>string t, source_location l, std<span style=color:#f92672>::</span>string m, std<span style=color:#f92672>::</span>string s <span style=color:#f92672>=</span> <span style=color:#e6db74>""</span>);
|
||||
</span></span><span style=display:flex><span> error_info(std<span style=color:#f92672>::</span>string t, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>pair<span style=color:#f92672><</span>source_location, std<span style=color:#f92672>::</span>string<span style=color:#f92672>>></span> l, std<span style=color:#f92672>::</span>string s <span style=color:#f92672>=</span> <span style=color:#e6db74>""</span>);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> title() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#f92672>&</span> title() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>pair<span style=color:#f92672><</span>source_location, std<span style=color:#f92672>::</span>string<span style=color:#f92672>>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> locations() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>void</span> <span style=color:#a6e22e>add_locations</span>(source_location loc, std<span style=color:#f92672>::</span>string msg) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> suffix() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#f92672>&</span> suffix() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>error_info make_error_info(
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string title, source_location loc, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> errkind, <span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> err);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(<span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> err);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(std<span style=color:#f92672>::</span>string title,
|
||||
</span></span><span style=display:flex><span> source_location loc, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, <span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> e);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=constructor-title-loc-msg-suffix>Constructor (<code>title, loc, msg, suffix</code>)
|
||||
<a class=anchor href=#constructor-title-loc-msg-suffix>#</a></h3><p>Constructs <code>error_info</code> with specified <code>title</code>, location information <code>loc</code>, message <code>msg</code>, and optional <code>suffix</code>.</p><p><code>suffix</code> defaults to empty.</p><h3 id=constructor-title-loc-msg--suffix>Constructor (<code>title, [{loc, msg}, ...], suffix</code>)
|
||||
<a class=anchor href=#constructor-title-loc-msg--suffix>#</a></h3><p>Constructs <code>error_info</code> with specified <code>title</code>, an array of location-message pairs <code>[{loc, msg}, ...]</code>, and optional <code>suffix</code>.</p><p><code>suffix</code> defaults to empty.</p><h3 id=stdstring-title><code>std::string title()</code>
|
||||
<a class=anchor href=#stdstring-title>#</a></h3><p>Returns the title of the error message.</p><h3 id=stdvectorstdpairsource_location-stdstring-locations><code>std::vector<std::pair<source_location, std::string>> locations()</code>
|
||||
<a class=anchor href=#stdvectorstdpairsource_location-stdstring-locations>#</a></h3><p>Returns the list of locations where errors occurred along with their respective messages.</p><p>Multiple locations can be specified.</p><h3 id=stdstring-suffix><code>std::string suffix()</code>
|
||||
<a class=anchor href=#stdstring-suffix>#</a></h3><p>Returns the suffix message to display at the end, providing hints or additional information.</p><h2 id=non-member-functions>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=make_error_info><code>make_error_info</code>
|
||||
<a class=anchor href=#make_error_info>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>error_info make_error_info(
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string title, source_location loc, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span></code></pre></div><p>Creates a new <code>error_info</code>.</p><p>Must be followed by a <code>msg</code> related to <code>source_location</code> or <code>basic_value</code>.</p><p>Overloads are added in <a href=https://toruniina.github.io/toml11/docs/reference/value/#tomlmake_error_info><code>value.hpp</code></a> when passing <code>toml::basic_value</code> instead of <code>source_location</code>.</p><p>Possible to pass <code>suffix</code> at the end.</p><h3 id=format_error><code>format_error</code>
|
||||
<a class=anchor href=#format_error>#</a></h3><p>Formats <code>error_info</code> as follows:</p><pre tabindex=0><code>{title}
|
||||
--> {locations().at(0).first.file_name()}
|
||||
|
|
||||
1 | {locations().at(0).first.line()}
|
||||
| ^-- {locations().at(0).second}
|
||||
|
|
||||
2 | {locations().at(1).first.line()}
|
||||
| ^-- {locations().at(1).second}
|
||||
{suffix}
|
||||
</code></pre><p>If file names differ between two <code>source_location</code>, the file name is displayed again.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> errkind, <span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> err);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(<span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> err);
|
||||
</span></span></code></pre></div><p>Formats <code>error_info</code>.</p><p>If <code>errkind</code> is not provided, a red-bold <code>[error]</code> prefix is added before <code>title</code>.</p><p>If <code>errkind</code> is provided (including an empty string), it replaces <code>[error]</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(std<span style=color:#f92672>::</span>string title,
|
||||
</span></span><span style=display:flex><span> source_location loc, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><p>Returns a formatted string using <code>format_error</code> for <code>error_info</code> created with <code>make_error_info</code>.</p><p>Overloads are added in <a href=https://toruniina.github.io/toml11/docs/reference/value/#tomlformat_error><code>value.hpp</code></a> when passing <code>toml::basic_value</code> instead of <code>source_location</code>.</p><h3 id=stream-operator>Stream Operator
|
||||
<a class=anchor href=#stream-operator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, <span style=color:#66d9ef>const</span> error_info<span style=color:#f92672>&</span> e);
|
||||
</span></span></code></pre></div><p>Calls <code>format_error(e)</code> and outputs it.</p><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/color/>color.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/source_location/>source_location.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#error_infohpp>error_info.hpp</a></li><li><a href=#tomlerror_info><code>toml::error_info</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor-title-loc-msg-suffix>Constructor (<code>title, loc, msg, suffix</code>)</a></li><li><a href=#constructor-title-loc-msg--suffix>Constructor (<code>title, [{loc, msg}, ...], suffix</code>)</a></li><li><a href=#stdstring-title><code>std::string title()</code></a></li><li><a href=#stdvectorstdpairsource_location-stdstring-locations><code>std::vector<std::pair<source_location, std::string>> locations()</code></a></li><li><a href=#stdstring-suffix><code>std::string suffix()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#make_error_info><code>make_error_info</code></a></li><li><a href=#format_error><code>format_error</code></a></li><li><a href=#stream-operator>Stream Operator</a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
59
docs/reference/exception/index.html
Normal file
59
docs/reference/exception/index.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content='
|
||||
exception.hpp
|
||||
#
|
||||
|
||||
|
||||
toml::exception
|
||||
#
|
||||
|
||||
Base class for exception types defined in toml11.
|
||||
namespace toml
|
||||
{
|
||||
struct exception : public std::exception
|
||||
{
|
||||
public:
|
||||
virtual ~exception() noexcept override = default;
|
||||
virtual const char* what() const noexcept override {return "";}
|
||||
};
|
||||
} // toml
|
||||
|
||||
Member Functions
|
||||
#
|
||||
|
||||
|
||||
Destructor
|
||||
#
|
||||
|
||||
virtual ~exception() noexcept override = default;
|
||||
Override when derived.
|
||||
|
||||
what
|
||||
#
|
||||
|
||||
virtual const char* what() const noexcept override {return "";}
|
||||
Returns the error message. Override when derived.'><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/exception/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="exception.hpp"><meta property="og:description" content='exception.hpp # toml::exception # Base class for exception types defined in toml11.
|
||||
namespace toml { struct exception : public std::exception { public: virtual ~exception() noexcept override = default; virtual const char* what() const noexcept override {return "";} }; } // toml Member Functions # Destructor # virtual ~exception() noexcept override = default; Override when derived.
|
||||
what # virtual const char* what() const noexcept override {return "";} Returns the error message. Override when derived.'><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>exception.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/exception/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/exception/ title=exception.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/exception/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/ class=active>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>exception.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#exceptionhpp>exception.hpp</a></li><li><a href=#tomlexception><code>toml::exception</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#destructor>Destructor</a></li><li><a href=#what><code>what</code></a></li></ul></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=exceptionhpp>exception.hpp
|
||||
<a class=anchor href=#exceptionhpp>#</a></h1><h1 id=tomlexception><code>toml::exception</code>
|
||||
<a class=anchor href=#tomlexception>#</a></h1><p>Base class for exception types defined in toml11.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>exception</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> std<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>virtual</span> <span style=color:#f92672>~</span>exception() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>virtual</span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>""</span>;}
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=destructor>Destructor
|
||||
<a class=anchor href=#destructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>virtual</span> <span style=color:#f92672>~</span>exception() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span></code></pre></div><p>Override when derived.</p><h3 id=what><code>what</code>
|
||||
<a class=anchor href=#what>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>virtual</span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>""</span>;}
|
||||
</span></span></code></pre></div><p>Returns the error message. Override when derived.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#exceptionhpp>exception.hpp</a></li><li><a href=#tomlexception><code>toml::exception</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#destructor>Destructor</a></li><li><a href=#what><code>what</code></a></li></ul></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
132
docs/reference/find/index.html
Normal file
132
docs/reference/find/index.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
find.hpp
|
||||
#
|
||||
|
||||
This function searches for a value in a toml::value and performs type conversion if necessary.
|
||||
|
||||
toml::value can change the type it stores, and toml::find accommodates these types.
|
||||
Technically, all functions use toml::basic_value<TC>.
|
||||
However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly.
|
||||
|
||||
|
||||
|
||||
toml::find
|
||||
#
|
||||
|
||||
|
||||
Overview
|
||||
#
|
||||
|
||||
toml::find uses template arguments for the type you want to retrieve and function arguments for the key of the value you want to find."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/find/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="find.hpp"><meta property="og:description" content="find.hpp # This function searches for a value in a toml::value and performs type conversion if necessary.
|
||||
toml::value can change the type it stores, and toml::find accommodates these types. Technically, all functions use toml::basic_value<TC>. However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary. In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly. toml::find # Overview # toml::find uses template arguments for the type you want to retrieve and function arguments for the key of the value you want to find."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>find.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/find/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/find/ title=find.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/find/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/ class=active>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>find.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#findhpp>find.hpp</a></li><li><a href=#tomlfind><code>toml::find</code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#note-on-recursive-search>Note on Recursive Search</a></li></ul></li><li><a href=#tomlfindvalue-key><code>toml::find(value, key)</code></a><ul><li><a href=#exceptions>Exceptions</a></li></ul></li><li><a href=#tomlfindvalue-index><code>toml::find(value, index)</code></a><ul><li><a href=#exceptions-1>Exceptions</a></li></ul></li><li><a href=#tomlfindvalue-keys><code>toml::find(value, keys...)</code></a></li></ul></li><li><a href=#tomlfind_orvalue-key-fallback><code>toml::find_or(value, key, fallback)</code></a><ul><li><a href=#when-t-is-basic_value>When <code>T</code> is <code>basic_value</code></a></li><li><a href=#when-t-is-tomlvaluesome_type>When <code>T</code> is <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-any-other-type>When <code>T</code> is any other type</a></li><li><a href=#when-multiple-keys-are-provided>When multiple keys are provided</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=findhpp>find.hpp
|
||||
<a class=anchor href=#findhpp>#</a></h1><p>This function searches for a value in a <code>toml::value</code> and performs type conversion if necessary.</p><blockquote class="book-hint info"><code>toml::value</code> can change the type it stores, and <code>toml::find</code> accommodates these types.
|
||||
Technically, all functions use <code>toml::basic_value<TC></code>.
|
||||
However, for simplicity, we refer to it as <code>toml::value</code> in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter <code>TC</code> changes the type, assume that types like <code>toml::value::integer_type</code> will also change accordingly.</blockquote><h1 id=tomlfind><code>toml::find</code>
|
||||
<a class=anchor href=#tomlfind>#</a></h1><h2 id=overview>Overview
|
||||
<a class=anchor href=#overview>#</a></h2><p><code>toml::find</code> uses template arguments for the type you want to retrieve and function arguments for the key of the value you want to find.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> ... Keys<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T find(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, Keys ... keys);
|
||||
</span></span></code></pre></div><p>The supported types for <code>T</code> and the behavior of the conversion are the same as for <code>toml::get</code>.</p><p>If <code>T</code> is not specified, a <code>toml::value</code> will be returned.</p><p>Keys can be of type <code>toml::value::key_type</code> or <code>std::size_t</code>.
|
||||
When multiple keys are provided, the function will search recursively through sub-tables or arrays.
|
||||
If a <code>toml::value::key_type</code> is given, <code>toml::value</code> is interpreted as a <code>toml::table</code>; if a <code>std::size_t</code> is given, <code>toml::value</code> is interpreted as a <code>toml::array</code>.</p><h3 id=note-on-recursive-search>Note on Recursive Search
|
||||
<a class=anchor href=#note-on-recursive-search>#</a></h3><p>TOML allows for bare keys as well as quoted keys (enclosed in <code>"</code> or <code>'</code>). Using a quoted key like <code>"foo.bar" = "baz"</code> means no sub-table is constructed, and the key is <code>"foo.bar"</code>. To handle such patterns, toml11 does not split keys containing <code>.</code> and searches using the full string.</p><p>Consider the following TOML file:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-toml data-lang=toml><span style=display:flex><span>[<span style=color:#a6e22e>foo</span>]
|
||||
</span></span><span style=display:flex><span>[<span style=color:#a6e22e>foo</span>.<span style=color:#a6e22e>bar</span>]
|
||||
</span></span><span style=display:flex><span><span style=color:#a6e22e>baz</span> = <span style=color:#e6db74>"hoge"</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>[<span style=color:#e6db74>"foo.bar"</span>]
|
||||
</span></span><span style=display:flex><span><span style=color:#a6e22e>baz</span> = <span style=color:#e6db74>"fuga"</span>
|
||||
</span></span></code></pre></div><p>The corresponding usage of <code>toml::find</code> is shown below:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> input <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>parse(<span style=color:#e6db74>"input.toml"</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> baz1 <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>find<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span>(input, <span style=color:#e6db74>"foo"</span>, <span style=color:#e6db74>"bar"</span>, <span style=color:#e6db74>"baz"</span>); <span style=color:#75715e>// hoge
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> baz2 <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>find<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span>(input, <span style=color:#e6db74>"foo.bar"</span>, <span style=color:#e6db74>"baz"</span>); <span style=color:#75715e>// fuga
|
||||
</span></span></span></code></pre></div><p>cf. <a href=https://toml.io/en/v1.0.0#keys>toml.io/en/v1.0.0#keys</a></p><h2 id=tomlfindvalue-key><code>toml::find(value, key)</code>
|
||||
<a class=anchor href=#tomlfindvalue-key>#</a></h2><p>Searches for <code>key</code> in <code>value</code> as if <code>value</code> were a <code>toml::table</code>, then converts using <code>toml::get</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(const value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span></code></pre></div><p>If <code>T</code> is not specified, the function returns a <code>toml::value</code> without conversion.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> ky);
|
||||
</span></span></code></pre></div><h3 id=exceptions>Exceptions
|
||||
<a class=anchor href=#exceptions>#</a></h3><p>If the <code>toml::value</code> does not contain a <code>table</code>, a <code>toml::type_error</code> is thrown.</p><p>If the contained <code>table</code> does not have the specified element, a <code>std::out_of_range</code> is thrown.</p><p>If the specified element cannot be converted to <code>T</code> (i.e., <code>toml::get</code> fails), a <code>toml::type_error</code> is thrown.</p><h2 id=tomlfindvalue-index><code>toml::find(value, index)</code>
|
||||
<a class=anchor href=#tomlfindvalue-index>#</a></h2><p>Accesses the <code>index</code>-th element of <code>value</code> as if <code>value</code> were a <code>toml::array</code>, then converts using <code>toml::get</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(const value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t index);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t index);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t index);
|
||||
</span></span></code></pre></div><p>If <code>T</code> is not specified, the function returns a <code>toml::value</code> without conversion.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> find(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> find(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t ky);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> find(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t ky);
|
||||
</span></span></code></pre></div><h3 id=exceptions-1>Exceptions
|
||||
<a class=anchor href=#exceptions-1>#</a></h3><p>If the <code>toml::value</code> does not contain an <code>array</code>, a <code>toml::type_error</code> is thrown.</p><p>If the contained <code>array</code> does not have the specified number of elements, a <code>std::out_of_range</code> is thrown.</p><p>If the specified element cannot be converted to <code>T</code> (i.e., <code>toml::get</code> fails), a <code>toml::type_error</code> is thrown.</p><h2 id=tomlfindvalue-keys><code>toml::find(value, keys...)</code>
|
||||
<a class=anchor href=#tomlfindvalue-keys>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K1, <span style=color:#66d9ef>typename</span> K2, <span style=color:#66d9ef>typename</span> ... Ks<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(const value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K1<span style=color:#f92672>&</span> k1, <span style=color:#66d9ef>const</span> K2<span style=color:#f92672>&</span> k2, <span style=color:#66d9ef>const</span> Ks<span style=color:#f92672>&</span> ... ks);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K1, <span style=color:#66d9ef>typename</span> K2, <span style=color:#66d9ef>typename</span> ... Ks<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K1<span style=color:#f92672>&</span> k1, <span style=color:#66d9ef>const</span> K2<span style=color:#f92672>&</span> k2, <span style=color:#66d9ef>const</span> Ks<span style=color:#f92672>&</span> ... ks);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K1, <span style=color:#66d9ef>typename</span> K2, <span style=color:#66d9ef>typename</span> ... Ks<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Equivalent to toml::get<T>(value&&) */</span> find(
|
||||
</span></span><span style=display:flex><span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, <span style=color:#66d9ef>const</span> K1<span style=color:#f92672>&</span> k1, <span style=color:#66d9ef>const</span> K2<span style=color:#f92672>&</span> k2, <span style=color:#66d9ef>const</span> Ks<span style=color:#f92672>&</span> ... ks);
|
||||
</span></span></code></pre></div><p>This function calls <code>toml::find</code> recursively.</p><p>The failure conditions and the exceptions thrown are the same as those for <code>toml::find</code>.</p><h1 id=tomlfind_orvalue-key-fallback><code>toml::find_or(value, key, fallback)</code>
|
||||
<a class=anchor href=#tomlfind_orvalue-key-fallback>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> Key<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T find_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> Key<span style=color:#f92672>&</span> key, T<span style=color:#f92672>&&</span> opt);
|
||||
</span></span></code></pre></div><p>The <code>find_or</code> function takes a default value to avoid throwing an exception when the search fails.</p><p>The default value must be of the same type as the return type <code>T</code>. Therefore, unlike <code>toml::find<T></code>, <code>find_or</code> infers the type <code>T</code>.</p><p>You can specify <code>T</code> explicitly with <code>find_or<T></code>, but this always returns a new value. To obtain a reference, do not specify <code>T</code>.</p><h2 id=when-t-is-basic_value>When <code>T</code> is <code>basic_value</code>
|
||||
<a class=anchor href=#when-t-is-basic_value>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> find_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> find_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><p>Searches for the corresponding value and returns it without conversion. Because no conversion is needed, a reference can be returned.</p><p>If the value is not found, the default value is returned.</p><h2 id=when-t-is-tomlvaluesome_type>When <code>T</code> is <code>toml::value::{some_type}</code>
|
||||
<a class=anchor href=#when-t-is-tomlvaluesome_type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T<span style=color:#f92672>&</span> find_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, T<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> find_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, <span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><p>Searches for the corresponding value and returns it without conversion. Because no conversion is needed, a reference can be returned.</p><p>If the value is not found or if a different type is stored, the default value is returned.</p><h2 id=when-t-is-const-char>When <code>T</code> is <code>const char*</code>
|
||||
<a class=anchor href=#when-t-is-const-char>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T find_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, T opt)
|
||||
</span></span></code></pre></div><p>Searches for the corresponding value and returns it as a <code>std::string</code>.</p><p>Since the fallback is constructed from <code>const char*</code> to <code>std::string</code>, a reference cannot be returned in case of failure.</p><h2 id=when-t-is-any-other-type>When <code>T</code> is any other type
|
||||
<a class=anchor href=#when-t-is-any-other-type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> K<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T find_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> K<span style=color:#f92672>&</span> key, T opt);
|
||||
</span></span></code></pre></div><p>Searches for the corresponding value and converts it to <code>T</code> before returning it.</p><p>Because conversion is performed, a reference cannot be returned.</p><h2 id=when-multiple-keys-are-provided>When multiple keys are provided
|
||||
<a class=anchor href=#when-multiple-keys-are-provided>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Value, <span style=color:#66d9ef>typename</span> K1, <span style=color:#66d9ef>typename</span> K2, <span style=color:#66d9ef>typename</span> K3, <span style=color:#66d9ef>typename</span> ... Ks<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>auto</span> find_or(Value<span style=color:#f92672>&&</span> v, <span style=color:#66d9ef>const</span> K1<span style=color:#f92672>&</span> k1, <span style=color:#66d9ef>const</span> K2<span style=color:#f92672>&</span> k2, K3<span style=color:#f92672>&&</span> k3, Ks<span style=color:#f92672>&&</span> ... keys) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>-></span> <span style=color:#66d9ef>decltype</span>(find_or(v, k2, std<span style=color:#f92672>::</span>forward<span style=color:#f92672><</span>K3<span style=color:#f92672>></span>(k3), std<span style=color:#f92672>::</span>forward<span style=color:#f92672><</span>Ks<span style=color:#f92672>></span>(keys)...))
|
||||
</span></span></code></pre></div><p>Interprets the last element in the key sequence as the default value and applies <code>find_or</code> recursively.</p><p>If the inferred type of <code>T</code> is <code>toml::value</code> or <code>toml::value::some_type</code>, a reference can be returned.</p><p>If <code>T</code> is explicitly specified, conversion is always performed.</p><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/get/>get.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#findhpp>find.hpp</a></li><li><a href=#tomlfind><code>toml::find</code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#note-on-recursive-search>Note on Recursive Search</a></li></ul></li><li><a href=#tomlfindvalue-key><code>toml::find(value, key)</code></a><ul><li><a href=#exceptions>Exceptions</a></li></ul></li><li><a href=#tomlfindvalue-index><code>toml::find(value, index)</code></a><ul><li><a href=#exceptions-1>Exceptions</a></li></ul></li><li><a href=#tomlfindvalue-keys><code>toml::find(value, keys...)</code></a></li></ul></li><li><a href=#tomlfind_orvalue-key-fallback><code>toml::find_or(value, key, fallback)</code></a><ul><li><a href=#when-t-is-basic_value>When <code>T</code> is <code>basic_value</code></a></li><li><a href=#when-t-is-tomlvaluesome_type>When <code>T</code> is <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-any-other-type>When <code>T</code> is any other type</a></li><li><a href=#when-multiple-keys-are-provided>When multiple keys are provided</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
431
docs/reference/format/index.html
Normal file
431
docs/reference/format/index.html
Normal file
File diff suppressed because one or more lines are too long
92
docs/reference/from/index.html
Normal file
92
docs/reference/from/index.html
Normal file
@@ -0,0 +1,92 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content='
|
||||
from.hpp
|
||||
#
|
||||
|
||||
Defines a struct used for conversion from toml::value in toml::get and toml::find.
|
||||
You can achieve the same functionality by adding a from_toml member function, but for classes where you cannot add member functions, use from<T>.
|
||||
This file does not provide specific implementations. Please specialize this struct when using.
|
||||
namespace toml
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct from;
|
||||
|
||||
} // toml
|
||||
|
||||
Example
|
||||
#
|
||||
|
||||
namespace extlib
|
||||
{
|
||||
struct foo
|
||||
{
|
||||
int a;
|
||||
std::string b;
|
||||
};
|
||||
} // extlib
|
||||
|
||||
#include <toml11/from.hpp>
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template<>
|
||||
struct from<extlib::foo>
|
||||
{
|
||||
template<typename TC>
|
||||
static extlib::foo from_toml(const toml::basic_value<TC>& v)
|
||||
{
|
||||
return extlib::foo{toml::find<int>(v, "a"), toml::find<std::string>(v, "b")};
|
||||
}
|
||||
};
|
||||
} // toml
|
||||
|
||||
Related
|
||||
#
|
||||
|
||||
|
||||
conversion.hpp
|
||||
into.hpp
|
||||
'><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/from/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="from.hpp"><meta property="og:description" content='from.hpp # Defines a struct used for conversion from toml::value in toml::get and toml::find.
|
||||
You can achieve the same functionality by adding a from_toml member function, but for classes where you cannot add member functions, use from<T>.
|
||||
This file does not provide specific implementations. Please specialize this struct when using.
|
||||
namespace toml { template<typename T> struct from; } // toml Example # namespace extlib { struct foo { int a; std::string b; }; } // extlib #include <toml11/from.hpp> namespace toml { template<> struct from<extlib::foo> { template<typename TC> static extlib::foo from_toml(const toml::basic_value<TC>& v) { return extlib::foo{toml::find<int>(v, "a"), toml::find<std::string>(v, "b")}; } }; } // toml Related # conversion.hpp into.hpp'><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>from.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/from/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/from/ title=from.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/from/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/ class=active>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>from.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#fromhpp>from.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=fromhpp>from.hpp
|
||||
<a class=anchor href=#fromhpp>#</a></h1><p>Defines a <code>struct</code> used for conversion from <code>toml::value</code> in <code>toml::get</code> and <code>toml::find</code>.</p><p>You can achieve the same functionality by adding a <code>from_toml</code> member function, but for classes where you cannot add member functions, use <code>from<T></code>.</p><p>This file does not provide specific implementations. Please specialize this <code>struct</code> when using.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>from</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> extlib
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>foo</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>int</span> a;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string b;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// extlib
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml11/from.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>from</span><span style=color:#f92672><</span>extlib<span style=color:#f92672>::</span>foo<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> extlib<span style=color:#f92672>::</span>foo from_toml(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v)
|
||||
</span></span><span style=display:flex><span> {
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> extlib<span style=color:#f92672>::</span>foo{toml<span style=color:#f92672>::</span>find<span style=color:#f92672><</span><span style=color:#66d9ef>int</span><span style=color:#f92672>></span>(v, <span style=color:#e6db74>"a"</span>), toml<span style=color:#f92672>::</span>find<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span>(v, <span style=color:#e6db74>"b"</span>)};
|
||||
</span></span><span style=display:flex><span> }
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/into/>into.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#fromhpp>from.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
141
docs/reference/get/index.html
Normal file
141
docs/reference/get/index.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
get.hpp
|
||||
#
|
||||
|
||||
These are functions for extracting values from toml::value and performing type conversions if necessary.
|
||||
|
||||
toml::value can change the type it stores, and toml::get accommodates these types.
|
||||
Technically, all functions use toml::basic_value<TC>.
|
||||
However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly.
|
||||
|
||||
|
||||
|
||||
toml::get<T>
|
||||
#
|
||||
|
||||
|
||||
Overview
|
||||
#
|
||||
|
||||
Generally, toml::get behaves as follows:
|
||||
You specify T as in toml::get<int>(v)."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/get/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="get.hpp"><meta property="og:description" content="get.hpp # These are functions for extracting values from toml::value and performing type conversions if necessary.
|
||||
toml::value can change the type it stores, and toml::get accommodates these types. Technically, all functions use toml::basic_value<TC>. However, for simplicity, we refer to it as toml::value in explanations unless a distinction is necessary. In the documentation, if the template parameter TC changes the type, assume that types like toml::value::integer_type will also change accordingly. toml::get<T> # Overview # Generally, toml::get behaves as follows: You specify T as in toml::get<int>(v)."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>get.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/get/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/get/ title=get.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/get/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/ class=active>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>get.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#gethpp>get.hpp</a></li><li><a href=#tomlgett><code>toml::get<T></code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#types-that-do-not-require-conversion>Types that Do Not Require Conversion</a></li><li><a href=#types-that-require-conversion>Types that Require Conversion</a></li><li><a href=#when-conversion-fails>When Conversion Fails</a></li></ul></li><li><a href=#when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code></a></li><li><a href=#when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value<OtherTC></code> with a different <code>TypeConfig</code></a></li><li><a href=#when-t-is-an-integer-type>When <code>T</code> is an integer type</a></li><li><a href=#when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type</a></li><li><a href=#when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code></a></li><li><a href=#when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code></a></li><li><a href=#when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code></a></li><li><a href=#when-t-is-array-like>When <code>T</code> is array-like</a></li><li><a href=#when-t-is-stdarray>When <code>T</code> is <code>std::array</code></a></li><li><a href=#when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code></a></li><li><a href=#when-t-is-stdpair>When <code>T</code> is <code>std::pair</code></a></li><li><a href=#when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code></a></li><li><a href=#when-t-is-map-like>When <code>T</code> is map-like</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from<T></code></a></li><li><a href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value<TC></code></a></li></ul></li><li><a href=#tomlget_ort><code>toml::get_or<T></code></a><ul><li><a href=#when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value<TC></code></a></li><li><a href=#when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value<TC>::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-something-else>When <code>T</code> is something else</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=gethpp>get.hpp
|
||||
<a class=anchor href=#gethpp>#</a></h1><p>These are functions for extracting values from <code>toml::value</code> and performing type conversions if necessary.</p><blockquote class="book-hint info"><code>toml::value</code> can change the type it stores, and <code>toml::get</code> accommodates these types.
|
||||
Technically, all functions use <code>toml::basic_value<TC></code>.
|
||||
However, for simplicity, we refer to it as <code>toml::value</code> in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter <code>TC</code> changes the type, assume that types like <code>toml::value::integer_type</code> will also change accordingly.</blockquote><h1 id=tomlgett><code>toml::get<T></code>
|
||||
<a class=anchor href=#tomlgett>#</a></h1><h2 id=overview>Overview
|
||||
<a class=anchor href=#overview>#</a></h2><p>Generally, <code>toml::get</code> behaves as follows:
|
||||
You specify <code>T</code> as in <code>toml::get<int>(v)</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>However, depending on the type of <code>T</code>, <code>toml::get</code> can exhibit different behaviors.</p><p>The types of <code>T</code> can be categorized into:</p><ol><li>Types that do not require conversion</li><li>Types that require conversion</li></ol><p>Detailed conditions and the specific types supported are discussed later.</p><h3 id=types-that-do-not-require-conversion>Types that Do Not Require Conversion
|
||||
<a class=anchor href=#types-that-do-not-require-conversion>#</a></h3><p>No conversion is needed if the provided <code>toml::value</code> is already storing the desired type. For instance, since <code>toml::value::integer_type</code> is an alias for <code>std::int64_t</code>, <code>toml::get<std::int64_t>(v)</code> requires no conversion. In this case, <code>toml::get</code> retrieves the <code>integer</code> value from <code>toml::value</code> and returns a reference to it.</p><p>If the provided <code>toml::value</code> is a mutable reference (<code>&</code>), the returned value is also a mutable reference (<code>&</code>). If it is an immutable reference (<code>const&</code>), the returned value will also be an immutable reference (<code>const&</code>). Returning a mutable reference allows you to overwrite the value stored in <code>toml::value</code> through that reference.</p><h3 id=types-that-require-conversion>Types that Require Conversion
|
||||
<a class=anchor href=#types-that-require-conversion>#</a></h3><p>Types other than the ones mentioned above require conversion. For example, since <code>toml::value::integer_type</code> is an alias for <code>std::int64_t</code>, <code>toml::get<std::size_t>(toml::value&)</code> requires conversion. In this case, <code>toml::get</code> retrieves the <code>integer</code> value from <code>toml::value</code> and casts it to return the appropriate type.</p><p>toml11 supports not only simple casts but also complex type conversions like converting from <code>toml::array</code> to <code>std::tuple<int, double, std::string></code>, <code>std::array<double, 4></code>, or from <code>toml::table</code> to <code>std::map<std::string, int></code>. For specifics, refer to the subsequent sections.</p><h3 id=when-conversion-fails>When Conversion Fails
|
||||
<a class=anchor href=#when-conversion-fails>#</a></h3><p>Sometimes, the expected type conversion cannot be performed. For example, applying <code>toml::get<int>(v)</code> to a <code>toml::value</code> that holds a <code>table</code>.</p><p>In such cases, an attempt to convert to the type most similar to the desired type (in this case, <code>int</code> using <code>as_integer</code>) fails, and a <code>toml::type_error</code> is thrown.</p><p>When parsing from a file, an error message similar to the following is output:</p><pre tabindex=0><code>terminate called after throwing an instance of 'toml::type_error'
|
||||
what(): toml::value::as_integer(): bad_cast to integer
|
||||
--> input.toml
|
||||
|
|
||||
6 | [fruit]
|
||||
| ^^^^^^^-- the actual type is table
|
||||
</code></pre><h2 id=when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code>
|
||||
<a class=anchor href=#when-t-is-identical-to-tomlvalue>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T<span style=color:#f92672>&</span> get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same<T, basic_value<TC>></code> is satisfied.</li></ul><p>Since this involves retrieving <code>toml::value</code> from <code>toml::value</code>, no conversion is performed, and the value is returned as is. This exists solely to generalize the implementation of other functions.</p><p>This does not fail.</p><h2 id=when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code>
|
||||
<a class=anchor href=#when-t-is-one-of-tomlvaluesome_type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T<span style=color:#f92672>&</span> get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> must be the same as one of the types that <code>toml::value</code> can store (e.g., <code>toml::value::boolean_type</code>).</li></ul><p>If <code>toml::value</code> is storing a type that matches the specified type in <code>toml::get<T></code>, such as <code>toml::value::integer_type</code>, no type conversion is needed, and a reference can be returned.</p><p>If a different type is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value<OtherTC></code> with a different <code>TypeConfig</code>
|
||||
<a class=anchor href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is not <code>toml::basic_value<TC></code>.</li><li><code>T</code> is <code>toml::basic_value<OtherTC></code>.</li></ul><p>When a <code>basic_value</code> that can store different types is specified, conversion is performed.</p><p>Since type conversion occurs, the returned value is a new value and not a reference.</p><p>This does not fail (except in cases like memory exhaustion).</p><h2 id=when-t-is-an-integer-type>When <code>T</code> is an integer type
|
||||
<a class=anchor href=#when-t-is-an-integer-type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_integral<T></code> is satisfied</li><li><code>T</code> is not <code>bool</code></li><li><code>T</code> is not <code>toml::value::integer_type</code></li></ul><p>The function assumes that <code>toml::value</code> holds an <code>integer_type</code>, retrieves its value, converts it to <code>T</code>, and returns it.</p><p>If a type other than <code>toml::value::integer_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type
|
||||
<a class=anchor href=#when-t-is-a-floating-point-type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_floating_point<T></code> is satisfied</li><li><code>T</code> is not <code>toml::value::floating_type</code></li></ul><p>The function assumes that <code>toml::value</code> holds a <code>floating_type</code>, retrieves its value, converts it to <code>T</code>, and returns it.</p><p>If a type other than <code>toml::value::floating_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code>
|
||||
<a class=anchor href=#when-t-is-stdstring_view>#</a></h2><p>This is only available in C++17 and later.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same<std::string_view, T></code> is satisfied</li></ul><p>The function assumes that <code>toml::value</code> holds a <code>string_type</code>, retrieves its value, constructs a <code>std::string_view</code> from it, and returns it.</p><p>If a type other than <code>toml::value::string_type</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code>
|
||||
<a class=anchor href=#when-t-is-stdchronoduration>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::chrono::duration<Rep, Period></code></li></ul><p>The function assumes that <code>toml::value</code> holds a <code>local_time</code>, retrieves its value, converts it to <code>std::chrono::duration</code>, and returns it.</p><p>If a type other than <code>toml::value::local_time</code> is stored, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code>
|
||||
<a class=anchor href=#when-t-is-stdchronosystem_clocktime_point>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>std::is_same<T, std::chrono::system_clock::time_point></code> is satisfied</li></ul><p>If the <code>toml::value</code> holds a <code>local_date</code>, <code>local_datetime</code>, or <code>offset_datetime</code>, this function retrieves the value and converts it to <code>std::chrono::system_clock::time_point</code>, returning the result.</p><p>If the value is of a type other than <code>local_date</code>, <code>local_datetime</code>, or <code>offset_datetime</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-array-like>When <code>T</code> is array-like
|
||||
<a class=anchor href=#when-t-is-array-like>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>T</code> has an <code>iterator</code></li><li><code>T</code> has a <code>value_type</code></li><li><code>T</code> supports <code>push_back(x)</code></li><li><code>T</code> is not <code>toml::value::array_type</code></li><li><code>T</code> is not <code>std::string</code></li><li><code>T</code> is not <code>std::string_view</code></li><li><code>T</code> is not map-like</li><li><code>T</code> does not have <code>from_toml()</code> member function</li><li><code>toml::from<T></code> is not defined</li><li>A constructor from <code>toml::basic_value<TC></code> is not defined</li></ul><p>This includes types like <code>std::vector<int></code> and <code>std::deque<std::string></code>.</p><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to the specified container type, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdarray>When <code>T</code> is <code>std::array</code>
|
||||
<a class=anchor href=#when-t-is-stdarray>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::array<U, N></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to the specified container type, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain enough elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code>
|
||||
<a class=anchor href=#when-t-is-stdforward_list>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::forward_list<U></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to a <code>std::forward_list</code>, returning the result.</p><p>If the value is of a type other than <code>toml::value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-stdpair>When <code>T</code> is <code>std::pair</code>
|
||||
<a class=anchor href=#when-t-is-stdpair>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::pair<T1, T2></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to <code>std::pair<T1, T2></code>, returning the result.</p><p>The <code>first</code> and <code>second</code> elements are recursively converted.</p><p>If the value is of a type other than <code>basic_value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain exactly 2 elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code>
|
||||
<a class=anchor href=#when-t-is-stdtuple>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li><code>T</code> is <code>std::tuple<T1, T2, ... TN></code></li></ul><p>If the <code>toml::value</code> holds an <code>array</code>, this function retrieves the value and converts it to <code>std::tuple<T1, T2, ...TN></code>, returning the result.</p><p>Each element is recursively converted.</p><p>If the value is of a type other than <code>basic_value::array_type</code>, a <code>toml::type_error</code> is thrown.</p><p>If the <code>array</code> held by <code>toml::value</code> does not contain exactly <code>std::tuple_size<T>::value</code> elements, a <code>std::out_of_range</code> is thrown.</p><h2 id=when-t-is-map-like>When <code>T</code> is map-like
|
||||
<a class=anchor href=#when-t-is-map-like>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>T</code> has an <code>iterator</code></li><li><code>T</code> has a <code>key_type</code></li><li><code>T</code> has a <code>value_type</code></li><li><code>T</code> has a <code>mapped_type</code></li><li><code>T</code> is not <code>toml::value::table_type</code></li><li><code>T</code> does not have a <code>from_toml()</code> member function</li><li><code>toml::from<T></code> is not defined</li><li>A constructor from <code>toml::basic_value<TC></code> is not defined</li></ul><p>This includes types like <code>std::map<std::string, int></code> and <code>std::unordered_map<std::string, float></code>.</p><p>If the <code>toml::value</code> holds a <code>table</code>, this function retrieves the value and converts it to <code>T</code>, returning the result.</p><p>Elements are recursively converted.</p><p>If the value is of a type other than <code>basic_value::table_type</code>, a <code>toml::type_error</code> is thrown.</p><h2 id=when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from<T></code>
|
||||
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Condition:</p><ul><li>A specialization of <code>toml::from<T></code> is defined</li></ul><p>If a specialization of <code>toml::from</code> for <code>T</code> is defined, it is used for type conversion.</p><p>Ensure this does not conflict with individually supported types (<code>std::array</code>, <code>std::pair</code>, <code>std::tuple</code> etc).</p><h2 id=when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function
|
||||
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>toml::from<T></code> is not defined</li><li><code>T</code> has <code>from_toml()</code> member function</li></ul><p>If <code>T</code> has a <code>from_toml(toml::basic_value<TC>)</code> member function, it is used for type conversion.</p><p>If <code>toml::from<T></code> is defined, it takes precedence.</p><h2 id=when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value<TC></code>
|
||||
<a class=anchor href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v);
|
||||
</span></span></code></pre></div><p>Conditions:</p><ul><li><code>toml::from<T></code> is not defined</li><li><code>T</code> does not have <code>from_toml()</code> member function</li><li><code>T</code> has a constructor that takes <code>toml::basic_value<TC></code></li></ul><p>If <code>T</code> has a constructor that takes <code>toml::basic_value<TC></code>, it is used for type conversion.</p><p>If <code>toml::from<T></code> or <code>T::from_toml</code> is defined, they take precedence.</p><h1 id=tomlget_ort><code>toml::get_or<T></code>
|
||||
<a class=anchor href=#tomlget_ort>#</a></h1><p><code>get_or</code> takes a default value for use when the conversion fails, avoiding exceptions.</p><p>The default value must be of the same type as the target type <code>T</code>.
|
||||
Therefore, unlike <code>toml::get<T></code>, <code>T</code> can be inferred in <code>get_or</code>.</p><h2 id=when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value<TC></code>
|
||||
<a class=anchor href=#when-t-is-basic_valuetc>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> opt)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> <span style=color:#f92672>&</span> get_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> opt)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> get_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> opt)
|
||||
</span></span></code></pre></div><p>Since the conversion target is the same <code>toml::value</code>, this never fails.</p><p>It exists solely to generalize the implementation of other functions.</p><h2 id=when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value<TC>::{some_type}</code>
|
||||
<a class=anchor href=#when-t-is-basic_valuetcsome_type>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, <span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T <span style=color:#f92672>&</span> get_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, T<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>T get_or(basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&&</span> v, T<span style=color:#f92672>&&</span> opt) <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><p>Performs the same conversion as <code>toml::get<T></code>. If it fails, the second argument is returned.</p><h2 id=when-t-is-const-char>When <code>T</code> is <code>const char*</code>
|
||||
<a class=anchor href=#when-t-is-const-char>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>string_type
|
||||
</span></span><span style=display:flex><span>get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> opt);
|
||||
</span></span></code></pre></div><p>When <code>const char*</code> is passed, the conversion target is interpreted as <code>std::string</code>.</p><h2 id=when-t-is-something-else>When <code>T</code> is something else
|
||||
<a class=anchor href=#when-t-is-something-else>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>remove_cv<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>remove_reference<span style=color:#f92672><</span>T<span style=color:#f92672>>::</span>type<span style=color:#f92672>>::</span>type
|
||||
</span></span><span style=display:flex><span>get_or(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, T<span style=color:#f92672>&&</span> opt);
|
||||
</span></span></code></pre></div><p>Performs the same conversion as <code>toml::get<T></code>. If it fails, the second argument is returned.</p><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/find/>find.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/from/>from.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#gethpp>get.hpp</a></li><li><a href=#tomlgett><code>toml::get<T></code></a><ul><li><a href=#overview>Overview</a><ul><li><a href=#types-that-do-not-require-conversion>Types that Do Not Require Conversion</a></li><li><a href=#types-that-require-conversion>Types that Require Conversion</a></li><li><a href=#when-conversion-fails>When Conversion Fails</a></li></ul></li><li><a href=#when-t-is-identical-to-tomlvalue>When <code>T</code> is identical to <code>toml::value</code></a></li><li><a href=#when-t-is-one-of-tomlvaluesome_type>When <code>T</code> is one of <code>toml::value::{some_type}</code></a></li><li><a href=#when-t-is-basic_valueothertc-with-a-different-typeconfig>When <code>T</code> is <code>basic_value<OtherTC></code> with a different <code>TypeConfig</code></a></li><li><a href=#when-t-is-an-integer-type>When <code>T</code> is an integer type</a></li><li><a href=#when-t-is-a-floating-point-type>When <code>T</code> is a floating-point type</a></li><li><a href=#when-t-is-stdstring_view>When <code>T</code> is <code>std::string_view</code></a></li><li><a href=#when-t-is-stdchronoduration>When <code>T</code> is <code>std::chrono::duration</code></a></li><li><a href=#when-t-is-stdchronosystem_clocktime_point>When <code>T</code> is <code>std::chrono::system_clock::time_point</code></a></li><li><a href=#when-t-is-array-like>When <code>T</code> is array-like</a></li><li><a href=#when-t-is-stdarray>When <code>T</code> is <code>std::array</code></a></li><li><a href=#when-t-is-stdforward_list>When <code>T</code> is <code>std::forward_list</code></a></li><li><a href=#when-t-is-stdpair>When <code>T</code> is <code>std::pair</code></a></li><li><a href=#when-t-is-stdtuple>When <code>T</code> is <code>std::tuple</code></a></li><li><a href=#when-t-is-map-like>When <code>T</code> is map-like</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-specialization-of-tomlfromt>When <code>T</code> is a user-defined type with a specialization of <code>toml::from<T></code></a></li><li><a href=#when-t-is-a-user-defined-type-with-a-from_toml-member-function>When <code>T</code> is a user-defined type with a <code>from_toml</code> member function</a></li><li><a href=#when-t-is-a-user-defined-type-with-a-constructor-that-takes-tomlbasic_valuetc>When <code>T</code> is a user-defined type with a constructor that takes <code>toml::basic_value<TC></code></a></li></ul></li><li><a href=#tomlget_ort><code>toml::get_or<T></code></a><ul><li><a href=#when-t-is-basic_valuetc>When <code>T</code> is <code>basic_value<TC></code></a></li><li><a href=#when-t-is-basic_valuetcsome_type>When <code>T</code> is <code>basic_value<TC>::{some_type}</code></a></li><li><a href=#when-t-is-const-char>When <code>T</code> is <code>const char*</code></a></li><li><a href=#when-t-is-something-else>When <code>T</code> is something else</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
64
docs/reference/index.html
Normal file
64
docs/reference/index.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
Reference
|
||||
#
|
||||
|
||||
Here, we explain the effects of the classes and functions provided by toml11.
|
||||
|
||||
Directory Structure
|
||||
#
|
||||
|
||||
toml.hpp and toml_fwd.hpp reside in ${TOML11_INCLUDE_DIR}.
|
||||
Other files are located in ${TOML11_INCLUDE_DIR}/toml11.
|
||||
If you want to #include each feature’s file individually, use #include <toml11/color.hpp>.
|
||||
If you want to include all at once, use #include <toml.hpp>.
|
||||
|
||||
color.hpp
|
||||
#
|
||||
|
||||
Defines functions related to colorizing error messages.
|
||||
|
||||
comments.hpp
|
||||
#
|
||||
|
||||
Defines types preserve_comment and discard_comment for preserving comments."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="reference"><meta property="og:description" content="Reference # Here, we explain the effects of the classes and functions provided by toml11.
|
||||
Directory Structure # toml.hpp and toml_fwd.hpp reside in ${TOML11_INCLUDE_DIR}. Other files are located in ${TOML11_INCLUDE_DIR}/toml11.
|
||||
If you want to #include each feature’s file individually, use #include <toml11/color.hpp>. If you want to include all at once, use #include <toml.hpp>.
|
||||
color.hpp # Defines functions related to colorizing error messages.
|
||||
comments.hpp # Defines types preserve_comment and discard_comment for preserving comments."><meta property="og:locale" content="en"><meta property="og:type" content="website"><title>reference | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/ title=reference><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script><link rel=alternate type=application/rss+xml href=https://toruniina.github.io/toml11/docs/reference/index.xml title=toml11></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/ class=active>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>reference</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#reference>Reference</a><ul><li><a href=#directory-structure>Directory Structure</a></li><li><a href=#colorhpp>color.hpp</a></li><li><a href=#commentshpp>comments.hpp</a></li><li><a href=#conversionhpp>conversion.hpp</a></li><li><a href=#datetimehpp>datetime.hpp</a></li><li><a href=#error_>error_info.hpp</a></li><li><a href=#exceptionhpp>exception.hpp</a></li><li><a href=#findhpp>find.hpp</a></li><li><a href=#formathpp>format.hpp</a></li><li><a href=#fromhpp>from.hpp</a></li><li><a href=#gethpp>get.hpp</a></li><li><a href=#intohpp>into.hpp</a></li><li><a href=#literalhpp>literal.hpp</a></li><li><a href=#ordered_>ordered_map.hpp</a></li><li><a href=#parserhpp>parser.hpp</a></li><li><a href=#resulthpp>result.hpp</a></li><li><a href=#serializerhpp>serializer.hpp</a></li><li><a href=#source_>source_location.hpp</a></li><li><a href=#spechpp>spec.hpp</a></li><li><a href=#tomlhpp>toml.hpp</a></li><li><a href=#toml_>toml_fwd.hpp</a></li><li><a href=#typeshpp>types.hpp</a></li><li><a href=#valuehpp>value.hpp</a></li><li><a href=#value_>value_t.hpp</a></li><li><a href=#versionhpp>version.hpp</a></li><li><a href=#visithpp>visit.hpp</a></li><li><a href=#notes>Notes</a></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=reference>Reference
|
||||
<a class=anchor href=#reference>#</a></h1><p>Here, we explain the effects of the classes and functions provided by toml11.</p><h2 id=directory-structure>Directory Structure
|
||||
<a class=anchor href=#directory-structure>#</a></h2><p><code>toml.hpp</code> and <code>toml_fwd.hpp</code> reside in <code>${TOML11_INCLUDE_DIR}</code>.
|
||||
Other files are located in <code>${TOML11_INCLUDE_DIR}/toml11</code>.</p><p>If you want to <code>#include</code> each feature’s file individually, use <code>#include <toml11/color.hpp></code>.
|
||||
If you want to include all at once, use <code>#include <toml.hpp></code>.</p><h2 id=colorhpp><a href=color>color.hpp</a>
|
||||
<a class=anchor href=#colorhpp>#</a></h2><p>Defines functions related to colorizing error messages.</p><h2 id=commentshpp><a href=comments>comments.hpp</a>
|
||||
<a class=anchor href=#commentshpp>#</a></h2><p>Defines types <code>preserve_comment</code> and <code>discard_comment</code> for preserving comments.</p><h2 id=conversionhpp><a href=conversion>conversion.hpp</a>
|
||||
<a class=anchor href=#conversionhpp>#</a></h2><p>Defines macros to automatically convert <code>toml::value</code> and user-defined classes.</p><h2 id=datetimehpp><a href=datetime>datetime.hpp</a>
|
||||
<a class=anchor href=#datetimehpp>#</a></h2><p>Defines classes for datetime information.</p><h2 id=error_><a href=error_info>error_info.hpp</a>
|
||||
<a class=anchor href=#error_>#</a></h2><p>Defines a class for error information.</p><h2 id=exceptionhpp><a href=exception>exception.hpp</a>
|
||||
<a class=anchor href=#exceptionhpp>#</a></h2><p>Defines the base class for exceptions used in toml11, <code>toml::exception</code>.</p><h2 id=findhpp><a href=find>find.hpp</a>
|
||||
<a class=anchor href=#findhpp>#</a></h2><p>Defines the <code>toml::find</code> function to search for and convert values.</p><h2 id=formathpp><a href=format>format.hpp</a>
|
||||
<a class=anchor href=#formathpp>#</a></h2><p>Defines classes for formatting information of values.</p><h2 id=fromhpp><a href=from>from.hpp</a>
|
||||
<a class=anchor href=#fromhpp>#</a></h2><p>Forward declaration of the <code>from<T></code> type for converting user-defined types.</p><h2 id=gethpp><a href=get>get.hpp</a>
|
||||
<a class=anchor href=#gethpp>#</a></h2><p>Defines the <code>toml::get<T></code> function to retrieve and convert values from <code>toml::value</code>.</p><h2 id=intohpp><a href=into>into.hpp</a>
|
||||
<a class=anchor href=#intohpp>#</a></h2><p>Forward declaration of the <code>into<T></code> type for converting user-defined types.</p><h2 id=literalhpp><a href=literal>literal.hpp</a>
|
||||
<a class=anchor href=#literalhpp>#</a></h2><p>Defines the <code>operator"" _toml</code> literal.</p><h2 id=ordered_><a href=ordered_map>ordered_map.hpp</a>
|
||||
<a class=anchor href=#ordered_>#</a></h2><p>Defines <code>toml::ordered_map</code>.</p><h2 id=parserhpp><a href=parser>parser.hpp</a>
|
||||
<a class=anchor href=#parserhpp>#</a></h2><p>Defines functions to parse files or strings.</p><h2 id=resulthpp><a href=result>result.hpp</a>
|
||||
<a class=anchor href=#resulthpp>#</a></h2><p>Defines the <code>result<T, E></code> type for representing success or failure values used as return types in other functions.</p><h2 id=serializerhpp><a href=serializer>serializer.hpp</a>
|
||||
<a class=anchor href=#serializerhpp>#</a></h2><p>Defines the <code>toml::format</code> function and <code>toml::serializer</code> used for serialization.</p><h2 id=source_><a href=source_location>source_location.hpp</a>
|
||||
<a class=anchor href=#source_>#</a></h2><p>Defines the <code>source_location</code> type used for error information, pointing to a location within a file.</p><h2 id=spechpp><a href=spec>spec.hpp</a>
|
||||
<a class=anchor href=#spechpp>#</a></h2><p>Defines the <code>toml::semantic_version</code> and <code>toml::spec</code> types to control TOML language version information and feature flags.</p><h2 id=tomlhpp><a href=toml>toml.hpp</a>
|
||||
<a class=anchor href=#tomlhpp>#</a></h2><p><code>toml.hpp</code> includes all other headers, making all toml11 features available.</p><h2 id=toml_><a href=toml_fwd>toml_fwd.hpp</a>
|
||||
<a class=anchor href=#toml_>#</a></h2><p><code>toml_fwd.hpp</code> contains forward declarations of structs defined in toml11 and macro definitions.</p><h2 id=typeshpp><a href=types>types.hpp</a>
|
||||
<a class=anchor href=#typeshpp>#</a></h2><p>Defines the <code>toml::type_config</code> type for controlling the types held by <code>toml::value</code>.</p><h2 id=valuehpp><a href=value>value.hpp</a>
|
||||
<a class=anchor href=#valuehpp>#</a></h2><p>Defines the <code>toml::value</code> type.</p><h2 id=value_><a href=value_t>value_t.hpp</a>
|
||||
<a class=anchor href=#value_>#</a></h2><p>Defines the <code>toml::value_t</code> enumeration.</p><h2 id=versionhpp><a href=version>version.hpp</a>
|
||||
<a class=anchor href=#versionhpp>#</a></h2><p>Defines the version information for toml11.</p><h2 id=visithpp><a href=visit>visit.hpp</a>
|
||||
<a class=anchor href=#visithpp>#</a></h2><p>Defines the <code>toml::visit</code> function to apply functions to the values held by <code>toml::value</code>.</p><h2 id=notes>Notes
|
||||
<a class=anchor href=#notes>#</a></h2><p>Functions not explicitly mentioned here (mostly those defined under <code>namespace toml::detail</code> or <code>namespace toml::cxx</code>) are available by inspecting the source code but are not guaranteed to maintain their interface across future versions (including patch version updates).</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#reference>Reference</a><ul><li><a href=#directory-structure>Directory Structure</a></li><li><a href=#colorhpp>color.hpp</a></li><li><a href=#commentshpp>comments.hpp</a></li><li><a href=#conversionhpp>conversion.hpp</a></li><li><a href=#datetimehpp>datetime.hpp</a></li><li><a href=#error_>error_info.hpp</a></li><li><a href=#exceptionhpp>exception.hpp</a></li><li><a href=#findhpp>find.hpp</a></li><li><a href=#formathpp>format.hpp</a></li><li><a href=#fromhpp>from.hpp</a></li><li><a href=#gethpp>get.hpp</a></li><li><a href=#intohpp>into.hpp</a></li><li><a href=#literalhpp>literal.hpp</a></li><li><a href=#ordered_>ordered_map.hpp</a></li><li><a href=#parserhpp>parser.hpp</a></li><li><a href=#resulthpp>result.hpp</a></li><li><a href=#serializerhpp>serializer.hpp</a></li><li><a href=#source_>source_location.hpp</a></li><li><a href=#spechpp>spec.hpp</a></li><li><a href=#tomlhpp>toml.hpp</a></li><li><a href=#toml_>toml_fwd.hpp</a></li><li><a href=#typeshpp>types.hpp</a></li><li><a href=#valuehpp>value.hpp</a></li><li><a href=#value_>value_t.hpp</a></li><li><a href=#versionhpp>version.hpp</a></li><li><a href=#visithpp>visit.hpp</a></li><li><a href=#notes>Notes</a></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
768
docs/reference/index.xml
Normal file
768
docs/reference/index.xml
Normal file
@@ -0,0 +1,768 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>reference on toml11</title><link>https://toruniina.github.io/toml11/docs/reference/</link><description>Recent content in reference on toml11</description><generator>Hugo</generator><language>en</language><atom:link href="https://toruniina.github.io/toml11/docs/reference/index.xml" rel="self" type="application/rss+xml"/><item><title>color.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/color/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/color/</guid><description><h1 id="colorhpp">
|
||||
color.hpp
|
||||
<a class="anchor" href="#colorhpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>color.hpp</code>, functions related to colorizing error messages are defined.</p>
|
||||
<p>Colors are specified using ANSI escape code.
|
||||
In terminals or other output destinations that do not support ANSI escape code, the output may become difficult to read.</p>
|
||||
<h2 id="macros">
|
||||
Macros
|
||||
<a class="anchor" href="#macros">#</a>
|
||||
</h2>
|
||||
<h3 id="toml11_colorize_error_message">
|
||||
<code>TOML11_COLORIZE_ERROR_MESSAGE</code>
|
||||
<a class="anchor" href="#toml11_colorize_error_message">#</a>
|
||||
</h3>
|
||||
<p>If this macro is defined during compilation (<code>-DTOML11_COLORIZE_ERROR_MESASGE</code>), error messages are colored by default.</p>
|
||||
<p>If not defined, colors are not applied by default. You need to specify them using <code>toml::color::enable()</code>.</p></description></item><item><title>comments.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/comments/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/comments/</guid><description><h1 id="commentshpp">
|
||||
comments.hpp
|
||||
<a class="anchor" href="#commentshpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>comments.hpp</code>, comment containers are provided.</p>
|
||||
<h1 id="tomlpreserve_comments">
|
||||
<code>toml::preserve_comments</code>
|
||||
<a class="anchor" href="#tomlpreserve_comments">#</a>
|
||||
</h1>
|
||||
<p><code>preserve_comments</code> is a container that preserves comments.</p>
|
||||
<p>It has all the member functions of <code>std::vector&lt;std::string&gt;</code>.</p>
|
||||
<p>Comments are preserved as <code>std::string</code>.
|
||||
If the comment does not start with <code>#</code>, it will be prefixed with <code>#</code> during output.
|
||||
However, this prefixing is not done when adding comments to the container.</p>
|
||||
<p>Spaces are not automatically added, so if you want a space immediately after <code>#</code>,
|
||||
either start the comment with a space or pass the comment with <code>#</code>.</p></description></item><item><title>conversion.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/conversion/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/conversion/</guid><description><h1 id="conversionhpp">
|
||||
conversion.hpp
|
||||
<a class="anchor" href="#conversionhpp">#</a>
|
||||
</h1>
|
||||
<p>Provides macros to automatically define conversion functions for supporting user-defined types with <code>toml::get</code> and <code>toml::find</code>.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span>TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(NAME, ...)
|
||||
</span></span></code></pre></div><h2 id="example">
|
||||
Example
|
||||
<a class="anchor" href="#example">#</a>
|
||||
</h2>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> foo
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">Foo</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string s;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">double</span> d;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">int</span> i;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// foo
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span>TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(foo<span style="color:#f92672">::</span>Foo, s, d, i)
|
||||
</span></span></code></pre></div><h1 id="related">
|
||||
Related
|
||||
<a class="anchor" href="#related">#</a>
|
||||
</h1>
|
||||
<ul>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/from/">from.hpp</a></li>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/into/">into.hpp</a></li>
|
||||
</ul></description></item><item><title>datetime.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/datetime/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/datetime/</guid><description><h1 id="datetimehpp">
|
||||
datetime.hpp
|
||||
<a class="anchor" href="#datetimehpp">#</a>
|
||||
</h1>
|
||||
<p>Defines a class that stores date and time information used in TOML&rsquo;s <code>datetime</code>.</p>
|
||||
<h1 id="enum-class-month_t">
|
||||
<code>enum class month_t</code>
|
||||
<a class="anchor" href="#enum-class-month_t">#</a>
|
||||
</h1>
|
||||
<p>Enum class to specify months.</p>
|
||||
<p>Due to its relationship with <code>std::tm</code>, <code>local_date</code> treats January as <code>0</code>.
|
||||
To avoid confusion, <code>month_t</code> allows specification of months by their names.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">enum</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">month_t</span> <span style="color:#f92672">:</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint8_t</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> Jan <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>,
|
||||
</span></span><span style="display:flex;"><span> Feb <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>,
|
||||
</span></span><span style="display:flex;"><span> Mar <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>,
|
||||
</span></span><span style="display:flex;"><span> Apr <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>,
|
||||
</span></span><span style="display:flex;"><span> May <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>,
|
||||
</span></span><span style="display:flex;"><span> Jun <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>,
|
||||
</span></span><span style="display:flex;"><span> Jul <span style="color:#f92672">=</span> <span style="color:#ae81ff">6</span>,
|
||||
</span></span><span style="display:flex;"><span> Aug <span style="color:#f92672">=</span> <span style="color:#ae81ff">7</span>,
|
||||
</span></span><span style="display:flex;"><span> Sep <span style="color:#f92672">=</span> <span style="color:#ae81ff">8</span>,
|
||||
</span></span><span style="display:flex;"><span> Oct <span style="color:#f92672">=</span> <span style="color:#ae81ff">9</span>,
|
||||
</span></span><span style="display:flex;"><span> Nov <span style="color:#f92672">=</span> <span style="color:#ae81ff">10</span>,
|
||||
</span></span><span style="display:flex;"><span> Dec <span style="color:#f92672">=</span> <span style="color:#ae81ff">11</span>
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><h1 id="local_date">
|
||||
<code>local_date</code>
|
||||
<a class="anchor" href="#local_date">#</a>
|
||||
</h1>
|
||||
<p><code>local_date</code> holds a date.</p></description></item><item><title>error_info.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/error_info/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/error_info/</guid><description><h1 id="error_infohpp">
|
||||
error_info.hpp
|
||||
<a class="anchor" href="#error_infohpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>error_info.hpp</code>, definitions for <code>error_info</code> and functions to format it are provided.</p>
|
||||
<h1 id="tomlerror_info">
|
||||
<code>toml::error_info</code>
|
||||
<a class="anchor" href="#tomlerror_info">#</a>
|
||||
</h1>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">error_info</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> error_info(std<span style="color:#f92672">::</span>string t, source_location l, std<span style="color:#f92672">::</span>string m, std<span style="color:#f92672">::</span>string s <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;&#34;</span>);
|
||||
</span></span><span style="display:flex;"><span> error_info(std<span style="color:#f92672">::</span>string t, std<span style="color:#f92672">::</span>vector<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>pair<span style="color:#f92672">&lt;</span>source_location, std<span style="color:#f92672">::</span>string<span style="color:#f92672">&gt;&gt;</span> l, std<span style="color:#f92672">::</span>string s <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;&#34;</span>);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> title() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#f92672">&amp;</span> title() <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>vector<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>pair<span style="color:#f92672">&lt;</span>source_location, std<span style="color:#f92672">::</span>string<span style="color:#f92672">&gt;&gt;</span> <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> locations() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">add_locations</span>(source_location loc, std<span style="color:#f92672">::</span>string msg) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> suffix() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#f92672">&amp;</span> suffix() <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> ... Ts<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>error_info make_error_info(
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string title, source_location loc, std<span style="color:#f92672">::</span>string msg, Ts<span style="color:#f92672">&amp;&amp;</span> ... tail);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format_error(<span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>string<span style="color:#f92672">&amp;</span> errkind, <span style="color:#66d9ef">const</span> error_info<span style="color:#f92672">&amp;</span> err);
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format_error(<span style="color:#66d9ef">const</span> error_info<span style="color:#f92672">&amp;</span> err);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> ... Ts<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format_error(std<span style="color:#f92672">::</span>string title,
|
||||
</span></span><span style="display:flex;"><span> source_location loc, std<span style="color:#f92672">::</span>string msg, Ts<span style="color:#f92672">&amp;&amp;</span> ... tail);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;&lt;</span>(std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> os, <span style="color:#66d9ef">const</span> error_info<span style="color:#f92672">&amp;</span> e);
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><h2 id="member-functions">
|
||||
Member Functions
|
||||
<a class="anchor" href="#member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="constructor-title-loc-msg-suffix">
|
||||
Constructor (<code>title, loc, msg, suffix</code>)
|
||||
<a class="anchor" href="#constructor-title-loc-msg-suffix">#</a>
|
||||
</h3>
|
||||
<p>Constructs <code>error_info</code> with specified <code>title</code>, location information <code>loc</code>, message <code>msg</code>, and optional <code>suffix</code>.</p></description></item><item><title>exception.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/exception/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/exception/</guid><description><h1 id="exceptionhpp">
|
||||
exception.hpp
|
||||
<a class="anchor" href="#exceptionhpp">#</a>
|
||||
</h1>
|
||||
<h1 id="tomlexception">
|
||||
<code>toml::exception</code>
|
||||
<a class="anchor" href="#tomlexception">#</a>
|
||||
</h1>
|
||||
<p>Base class for exception types defined in toml11.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">exception</span> <span style="color:#f92672">:</span> <span style="color:#66d9ef">public</span> std<span style="color:#f92672">::</span>exception
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span><span style="color:#f92672">:</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">virtual</span> <span style="color:#f92672">~</span>exception() <span style="color:#66d9ef">noexcept</span> <span style="color:#66d9ef">override</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">virtual</span> <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span><span style="color:#f92672">*</span> <span style="color:#a6e22e">what</span>() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span> <span style="color:#66d9ef">override</span> {<span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;&#34;</span>;}
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="member-functions">
|
||||
Member Functions
|
||||
<a class="anchor" href="#member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="destructor">
|
||||
Destructor
|
||||
<a class="anchor" href="#destructor">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">virtual</span> <span style="color:#f92672">~</span>exception() <span style="color:#66d9ef">noexcept</span> <span style="color:#66d9ef">override</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span></code></pre></div><p>Override when derived.</p>
|
||||
<h3 id="what">
|
||||
<code>what</code>
|
||||
<a class="anchor" href="#what">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">virtual</span> <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span><span style="color:#f92672">*</span> <span style="color:#a6e22e">what</span>() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span> <span style="color:#66d9ef">override</span> {<span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;&#34;</span>;}
|
||||
</span></span></code></pre></div><p>Returns the error message. Override when derived.</p></description></item><item><title>find.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/find/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/find/</guid><description><h1 id="findhpp">
|
||||
find.hpp
|
||||
<a class="anchor" href="#findhpp">#</a>
|
||||
</h1>
|
||||
<p>This function searches for a value in a <code>toml::value</code> and performs type conversion if necessary.</p>
|
||||
<blockquote class="book-hint info">
|
||||
<code>toml::value</code> can change the type it stores, and <code>toml::find</code> accommodates these types.
|
||||
Technically, all functions use <code>toml::basic_value&lt;TC&gt;</code>.
|
||||
However, for simplicity, we refer to it as <code>toml::value</code> in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter <code>TC</code> changes the type, assume that types like <code>toml::value::integer_type</code> will also change accordingly.
|
||||
</blockquote>
|
||||
|
||||
<h1 id="tomlfind">
|
||||
<code>toml::find</code>
|
||||
<a class="anchor" href="#tomlfind">#</a>
|
||||
</h1>
|
||||
<h2 id="overview">
|
||||
Overview
|
||||
<a class="anchor" href="#overview">#</a>
|
||||
</h2>
|
||||
<p><code>toml::find</code> uses template arguments for the type you want to retrieve and function arguments for the key of the value you want to find.</p></description></item><item><title>format.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/format/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/format/</guid><description><h1 id="formathpp">
|
||||
format.hpp
|
||||
<a class="anchor" href="#formathpp">#</a>
|
||||
</h1>
|
||||
<p>Defines structures and enumerations related to formatting information for <code>toml::value</code>.</p>
|
||||
<h1 id="indent_char">
|
||||
<code>indent_char</code>
|
||||
<a class="anchor" href="#indent_char">#</a>
|
||||
</h1>
|
||||
<p>An enumeration representing the indentation character choice.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">enum</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">indent_char</span> <span style="color:#f92672">:</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint8_t</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> space, <span style="color:#75715e">// use space
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> tab, <span style="color:#75715e">// use tab
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> none <span style="color:#75715e">// no indent
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>};
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;&lt;</span>(std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> os, <span style="color:#66d9ef">const</span> indent_char<span style="color:#f92672">&amp;</span> c);
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string to_string(<span style="color:#66d9ef">const</span> indent_char);
|
||||
</span></span></code></pre></div><p>Choosing <code>none</code> means no indentation is used, regardless of the value in super tables.</p>
|
||||
<p>If both <code>space</code> and <code>tab</code> are specified within the serializable value, the behavior is unspecified; typically, the unspecified indentation character appears.</p></description></item><item><title>from.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/from/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/from/</guid><description><h1 id="fromhpp">
|
||||
from.hpp
|
||||
<a class="anchor" href="#fromhpp">#</a>
|
||||
</h1>
|
||||
<p>Defines a <code>struct</code> used for conversion from <code>toml::value</code> in <code>toml::get</code> and <code>toml::find</code>.</p>
|
||||
<p>You can achieve the same functionality by adding a <code>from_toml</code> member function, but for classes where you cannot add member functions, use <code>from&lt;T&gt;</code>.</p>
|
||||
<p>This file does not provide specific implementations. Please specialize this <code>struct</code> when using.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">from</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="example">
|
||||
Example
|
||||
<a class="anchor" href="#example">#</a>
|
||||
</h2>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> extlib
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">foo</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">int</span> a;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string b;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// extlib
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e">#include</span> <span style="color:#75715e">&lt;toml11/from.hpp&gt;</span><span style="color:#75715e">
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">from</span><span style="color:#f92672">&lt;</span>extlib<span style="color:#f92672">::</span>foo<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">static</span> extlib<span style="color:#f92672">::</span>foo from_toml(<span style="color:#66d9ef">const</span> toml<span style="color:#f92672">::</span>basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span> v)
|
||||
</span></span><span style="display:flex;"><span> {
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> extlib<span style="color:#f92672">::</span>foo{toml<span style="color:#f92672">::</span>find<span style="color:#f92672">&lt;</span><span style="color:#66d9ef">int</span><span style="color:#f92672">&gt;</span>(v, <span style="color:#e6db74">&#34;a&#34;</span>), toml<span style="color:#f92672">::</span>find<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>string<span style="color:#f92672">&gt;</span>(v, <span style="color:#e6db74">&#34;b&#34;</span>)};
|
||||
</span></span><span style="display:flex;"><span> }
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h1 id="related">
|
||||
Related
|
||||
<a class="anchor" href="#related">#</a>
|
||||
</h1>
|
||||
<ul>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/conversion/">conversion.hpp</a></li>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/into/">into.hpp</a></li>
|
||||
</ul></description></item><item><title>get.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/get/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/get/</guid><description><h1 id="gethpp">
|
||||
get.hpp
|
||||
<a class="anchor" href="#gethpp">#</a>
|
||||
</h1>
|
||||
<p>These are functions for extracting values from <code>toml::value</code> and performing type conversions if necessary.</p>
|
||||
<blockquote class="book-hint info">
|
||||
<code>toml::value</code> can change the type it stores, and <code>toml::get</code> accommodates these types.
|
||||
Technically, all functions use <code>toml::basic_value&lt;TC&gt;</code>.
|
||||
However, for simplicity, we refer to it as <code>toml::value</code> in explanations unless a distinction is necessary.
|
||||
In the documentation, if the template parameter <code>TC</code> changes the type, assume that types like <code>toml::value::integer_type</code> will also change accordingly.
|
||||
</blockquote>
|
||||
|
||||
<h1 id="tomlgett">
|
||||
<code>toml::get&lt;T&gt;</code>
|
||||
<a class="anchor" href="#tomlgett">#</a>
|
||||
</h1>
|
||||
<h2 id="overview">
|
||||
Overview
|
||||
<a class="anchor" href="#overview">#</a>
|
||||
</h2>
|
||||
<p>Generally, <code>toml::get</code> behaves as follows:
|
||||
You specify <code>T</code> as in <code>toml::get&lt;int&gt;(v)</code>.</p></description></item><item><title>into.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/into/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/into/</guid><description><h1 id="intohpp">
|
||||
into.hpp
|
||||
<a class="anchor" href="#intohpp">#</a>
|
||||
</h1>
|
||||
<p>Defines a <code>struct</code> used for conversion from user-defined types into <code>toml::value</code> constructors.</p>
|
||||
<p>You can achieve the same functionality by adding an <code>into_toml</code> member function, but for classes where you cannot add member functions, use <code>into&lt;T&gt;</code>.</p>
|
||||
<p>This file does not provide specific implementations. Please specialize this <code>struct</code> when using.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">into</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="example">
|
||||
Example
|
||||
<a class="anchor" href="#example">#</a>
|
||||
</h2>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> extlib
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">foo</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">int</span> a;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string b;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// extlib
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e">#include</span> <span style="color:#75715e">&lt;toml11/into.hpp&gt;</span><span style="color:#75715e">
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">into</span><span style="color:#f92672">&lt;</span>extlib<span style="color:#f92672">::</span>foo<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">static</span> toml<span style="color:#f92672">::</span>basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;</span> into_toml(<span style="color:#66d9ef">const</span> extlib<span style="color:#f92672">::</span>foo<span style="color:#f92672">&amp;</span> f)
|
||||
</span></span><span style="display:flex;"><span> {
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> value_type <span style="color:#f92672">=</span> toml<span style="color:#f92672">::</span>basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> table_type <span style="color:#f92672">=</span> <span style="color:#66d9ef">typename</span> value_type<span style="color:#f92672">::</span>table_type;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">value_type</span>(table_type{{<span style="color:#e6db74">&#34;a&#34;</span>, f.a}, {<span style="color:#e6db74">&#34;b&#34;</span>, f.b}});
|
||||
</span></span><span style="display:flex;"><span> }
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h1 id="related">
|
||||
Related
|
||||
<a class="anchor" href="#related">#</a>
|
||||
</h1>
|
||||
<ul>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/conversion/">conversion.hpp</a></li>
|
||||
<li><a href="https://toruniina.github.io/toml11/docs/reference/from/">from.hpp</a></li>
|
||||
</ul></description></item><item><title>literal.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/literal/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/literal/</guid><description><h1 id="literalhpp">
|
||||
literal.hpp
|
||||
<a class="anchor" href="#literalhpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>literal.hpp</code>, the <code>_toml</code> literal is defined.</p>
|
||||
<p>The <code>_toml</code> literal parses string literals into <code>toml::value</code>.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">inline</span> <span style="color:#66d9ef">namespace</span> literals
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">inline</span> <span style="color:#66d9ef">namespace</span> toml_literals
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span>toml<span style="color:#f92672">::</span>value <span style="color:#66d9ef">operator</span><span style="color:#e6db74">&#34;&#34;</span> _toml(<span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span><span style="color:#f92672">*</span> str, std<span style="color:#f92672">::</span>size_t len);
|
||||
</span></span><span style="display:flex;"><span>toml<span style="color:#f92672">::</span>value <span style="color:#66d9ef">operator</span><span style="color:#e6db74">&#34;&#34;</span> _toml(<span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char8_t</span><span style="color:#f92672">*</span> str, std<span style="color:#f92672">::</span>size_t len); <span style="color:#75715e">// Available in C++20 and later
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} <span style="color:#75715e">// toml_literals
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} <span style="color:#75715e">// literals
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="free-functions">
|
||||
Free Functions
|
||||
<a class="anchor" href="#free-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="operator-_tomlconst-char">
|
||||
<code>operator&quot;&quot; _toml(const char*)</code>
|
||||
<a class="anchor" href="#operator-_tomlconst-char">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span>toml<span style="color:#f92672">::</span>value <span style="color:#66d9ef">operator</span><span style="color:#e6db74">&#34;&#34;</span> _toml(<span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span><span style="color:#f92672">*</span> str, std<span style="color:#f92672">::</span>size_t len);
|
||||
</span></span></code></pre></div><p>Converts a string literal into a <code>toml::value</code> by parsing it.</p></description></item><item><title>ordered_map.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/ordered_map/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/ordered_map/</guid><description><h1 id="ordered_maphpp">
|
||||
ordered_map.hpp
|
||||
<a class="anchor" href="#ordered_maphpp">#</a>
|
||||
</h1>
|
||||
<p>Defines <code>toml::ordered_map</code>, which is used to maintain the order of values in a file.</p>
|
||||
<h1 id="class-ordered_map">
|
||||
<code>class ordered_map</code>
|
||||
<a class="anchor" href="#class-ordered_map">#</a>
|
||||
</h1>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> Key, <span style="color:#66d9ef">typename</span> Val, <span style="color:#66d9ef">typename</span> Cmp <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span>equal_to<span style="color:#f92672">&lt;</span>Key<span style="color:#f92672">&gt;</span>,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">typename</span> Allocator <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span>allocator<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>pair<span style="color:#f92672">&lt;</span>Key, Val<span style="color:#f92672">&gt;&gt;&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">ordered_map</span>;
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><p>The <code>ordered_map</code> is a <code>map</code> type that preserves the insertion order of values, allowing iteration in that order.</p>
|
||||
<p>As a linear container, searches require <code>O(n)</code> time relative to the number of elements.
|
||||
Use this when search operations are infrequent and maintaining the order of values is important.</p></description></item><item><title>parser.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/parser/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/parser/</guid><description><h1 id="parserhpp">
|
||||
parser.hpp
|
||||
<a class="anchor" href="#parserhpp">#</a>
|
||||
</h1>
|
||||
<p>Defines functions for parsing files or strings and the exceptions they use.</p>
|
||||
<p>While <code>parse</code> throws an exception on failure, <code>try_parse</code> returns error information.</p>
|
||||
<h1 id="parse">
|
||||
<code>parse</code>
|
||||
<a class="anchor" href="#parse">#</a>
|
||||
</h1>
|
||||
<p>Parses the content of a given file and returns a <code>toml::basic_value</code>.</p>
|
||||
<p>In case of failure, <code>toml::syntax_error</code> is thrown.</p>
|
||||
<p>The type information of <code>basic_value</code> is provided by a <code>template</code>, and the TOML language version is specified by <code>toml::spec</code>.</p>
|
||||
<h3 id="parsestdstring-filename-tomlspec">
|
||||
<code>parse(std::string filename, toml::spec)</code>
|
||||
<a class="anchor" href="#parsestdstring-filename-tomlspec">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC <span style="color:#f92672">=</span> type_config<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>parse(std<span style="color:#f92672">::</span>string fname,
|
||||
</span></span><span style="display:flex;"><span> spec s <span style="color:#f92672">=</span> spec<span style="color:#f92672">::</span>default_version());
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><p>Parses the content of the given filename.</p></description></item><item><title>result.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/result/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/result/</guid><description><h1 id="resulthpp">
|
||||
result.hpp
|
||||
<a class="anchor" href="#resulthpp">#</a>
|
||||
</h1>
|
||||
<p><code>result.hpp</code> defines the <code>result</code> type, which can hold either a success value or a failure value.</p>
|
||||
<p>This is used as the return type for <code>toml::try_parse</code>, which does not throw exceptions.</p>
|
||||
<h1 id="success">
|
||||
success
|
||||
<a class="anchor" href="#success">#</a>
|
||||
</h1>
|
||||
<p>A type that holds a success value.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">success</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> value_type <span style="color:#f92672">=</span> T;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">explicit</span> <span style="color:#a6e22e">success</span>(value_type v);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#f92672">~</span>success() <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> success(<span style="color:#66d9ef">const</span> success<span style="color:#f92672">&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> success(success<span style="color:#f92672">&amp;&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> success<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">=</span>(<span style="color:#66d9ef">const</span> success<span style="color:#f92672">&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> success<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">=</span>(success<span style="color:#f92672">&amp;&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> U<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">explicit</span> success(U<span style="color:#f92672">&amp;&amp;</span> v);
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> U<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">explicit</span> success(success<span style="color:#f92672">&lt;</span>U<span style="color:#f92672">&gt;</span> v);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> value_type<span style="color:#f92672">&amp;</span> get() <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> value_type <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> get() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>success<span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> std<span style="color:#f92672">::</span>decay<span style="color:#f92672">&lt;</span>T<span style="color:#f92672">&gt;::</span>type<span style="color:#f92672">&gt;</span> ok(T<span style="color:#f92672">&amp;&amp;</span> v);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>size_t N<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>success<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>string<span style="color:#f92672">&gt;</span> ok(<span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span> (<span style="color:#f92672">&amp;</span>literal)[N])
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><h2 id="member-types">
|
||||
Member Types
|
||||
<a class="anchor" href="#member-types">#</a>
|
||||
</h2>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">using</span> value_type <span style="color:#f92672">=</span> T;
|
||||
</span></span></code></pre></div><p>The type of the success value.</p></description></item><item><title>serializer.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/serializer/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/serializer/</guid><description><h1 id="serializerhpp">
|
||||
serializer.hpp
|
||||
<a class="anchor" href="#serializerhpp">#</a>
|
||||
</h1>
|
||||
<h2 id="format">
|
||||
<code>format</code>
|
||||
<a class="anchor" href="#format">#</a>
|
||||
</h2>
|
||||
<p>Serializes the data.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format(<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span> v,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> spec s <span style="color:#f92672">=</span> spec<span style="color:#f92672">::</span>default_version());
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format(<span style="color:#66d9ef">const</span> <span style="color:#66d9ef">typename</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;::</span>key_type<span style="color:#f92672">&amp;</span> k,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span> v,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> spec s <span style="color:#f92672">=</span> spec<span style="color:#f92672">::</span>default_version());
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format(<span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>vector<span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;::</span>key_type<span style="color:#f92672">&gt;&amp;</span> ks,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span> v,
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">const</span> spec s <span style="color:#f92672">=</span> spec<span style="color:#f92672">::</span>default_version());
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><p>If there&rsquo;s a conflict between the format information and the <code>spec</code>, for example, when using <code>v1.0.0</code> with <code>table_format::multiline_oneline</code>, the <code>spec</code> takes precedence.</p></description></item><item><title>source_location.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/source_location/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/source_location/</guid><description><h1 id="source_locationhpp">
|
||||
source_location.hpp
|
||||
<a class="anchor" href="#source_locationhpp">#</a>
|
||||
</h1>
|
||||
<p><code>source_location.hpp</code> defines a class representing a specific area within a TOML file.</p>
|
||||
<p>This class is used to represent problematic areas in error messages.</p>
|
||||
<h1 id="tomlsource_location">
|
||||
<code>toml::source_location</code>
|
||||
<a class="anchor" href="#tomlsource_location">#</a>
|
||||
</h1>
|
||||
<p><code>source_location</code> is a class representing a specific area within a TOML file.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">source_location</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">public</span><span style="color:#f92672">:</span>
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">explicit</span> source_location(<span style="color:#75715e">/* implementation-defined */</span>);
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#f92672">~</span>source_location() <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> source_location(source_location <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> source_location(source_location <span style="color:#f92672">&amp;&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> source_location<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">=</span>(source_location <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span> source_location<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">=</span>(source_location <span style="color:#f92672">&amp;&amp;</span>) <span style="color:#f92672">=</span> <span style="color:#66d9ef">default</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">bool</span> <span style="color:#a6e22e">is_ok</span>() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t length() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t first_line_number() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t first_column_number() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t last_line_number() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t last_column_number() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> file_name() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>size_t num_lines() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> first_line() <span style="color:#66d9ef">const</span>;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>string <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> last_line() <span style="color:#66d9ef">const</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span>vector<span style="color:#f92672">&lt;</span>std<span style="color:#f92672">::</span>string<span style="color:#f92672">&gt;</span> <span style="color:#66d9ef">const</span><span style="color:#f92672">&amp;</span> lines() <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> ... Ts<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string format_location(<span style="color:#66d9ef">const</span> source_location<span style="color:#f92672">&amp;</span> loc, <span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>string<span style="color:#f92672">&amp;</span> msg, <span style="color:#66d9ef">const</span> Ts<span style="color:#f92672">&amp;</span> ... locs_and_msgs);
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">//toml
|
||||
</span></span></span></code></pre></div><h2 id="member-functions">
|
||||
Member Functions
|
||||
<a class="anchor" href="#member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="constructor">
|
||||
Constructor
|
||||
<a class="anchor" href="#constructor">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">explicit</span> <span style="color:#a6e22e">source_location</span>(<span style="color:#75715e">/* implementation-defined */</span>);
|
||||
</span></span></code></pre></div><p><code>toml::source_location</code> can only be constructed via <code>toml::parse</code> or the <code>_toml</code> literal.</p></description></item><item><title>spec.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/spec/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/spec/</guid><description><h1 id="spechpp">
|
||||
spec.hpp
|
||||
<a class="anchor" href="#spechpp">#</a>
|
||||
</h1>
|
||||
<p><code>spec.hpp</code> defines classes for specifying the version of TOML.</p>
|
||||
<h1 id="tomlsemantic_version">
|
||||
<code>toml::semantic_version</code>
|
||||
<a class="anchor" href="#tomlsemantic_version">#</a>
|
||||
</h1>
|
||||
<p><code>semantic_version</code> is a class that stores version information.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">semantic_version</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">constexpr</span> <span style="color:#a6e22e">semantic_version</span>(std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> mjr, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> mnr, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> p) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> major;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> minor;
|
||||
</span></span><span style="display:flex;"><span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> patch;
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> semantic_version
|
||||
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">make_semver</span>(std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> major, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> minor, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> patch) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">==</span>(<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">!=</span>(<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;</span> (<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;=</span>(<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&gt;</span> (<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&gt;=</span>(<span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span>) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;&lt;</span>(std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> os, <span style="color:#66d9ef">const</span> semantic_version<span style="color:#f92672">&amp;</span> ver);
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">//toml
|
||||
</span></span></span></code></pre></div><h2 id="member-functions">
|
||||
Member Functions
|
||||
<a class="anchor" href="#member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="constructor">
|
||||
Constructor
|
||||
<a class="anchor" href="#constructor">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">constexpr</span> <span style="color:#a6e22e">semantic_version</span>(std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> mjr, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> mnr, std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint32_t</span> p) <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span></code></pre></div><p>Constructs a <code>semantic_version</code> instance with the specified <code>major</code>, <code>minor</code>, and <code>patch</code> version numbers.</p></description></item><item><title>toml_fwd.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/toml_fwd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/toml_fwd/</guid><description><h1 id="toml_fwdhpp">
|
||||
toml_fwd.hpp
|
||||
<a class="anchor" href="#toml_fwdhpp">#</a>
|
||||
</h1>
|
||||
<p><code>toml_fwd.hpp</code> contains forward declarations of structures defined in toml11 and macro definitions.</p>
|
||||
<p>When only forward declarations of toml11 structures are needed and implementation is not required, including <code>toml_fwd.hpp</code> instead of <code>toml.hpp</code> can reduce compilation time.</p>
|
||||
<blockquote class="book-hint warning">
|
||||
Since this file only contains forward declarations, you cannot use <code>toml::table</code>, defined as <code>toml::basic_value&lt;toml::type_config&gt;::table_type</code>, and similarly defined <code>toml::array</code>. This is because they require the implementation of <code>basic_value</code>.
|
||||
</blockquote>
|
||||
|
||||
<p>This header file and <code>toml.hpp</code> are located under <code>${TOML11_INCLUDE_DIR}/</code>, while other header files are located under <code>${TOML11_INCLUDE_DIR}/toml11/</code>.</p></description></item><item><title>toml.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/toml/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/toml/</guid><description><h1 id="tomlhpp">
|
||||
toml.hpp
|
||||
<a class="anchor" href="#tomlhpp">#</a>
|
||||
</h1>
|
||||
<p><code>toml.hpp</code> includes all other headers.</p>
|
||||
<p>This allows access to all features of toml11.</p>
|
||||
<p>This header file and <code>toml_fwd.hpp</code> are located under <code>${TOML11_INCLUDE_DIR}/</code>,
|
||||
while other header files are located under <code>${toml11_include_dir}/toml11/</code>.</p></description></item><item><title>types.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/types/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/types/</guid><description><h1 id="typeshpp">
|
||||
types.hpp
|
||||
<a class="anchor" href="#typeshpp">#</a>
|
||||
</h1>
|
||||
<p>This document defines classes that specifies type information.</p>
|
||||
<h1 id="type_config">
|
||||
<code>type_config</code>
|
||||
<a class="anchor" href="#type_config">#</a>
|
||||
</h1>
|
||||
<p><code>type_config</code> is a type that encapsulates parameters given to <code>toml::basic_value</code>.</p>
|
||||
<p>When using different types within <code>toml::basic_value&lt;T&gt;</code>, you need to define and pass this type separately.
|
||||
All elements listed are required.</p>
|
||||
<p>If you use numerical types that cannot use standard stream operators, define and replace the equivalents for <code>read_int</code> and <code>read_float</code>.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">struct</span> <span style="color:#a6e22e">type_config</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> comment_type <span style="color:#f92672">=</span> preserve_comments;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> boolean_type <span style="color:#f92672">=</span> <span style="color:#66d9ef">bool</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> integer_type <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">int64_t</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> floating_type <span style="color:#f92672">=</span> <span style="color:#66d9ef">double</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> string_type <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span>string;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> array_type <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span>vector<span style="color:#f92672">&lt;</span>T<span style="color:#f92672">&gt;</span>;
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> K, <span style="color:#66d9ef">typename</span> T<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">using</span> table_type <span style="color:#f92672">=</span> std<span style="color:#f92672">::</span>unordered_map<span style="color:#f92672">&lt;</span>K, T<span style="color:#f92672">&gt;</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">static</span> result<span style="color:#f92672">&lt;</span>integer_type, error_info<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> parse_int(<span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>string<span style="color:#f92672">&amp;</span> str, <span style="color:#66d9ef">const</span> source_location src, <span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint8_t</span> base);
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">static</span> result<span style="color:#f92672">&lt;</span>floating_type, error_info<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span> parse_float(<span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>string<span style="color:#f92672">&amp;</span> str, <span style="color:#66d9ef">const</span> source_location src, <span style="color:#66d9ef">const</span> <span style="color:#66d9ef">bool</span> is_hex);
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">using</span> value <span style="color:#f92672">=</span> basic_value<span style="color:#f92672">&lt;</span>type_config<span style="color:#f92672">&gt;</span>;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">using</span> table <span style="color:#f92672">=</span> <span style="color:#66d9ef">typename</span> value<span style="color:#f92672">::</span>table_type;
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">using</span> array <span style="color:#f92672">=</span> <span style="color:#66d9ef">typename</span> value<span style="color:#f92672">::</span>array_type;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="static-member-functions">
|
||||
<code>static</code> Member Functions
|
||||
<a class="anchor" href="#static-member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="parse_intstr-src-base">
|
||||
<code>parse_int(str, src, base)</code>
|
||||
<a class="anchor" href="#parse_intstr-src-base">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">static</span> result<span style="color:#f92672">&lt;</span>integer_type, error_info<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span>parse_int(<span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span>string<span style="color:#f92672">&amp;</span> str, <span style="color:#66d9ef">const</span> source_location src, <span style="color:#66d9ef">const</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint8_t</span> base);
|
||||
</span></span></code></pre></div><p>If you use a type as <code>integer_type</code> that cannot utilize standard stream operators, implement this function.
|
||||
Otherwise, use <code>read_int</code> described later.</p></description></item><item><title>value_t.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/value_t/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/value_t/</guid><description><h1 id="value_thpp">
|
||||
value_t.hpp
|
||||
<a class="anchor" href="#value_thpp">#</a>
|
||||
</h1>
|
||||
<h1 id="value_t">
|
||||
<code>value_t</code>
|
||||
<a class="anchor" href="#value_t">#</a>
|
||||
</h1>
|
||||
<p><code>value_t</code> is used to handle the type information of <code>toml::value</code>.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">enum</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">value_t</span> <span style="color:#f92672">:</span> std<span style="color:#f92672">::</span><span style="color:#66d9ef">uint8_t</span>
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span> empty <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>,
|
||||
</span></span><span style="display:flex;"><span> boolean <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>,
|
||||
</span></span><span style="display:flex;"><span> integer <span style="color:#f92672">=</span> <span style="color:#ae81ff">2</span>,
|
||||
</span></span><span style="display:flex;"><span> floating <span style="color:#f92672">=</span> <span style="color:#ae81ff">3</span>,
|
||||
</span></span><span style="display:flex;"><span> string <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>,
|
||||
</span></span><span style="display:flex;"><span> offset_datetime <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>,
|
||||
</span></span><span style="display:flex;"><span> local_datetime <span style="color:#f92672">=</span> <span style="color:#ae81ff">6</span>,
|
||||
</span></span><span style="display:flex;"><span> local_date <span style="color:#f92672">=</span> <span style="color:#ae81ff">7</span>,
|
||||
</span></span><span style="display:flex;"><span> local_time <span style="color:#f92672">=</span> <span style="color:#ae81ff">8</span>,
|
||||
</span></span><span style="display:flex;"><span> array <span style="color:#f92672">=</span> <span style="color:#ae81ff">9</span>,
|
||||
</span></span><span style="display:flex;"><span> table <span style="color:#f92672">=</span> <span style="color:#ae81ff">10</span>
|
||||
</span></span><span style="display:flex;"><span>};
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;&lt;</span>(std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> os, value_t t);
|
||||
</span></span><span style="display:flex;"><span>std<span style="color:#f92672">::</span>string to_string(value_t t);
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">// toml
|
||||
</span></span></span></code></pre></div><h2 id="non-member-functions">
|
||||
Non-member Functions
|
||||
<a class="anchor" href="#non-member-functions">#</a>
|
||||
</h2>
|
||||
<h3 id="stream-operator">
|
||||
Stream Operator
|
||||
<a class="anchor" href="#stream-operator">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span>std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;&lt;</span>(std<span style="color:#f92672">::</span>ostream<span style="color:#f92672">&amp;</span> os, value_t t);
|
||||
</span></span></code></pre></div><p>Outputs the string representation of the <code>value_t</code> to the stream.</p></description></item><item><title>value.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/value/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/value/</guid><description><h1 id="valuehpp">
|
||||
value.hpp
|
||||
<a class="anchor" href="#valuehpp">#</a>
|
||||
</h1>
|
||||
<p><code>value.hpp</code> defines <code>basic_value</code>.</p>
|
||||
<h1 id="tomlbasic_value">
|
||||
<code>toml::basic_value</code>
|
||||
<a class="anchor" href="#tomlbasic_value">#</a>
|
||||
</h1>
|
||||
<p><code>basic_value</code> is a class that stores TOML values.</p>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span> <span style="color:#f92672">&lt;</span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">TypeConfig</span><span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">basic_value</span>;
|
||||
</span></span><span style="display:flex;"><span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Defined in types.hpp
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">// using value = basic_value&lt;type_config&gt;;
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">// using table = typename basic_value&lt;type_config&gt;::table_type;
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">// using array = typename basic_value&lt;type_config&gt;::array_type;
|
||||
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">==</span>(<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">!=</span>(<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;</span> (<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&lt;=</span>(<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&gt;</span> (<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> TC<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">bool</span> <span style="color:#66d9ef">operator</span><span style="color:#f92672">&gt;=</span>(<span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>, <span style="color:#66d9ef">const</span> basic_value<span style="color:#f92672">&lt;</span>TC<span style="color:#f92672">&gt;&amp;</span>);
|
||||
</span></span><span style="display:flex;"><span>} <span style="color:#75715e">//toml
|
||||
</span></span></span></code></pre></div><h2 id="member-types">
|
||||
Member Types
|
||||
<a class="anchor" href="#member-types">#</a>
|
||||
</h2>
|
||||
<p>The following member types are defined.</p></description></item><item><title>version.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/version/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/version/</guid><description><h1 id="versionhpp">
|
||||
version.hpp
|
||||
<a class="anchor" href="#versionhpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>version.hpp</code>, macros related to the version information of toml11 are defined.</p>
|
||||
<h2 id="macros">
|
||||
Macros
|
||||
<a class="anchor" href="#macros">#</a>
|
||||
</h2>
|
||||
<h3 id="toml11_version_major">
|
||||
<code>TOML11_VERSION_MAJOR</code>
|
||||
<a class="anchor" href="#toml11_version_major">#</a>
|
||||
</h3>
|
||||
<p>The major version of toml11.</p>
|
||||
<h3 id="toml11_version_minor">
|
||||
<code>TOML11_VERSION_MINOR</code>
|
||||
<a class="anchor" href="#toml11_version_minor">#</a>
|
||||
</h3>
|
||||
<p>The minor version of toml11.</p>
|
||||
<h3 id="toml11_version_patch">
|
||||
<code>TOML11_VERSION_PATCH</code>
|
||||
<a class="anchor" href="#toml11_version_patch">#</a>
|
||||
</h3>
|
||||
<p>The patch version of toml11.</p>
|
||||
<h2 id="function">
|
||||
Function
|
||||
<a class="anchor" href="#function">#</a>
|
||||
</h2>
|
||||
<h3 id="license_notice">
|
||||
<code>license_notice</code>
|
||||
<a class="anchor" href="#license_notice">#</a>
|
||||
</h3>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#66d9ef">char</span><span style="color:#f92672">*</span> <span style="color:#a6e22e">license_notice</span>() <span style="color:#66d9ef">noexcept</span>;
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><p>Returns the license notice.</p>
|
||||
<p>Provided for convenience when redistributing without source code.</p></description></item><item><title>visit.hpp</title><link>https://toruniina.github.io/toml11/docs/reference/visit/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://toruniina.github.io/toml11/docs/reference/visit/</guid><description><h1 id="visithpp">
|
||||
visit.hpp
|
||||
<a class="anchor" href="#visithpp">#</a>
|
||||
</h1>
|
||||
<p>In <code>visit.hpp</code>, <code>toml::visit</code> is defined.</p>
|
||||
<h1 id="tomlvisit">
|
||||
<code>toml::visit</code>
|
||||
<a class="anchor" href="#tomlvisit">#</a>
|
||||
</h1>
|
||||
<h2 id="functions">
|
||||
Functions
|
||||
<a class="anchor" href="#functions">#</a>
|
||||
</h2>
|
||||
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cpp" data-lang="cpp"><span style="display:flex;"><span><span style="color:#66d9ef">namespace</span> toml
|
||||
</span></span><span style="display:flex;"><span>{
|
||||
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">template</span><span style="color:#f92672">&lt;</span><span style="color:#66d9ef">typename</span> Visitor, <span style="color:#66d9ef">typename</span> ... Args<span style="color:#f92672">&gt;</span>
|
||||
</span></span><span style="display:flex;"><span><span style="color:#75715e">/* Return value when Visitor is called with a value of basic_value&lt;TC&gt; */</span>
|
||||
</span></span><span style="display:flex;"><span>visit(Visitor<span style="color:#f92672">&amp;&amp;</span> visitor, Args<span style="color:#f92672">&amp;&amp;</span> ... args);
|
||||
</span></span><span style="display:flex;"><span>}
|
||||
</span></span></code></pre></div><p><code>toml::visit</code> calls the overload of <code>Visitor</code> corresponding to the type held by <code>basic_value&lt;TC&gt;</code>, and returns the result.</p>
|
||||
<h4 id="requirements">
|
||||
Requirements
|
||||
<a class="anchor" href="#requirements">#</a>
|
||||
</h4>
|
||||
<p><code>Visitor</code> must be a function or function object callable with any type held by <code>basic_value&lt;TC&gt;</code>.</p></description></item></channel></rss>
|
||||
96
docs/reference/into/index.html
Normal file
96
docs/reference/into/index.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content='
|
||||
into.hpp
|
||||
#
|
||||
|
||||
Defines a struct used for conversion from user-defined types into toml::value constructors.
|
||||
You can achieve the same functionality by adding an into_toml member function, but for classes where you cannot add member functions, use into<T>.
|
||||
This file does not provide specific implementations. Please specialize this struct when using.
|
||||
namespace toml
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct into;
|
||||
|
||||
} // toml
|
||||
|
||||
Example
|
||||
#
|
||||
|
||||
namespace extlib
|
||||
{
|
||||
struct foo
|
||||
{
|
||||
int a;
|
||||
std::string b;
|
||||
};
|
||||
} // extlib
|
||||
|
||||
#include <toml11/into.hpp>
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template<>
|
||||
struct into<extlib::foo>
|
||||
{
|
||||
template<typename TC>
|
||||
static toml::basic_value<TC> into_toml(const extlib::foo& f)
|
||||
{
|
||||
using value_type = toml::basic_value<TC>;
|
||||
using table_type = typename value_type::table_type;
|
||||
return value_type(table_type{{"a", f.a}, {"b", f.b}});
|
||||
}
|
||||
};
|
||||
} // toml
|
||||
|
||||
Related
|
||||
#
|
||||
|
||||
|
||||
conversion.hpp
|
||||
from.hpp
|
||||
'><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/into/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="into.hpp"><meta property="og:description" content='into.hpp # Defines a struct used for conversion from user-defined types into toml::value constructors.
|
||||
You can achieve the same functionality by adding an into_toml member function, but for classes where you cannot add member functions, use into<T>.
|
||||
This file does not provide specific implementations. Please specialize this struct when using.
|
||||
namespace toml { template<typename T> struct into; } // toml Example # namespace extlib { struct foo { int a; std::string b; }; } // extlib #include <toml11/into.hpp> namespace toml { template<> struct into<extlib::foo> { template<typename TC> static toml::basic_value<TC> into_toml(const extlib::foo& f) { using value_type = toml::basic_value<TC>; using table_type = typename value_type::table_type; return value_type(table_type{{"a", f.a}, {"b", f.b}}); } }; } // toml Related # conversion.hpp from.hpp'><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>into.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/into/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/into/ title=into.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/into/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/ class=active>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>into.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#intohpp>into.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=intohpp>into.hpp
|
||||
<a class=anchor href=#intohpp>#</a></h1><p>Defines a <code>struct</code> used for conversion from user-defined types into <code>toml::value</code> constructors.</p><p>You can achieve the same functionality by adding an <code>into_toml</code> member function, but for classes where you cannot add member functions, use <code>into<T></code>.</p><p>This file does not provide specific implementations. Please specialize this <code>struct</code> when using.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>into</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> extlib
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>foo</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>int</span> a;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string b;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// extlib
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml11/into.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>into</span><span style=color:#f92672><</span>extlib<span style=color:#f92672>::</span>foo<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> toml<span style=color:#f92672>::</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span> into_toml(<span style=color:#66d9ef>const</span> extlib<span style=color:#f92672>::</span>foo<span style=color:#f92672>&</span> f)
|
||||
</span></span><span style=display:flex><span> {
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> table_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> value_type<span style=color:#f92672>::</span>table_type;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#a6e22e>value_type</span>(table_type{{<span style=color:#e6db74>"a"</span>, f.a}, {<span style=color:#e6db74>"b"</span>, f.b}});
|
||||
</span></span><span style=display:flex><span> }
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/from/>from.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#intohpp>into.hpp</a><ul><li><a href=#example>Example</a></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
69
docs/reference/literal/index.html
Normal file
69
docs/reference/literal/index.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content='
|
||||
literal.hpp
|
||||
#
|
||||
|
||||
In literal.hpp, the _toml literal is defined.
|
||||
The _toml literal parses string literals into toml::value.
|
||||
namespace toml
|
||||
{
|
||||
inline namespace literals
|
||||
{
|
||||
inline namespace toml_literals
|
||||
{
|
||||
toml::value operator"" _toml(const char* str, std::size_t len);
|
||||
toml::value operator"" _toml(const char8_t* str, std::size_t len); // Available in C++20 and later
|
||||
} // toml_literals
|
||||
} // literals
|
||||
} // toml
|
||||
|
||||
Free Functions
|
||||
#
|
||||
|
||||
|
||||
operator"" _toml(const char*)
|
||||
#
|
||||
|
||||
toml::value operator"" _toml(const char* str, std::size_t len);
|
||||
Converts a string literal into a toml::value by parsing it.'><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/literal/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="literal.hpp"><meta property="og:description" content='literal.hpp # In literal.hpp, the _toml literal is defined.
|
||||
The _toml literal parses string literals into toml::value.
|
||||
namespace toml { inline namespace literals { inline namespace toml_literals { toml::value operator"" _toml(const char* str, std::size_t len); toml::value operator"" _toml(const char8_t* str, std::size_t len); // Available in C++20 and later } // toml_literals } // literals } // toml Free Functions # operator"" _toml(const char*) # toml::value operator"" _toml(const char* str, std::size_t len); Converts a string literal into a toml::value by parsing it.'><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>literal.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/literal/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/literal/ title=literal.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/literal/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/ class=active>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>literal.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#literalhpp>literal.hpp</a><ul><li><a href=#free-functions>Free Functions</a><ul><li><a href=#operator-_tomlconst-char><code>operator"" _toml(const char*)</code></a></li><li><a href=#operator-_tomlconst-char8_t><code>operator"" _toml(const char8_t*)</code></a></li></ul></li></ul></li><li><a href=#example>Example</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=literalhpp>literal.hpp
|
||||
<a class=anchor href=#literalhpp>#</a></h1><p>In <code>literal.hpp</code>, the <code>_toml</code> literal is defined.</p><p>The <code>_toml</code> literal parses string literals into <code>toml::value</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>inline</span> <span style=color:#66d9ef>namespace</span> literals
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>inline</span> <span style=color:#66d9ef>namespace</span> toml_literals
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span>toml<span style=color:#f92672>::</span>value <span style=color:#66d9ef>operator</span><span style=color:#e6db74>""</span> _toml(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> str, std<span style=color:#f92672>::</span>size_t len);
|
||||
</span></span><span style=display:flex><span>toml<span style=color:#f92672>::</span>value <span style=color:#66d9ef>operator</span><span style=color:#e6db74>""</span> _toml(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char8_t</span><span style=color:#f92672>*</span> str, std<span style=color:#f92672>::</span>size_t len); <span style=color:#75715e>// Available in C++20 and later
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml_literals
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// literals
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=free-functions>Free Functions
|
||||
<a class=anchor href=#free-functions>#</a></h2><h3 id=operator-_tomlconst-char><code>operator"" _toml(const char*)</code>
|
||||
<a class=anchor href=#operator-_tomlconst-char>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>toml<span style=color:#f92672>::</span>value <span style=color:#66d9ef>operator</span><span style=color:#e6db74>""</span> _toml(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> str, std<span style=color:#f92672>::</span>size_t len);
|
||||
</span></span></code></pre></div><p>Converts a string literal into a <code>toml::value</code> by parsing it.</p><p>For typical TOML files, this performs equivalent parsing to <code>toml::parse</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v1 <span style=color:#f92672>=</span> <span style=color:#e6db74>"a = 'foo'"</span>_toml; <span style=color:#75715e>// v1: {a = 'foo'}
|
||||
</span></span></span></code></pre></div><p>When dealing with multiline content, raw string literal is convenient.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v1 <span style=color:#f92672>=</span> R<span style=color:#e6db74>"(</span>
|
||||
</span></span><span style=display:flex><span> a <span style=color:#f92672>=</span> <span style=color:#ae81ff>42</span>
|
||||
</span></span><span style=display:flex><span> b <span style=color:#f92672>=</span> <span style=color:#e6db74>"foo"</span>
|
||||
</span></span><span style=display:flex><span>)<span style=color:#e6db74>"_toml;</span>
|
||||
</span></span></code></pre></div><p>If the value is a standalone entity, it represents that value.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v2 <span style=color:#f92672>=</span> <span style=color:#e6db74>"'foo'"</span>_toml; <span style=color:#75715e>// v2: 'foo'
|
||||
</span></span></span></code></pre></div><p>TOML allows keys consisting solely of numbers. When distinguishing between table definitions and arrays is ambiguous (e.g., <code>[1]</code>), table definitions take precedence.</p><p>To interpret as an array, use a trailing comma.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v3 <span style=color:#f92672>=</span> <span style=color:#e6db74>"[1]"</span>_toml; <span style=color:#75715e>// v3: {1 = {}}
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v4 <span style=color:#f92672>=</span> <span style=color:#e6db74>"[1,]"</span>_toml; <span style=color:#75715e>// v4: [1,]
|
||||
</span></span></span></code></pre></div><h3 id=operator-_tomlconst-char8_t><code>operator"" _toml(const char8_t*)</code>
|
||||
<a class=anchor href=#operator-_tomlconst-char8_t>#</a></h3><p>Defined when <code>char8_t</code> is available. Otherwise identical in functionality, differing only in argument type.</p><h1 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> <span style=color:#66d9ef>namespace</span> toml<span style=color:#f92672>::</span>literals<span style=color:#f92672>::</span>toml_literals;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> v <span style=color:#f92672>=</span> <span style=color:#e6db74>"a = </span><span style=color:#ae81ff>\"</span><span style=color:#e6db74>foo</span><span style=color:#ae81ff>\"</span><span style=color:#e6db74>"</span>_toml;
|
||||
</span></span><span style=display:flex><span> assert(v.at(<span style=color:#e6db74>"a"</span>).as_string() <span style=color:#f92672>==</span> <span style=color:#e6db74>"foo"</span>);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#literalhpp>literal.hpp</a><ul><li><a href=#free-functions>Free Functions</a><ul><li><a href=#operator-_tomlconst-char><code>operator"" _toml(const char*)</code></a></li><li><a href=#operator-_tomlconst-char8_t><code>operator"" _toml(const char8_t*)</code></a></li></ul></li></ul></li><li><a href=#example>Example</a></li></ul></nav></div></aside></main></body></html>
|
||||
158
docs/reference/ordered_map/index.html
Normal file
158
docs/reference/ordered_map/index.html
Normal file
@@ -0,0 +1,158 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
ordered_map.hpp
|
||||
#
|
||||
|
||||
Defines toml::ordered_map, which is used to maintain the order of values in a file.
|
||||
|
||||
class ordered_map
|
||||
#
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template<typename Key, typename Val, typename Cmp = std::equal_to<Key>,
|
||||
typename Allocator = std::allocator<std::pair<Key, Val>>>
|
||||
class ordered_map;
|
||||
}
|
||||
The ordered_map is a map type that preserves the insertion order of values, allowing iteration in that order.
|
||||
As a linear container, searches require O(n) time relative to the number of elements.
|
||||
Use this when search operations are infrequent and maintaining the order of values is important."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/ordered_map/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="ordered_map.hpp"><meta property="og:description" content="ordered_map.hpp # Defines toml::ordered_map, which is used to maintain the order of values in a file.
|
||||
class ordered_map # namespace toml { template<typename Key, typename Val, typename Cmp = std::equal_to<Key>, typename Allocator = std::allocator<std::pair<Key, Val>>> class ordered_map; } The ordered_map is a map type that preserves the insertion order of values, allowing iteration in that order.
|
||||
As a linear container, searches require O(n) time relative to the number of elements. Use this when search operations are infrequent and maintaining the order of values is important."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>ordered_map.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/ordered_map/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/ordered_map/ title=ordered_map.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/ordered_map/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/ class=active>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>ordered_map.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#ordered_maphpp>ordered_map.hpp</a></li><li><a href=#class-ordered_map><code>class ordered_map</code></a><ul><li><a href=#non-member-types>Non-Member Types</a></li><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructors>Constructors</a></li><li><a href=#constructors-comparator-allocator>Constructors (Comparator, Allocator)</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#constructors-iterator>Constructors (Iterator)</a></li><li><a href=#constructors-stdinitializer_list>Constructors (std::initializer_list)</a></li><li><a href=#copy-and-move-assignment-operators>Copy and Move Assignment Operators</a></li><li><a href=#assignment-operator-stdinitializer_list>Assignment Operator (std::initializer_list)</a></li><li><a href=#destructor>Destructor</a></li><li><a href=#begin-end><code>begin()</code>, <code>end()</code></a></li><li><a href=#empty><code>empty()</code></a></li><li><a href=#size><code>size()</code></a></li><li><a href=#max_size><code>max_size()</code></a></li><li><a href=#clear><code>clear()</code></a></li><li><a href=#push_backkv><code>push_back(kv)</code></a></li><li><a href=#emplace_backk-v><code>emplace_back(k, v)</code></a></li><li><a href=#pop_back><code>pop_back()</code></a></li><li><a href=#insertkv><code>insert(kv)</code></a></li><li><a href=#emplacek-v><code>emplace(k, v)</code></a></li><li><a href=#countk><code>count(k)</code></a></li><li><a href=#containsk><code>contains(k)</code></a></li><li><a href=#findk><code>find(k)</code></a></li><li><a href=#atk><code>at(k)</code></a></li><li><a href=#operatork><code>operator[](k)</code></a></li><li><a href=#erase><code>erase(...)</code></a></li><li><a href=#key_comp><code>key_comp()</code></a></li></ul></li><li><a href=#notes>Notes</a><ul><li><a href=#key-modification>Key Modification</a></li><li><a href=#order-preservation-details>Order Preservation Details</a></li></ul></li><li><a href=#related>Related</a></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=ordered_maphpp>ordered_map.hpp
|
||||
<a class=anchor href=#ordered_maphpp>#</a></h1><p>Defines <code>toml::ordered_map</code>, which is used to maintain the order of values in a file.</p><h1 id=class-ordered_map><code>class ordered_map</code>
|
||||
<a class=anchor href=#class-ordered_map>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Key, <span style=color:#66d9ef>typename</span> Val, <span style=color:#66d9ef>typename</span> Cmp <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>equal_to<span style=color:#f92672><</span>Key<span style=color:#f92672>></span>,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>typename</span> Allocator <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>allocator<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>pair<span style=color:#f92672><</span>Key, Val<span style=color:#f92672>>>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>class</span> <span style=color:#a6e22e>ordered_map</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>The <code>ordered_map</code> is a <code>map</code> type that preserves the insertion order of values, allowing iteration in that order.</p><p>As a linear container, searches require <code>O(n)</code> time relative to the number of elements.
|
||||
Use this when search operations are infrequent and maintaining the order of values is important.</p><h2 id=non-member-types>Non-Member Types
|
||||
<a class=anchor href=#non-member-types>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>ordered_type_config</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_value <span style=color:#f92672>=</span> basic_value<span style=color:#f92672><</span>ordered_type_config<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_table <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> ordered_value<span style=color:#f92672>::</span>table_type;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_array <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> ordered_value<span style=color:#f92672>::</span>array_type;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Use these in place of <code>toml::type_config</code> and <code>toml::value</code>.</p><blockquote class="book-hint info"><p>Since <code>toml::parse</code> defaults to using <code>type_config</code>, specify</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>auto</span> input <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>parse<span style=color:#f92672><</span>toml<span style=color:#f92672>::</span>ordered_type_config<span style=color:#f92672>></span>(<span style=color:#e6db74>"input.toml"</span>);
|
||||
</span></span></code></pre></div><p>when parsing.</p></blockquote><h2 id=member-types>Member Types
|
||||
<a class=anchor href=#member-types>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>using</span> key_type <span style=color:#f92672>=</span> Key;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> mapped_type <span style=color:#f92672>=</span> Val;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>pair<span style=color:#f92672><</span>Key, Val<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> key_compare <span style=color:#f92672>=</span> Cmp;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> allocator_type <span style=color:#f92672>=</span> Allocator;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> container_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>value_type, Allocator<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> reference <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>reference;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> pointer <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>pointer;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> const_reference <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>const_reference;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> const_pointer <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>const_pointer;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> iterator <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>iterator;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> const_iterator <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>const_iterator;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> size_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>size_type;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> difference_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> container_type<span style=color:#f92672>::</span>difference_type;
|
||||
</span></span></code></pre></div><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=constructors>Constructors
|
||||
<a class=anchor href=#constructors>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>ordered_map() <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span></code></pre></div><p>Constructs an empty <code>ordered_map</code>.</p><h3 id=constructors-comparator-allocator>Constructors (Comparator, Allocator)
|
||||
<a class=anchor href=#constructors-comparator-allocator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>ordered_map</span>(<span style=color:#66d9ef>const</span> Cmp<span style=color:#f92672>&</span> cmp, <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc <span style=color:#f92672>=</span> Allocator());
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>ordered_map</span>(<span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc);
|
||||
</span></span></code></pre></div><p>Constructs an <code>ordered_map</code> with a specified comparator for key comparison and an allocator for memory management.</p><h3 id=copy-and-move-constructors>Copy and Move Constructors
|
||||
<a class=anchor href=#copy-and-move-constructors>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>ordered_map(<span style=color:#66d9ef>const</span> ordered_map<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>ordered_map(ordered_map<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>ordered_map(<span style=color:#66d9ef>const</span> ordered_map<span style=color:#f92672>&</span> other, <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc);
|
||||
</span></span><span style=display:flex><span>ordered_map(ordered_map<span style=color:#f92672>&&</span> other, <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc);
|
||||
</span></span></code></pre></div><p>Constructs an <code>ordered_map</code> by copying or moving the contents from another <code>ordered_map</code>.
|
||||
An allocator can also be specified for memory management.</p><h3 id=constructors-iterator>Constructors (Iterator)
|
||||
<a class=anchor href=#constructors-iterator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> InputIterator<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>ordered_map(InputIterator first, InputIterator last, <span style=color:#66d9ef>const</span> Cmp<span style=color:#f92672>&</span> cmp <span style=color:#f92672>=</span> Cmp(), <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc <span style=color:#f92672>=</span> Allocator());
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> InputIterator<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>ordered_map(InputIterator first, InputIterator last, <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc <span style=color:#f92672>=</span> Allocator());
|
||||
</span></span></code></pre></div><p>Constructs an <code>ordered_map</code> with a range represented by iterators.
|
||||
The order of the elements follows the order of the iterators.</p><h3 id=constructors-stdinitializer_list>Constructors (std::initializer_list)
|
||||
<a class=anchor href=#constructors-stdinitializer_list>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>ordered_map(std<span style=color:#f92672>::</span>initializer_list<span style=color:#f92672><</span>value_type<span style=color:#f92672>></span> v, <span style=color:#66d9ef>const</span> Cmp<span style=color:#f92672>&</span> cmp <span style=color:#f92672>=</span> Cmp(), <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc <span style=color:#f92672>=</span> Allocator());
|
||||
</span></span><span style=display:flex><span>ordered_map(std<span style=color:#f92672>::</span>initializer_list<span style=color:#f92672><</span>value_type<span style=color:#f92672>></span> v, <span style=color:#66d9ef>const</span> Allocator<span style=color:#f92672>&</span> alloc);
|
||||
</span></span></code></pre></div><p>Initializes the <code>ordered_map</code> using an initializer list.</p><h3 id=copy-and-move-assignment-operators>Copy and Move Assignment Operators
|
||||
<a class=anchor href=#copy-and-move-assignment-operators>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>ordered_map<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> ordered_map<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>ordered_map<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(ordered_map<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span></code></pre></div><p>Assigns the contents of another <code>ordered_map</code> to this one, using copy or move semantics.</p><h3 id=assignment-operator-stdinitializer_list>Assignment Operator (std::initializer_list)
|
||||
<a class=anchor href=#assignment-operator-stdinitializer_list>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>ordered_map<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(std<span style=color:#f92672>::</span>initializer_list<span style=color:#f92672><</span>value_type<span style=color:#f92672>></span> v);
|
||||
</span></span></code></pre></div><p>Assigns the contents of an initializer list to the <code>ordered_map</code>.</p><h3 id=destructor>Destructor
|
||||
<a class=anchor href=#destructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#f92672>~</span>ordered_map() <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span></code></pre></div><p>Destroys the <code>ordered_map</code>.</p><h3 id=begin-end><code>begin()</code>, <code>end()</code>
|
||||
<a class=anchor href=#begin-end>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>iterator <span style=color:#a6e22e>begin</span>() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>iterator <span style=color:#a6e22e>end</span>() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>const_iterator <span style=color:#a6e22e>begin</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>const_iterator <span style=color:#a6e22e>end</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>const_iterator <span style=color:#a6e22e>cbegin</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>const_iterator <span style=color:#a6e22e>cend</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns iterators to the beginning and end of the container, allowing iteration over its contents in order.</p><h3 id=empty><code>empty()</code>
|
||||
<a class=anchor href=#empty>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>empty</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if the <code>ordered_map</code> is empty, <code>false</code> otherwise.</p><h3 id=size><code>size()</code>
|
||||
<a class=anchor href=#size>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t size() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the number of elements in the <code>ordered_map</code>.</p><h3 id=max_size><code>max_size()</code>
|
||||
<a class=anchor href=#max_size>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t max_size() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the maximum number of elements the <code>ordered_map</code> can hold.</p><h3 id=clear><code>clear()</code>
|
||||
<a class=anchor href=#clear>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>clear</span>();
|
||||
</span></span></code></pre></div><p>Clears all elements from the <code>ordered_map</code>.</p><h3 id=push_backkv><code>push_back(kv)</code>
|
||||
<a class=anchor href=#push_backkv>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>push_back</span>(<span style=color:#66d9ef>const</span> value_type<span style=color:#f92672>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>push_back</span>(value_type<span style=color:#f92672>&&</span>);
|
||||
</span></span></code></pre></div><p>Appends a key-value pair to the end of the <code>ordered_map</code>.</p><h3 id=emplace_backk-v><code>emplace_back(k, v)</code>
|
||||
<a class=anchor href=#emplace_backk-v>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>emplace_back</span>(key_type, mapped_type);
|
||||
</span></span></code></pre></div><p>Appends a key-value pair to the end of the <code>ordered_map</code> by constructing it in place.</p><h3 id=pop_back><code>pop_back()</code>
|
||||
<a class=anchor href=#pop_back>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>pop_back</span>();
|
||||
</span></span></code></pre></div><p>Removes the last element from the <code>ordered_map</code>.</p><h3 id=insertkv><code>insert(kv)</code>
|
||||
<a class=anchor href=#insertkv>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>insert</span>(value_type);
|
||||
</span></span></code></pre></div><p>Inserts a key-value pair at the end of the <code>ordered_map</code>.</p><h3 id=emplacek-v><code>emplace(k, v)</code>
|
||||
<a class=anchor href=#emplacek-v>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>emplace</span>(key_type, mapped_type);
|
||||
</span></span></code></pre></div><p>Inserts a key-value pair at the end of the <code>ordered_map</code> by constructing it in place.</p><h3 id=countk><code>count(k)</code>
|
||||
<a class=anchor href=#countk>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t count(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the number of elements with the specified key.
|
||||
Since duplicate keys are not allowed, this will return either <code>1</code> if the key exists or <code>0</code> if it does not.</p><h3 id=containsk><code>contains(k)</code>
|
||||
<a class=anchor href=#containsk>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>contains</span>(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if the <code>ordered_map</code> contains an element with the specified key, <code>false</code> otherwise.</p><h3 id=findk><code>find(k)</code>
|
||||
<a class=anchor href=#findk>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>iterator <span style=color:#a6e22e>find</span>(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>const_iterator <span style=color:#a6e22e>find</span>(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Finds an element with the specified key and returns an iterator to it. If the key is not found, returns <code>end()</code>.</p><h3 id=atk><code>at(k)</code>
|
||||
<a class=anchor href=#atk>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>mapped_type<span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> k);
|
||||
</span></span><span style=display:flex><span>mapped_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> k) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Finds an element with the specified key and returns a reference to its value. Throws <code>std::out_of_range</code> if the key is not found.</p><h3 id=operatork><code>operator[](k)</code>
|
||||
<a class=anchor href=#operatork>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>mapped_type<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span>[](<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> k);
|
||||
</span></span><span style=display:flex><span>mapped_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span>[](<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> k) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Finds an element with the specified key and returns a reference to its value.
|
||||
If the key is not found, a new value is constructed and returned.
|
||||
If the <code>ordered_map</code> is <code>const</code>, throws <code>std::out_of_range</code> instead.</p><h3 id=erase><code>erase(...)</code>
|
||||
<a class=anchor href=#erase>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>iterator <span style=color:#a6e22e>erase</span>(iterator pos);
|
||||
</span></span><span style=display:flex><span>iterator <span style=color:#a6e22e>erase</span>(const_iterator pos);
|
||||
</span></span><span style=display:flex><span>iterator <span style=color:#a6e22e>erase</span>(const_iterator first, const_iterator last);
|
||||
</span></span><span style=display:flex><span>size_type <span style=color:#a6e22e>erase</span>(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key);
|
||||
</span></span></code></pre></div><p>Removes values pointed by an iterator or a value corresponding to a key.</p><h3 id=key_comp><code>key_comp()</code>
|
||||
<a class=anchor href=#key_comp>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>key_compare <span style=color:#a6e22e>key_comp</span>() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Returns the comparator used for key comparison.</p><h2 id=notes>Notes
|
||||
<a class=anchor href=#notes>#</a></h2><h3 id=key-modification>Key Modification
|
||||
<a class=anchor href=#key-modification>#</a></h3><blockquote class="book-hint warning"><p>Since <code>ordered_map</code> uses <code>std::pair<Key, Val></code> for <code>value_type</code>, it is possible to modify the key through an iterator. However, this practice is not recommended.</p><p>If you modify a key this way and it conflicts with an existing key, one of the conflicting keys will become unsearchable.</p><p>When using <code>operator[]</code>, <code>push_back</code>, or <code>insert</code>, collisions with existing keys are detected.</p></blockquote><h3 id=order-preservation-details>Order Preservation Details
|
||||
<a class=anchor href=#order-preservation-details>#</a></h3><blockquote class="book-hint warning"><p><code>ordered_map</code> maintains the order of keys, but this order preservation applies only to keys defined within the same table. Order across different tables is not maintained.</p><p>For example, the order in the following file will be preserved:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>apple.type <span style=color:#f92672>=</span> <span style=color:#e6db74>"fruit"</span>
|
||||
</span></span><span style=display:flex><span>apple.skin <span style=color:#f92672>=</span> <span style=color:#e6db74>"thin"</span>
|
||||
</span></span><span style=display:flex><span>apple.color <span style=color:#f92672>=</span> <span style=color:#e6db74>"red"</span>
|
||||
</span></span><span style=display:flex><span>orange.type <span style=color:#f92672>=</span> <span style=color:#e6db74>"fruit"</span>
|
||||
</span></span><span style=display:flex><span>orange.skin <span style=color:#f92672>=</span> <span style=color:#e6db74>"thick"</span>
|
||||
</span></span><span style=display:flex><span>orange.color <span style=color:#f92672>=</span> <span style=color:#e6db74>"orange"</span>
|
||||
</span></span></code></pre></div><p>In contrast, the order in the following file will not be preserved:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>apple.type <span style=color:#f92672>=</span> <span style=color:#e6db74>"fruit"</span>
|
||||
</span></span><span style=display:flex><span>orange.type <span style=color:#f92672>=</span> <span style=color:#e6db74>"fruit"</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>apple.skin <span style=color:#f92672>=</span> <span style=color:#e6db74>"thin"</span>
|
||||
</span></span><span style=display:flex><span>orange.skin <span style=color:#f92672>=</span> <span style=color:#e6db74>"thick"</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>apple.color <span style=color:#f92672>=</span> <span style=color:#e6db74>"red"</span>
|
||||
</span></span><span style=display:flex><span>orange.color <span style=color:#f92672>=</span> <span style=color:#e6db74>"orange"</span>
|
||||
</span></span></code></pre></div><p><code>ordered_map</code> preserves the order of the <code>apple</code> and <code>orange</code> definitions at the root table level, and the order of <code>type</code>, <code>skin</code>, <code>color</code> within each <code>apple</code> and <code>orange</code> table.</p></blockquote><h2 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h2><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/types/>types.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#ordered_maphpp>ordered_map.hpp</a></li><li><a href=#class-ordered_map><code>class ordered_map</code></a><ul><li><a href=#non-member-types>Non-Member Types</a></li><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructors>Constructors</a></li><li><a href=#constructors-comparator-allocator>Constructors (Comparator, Allocator)</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#constructors-iterator>Constructors (Iterator)</a></li><li><a href=#constructors-stdinitializer_list>Constructors (std::initializer_list)</a></li><li><a href=#copy-and-move-assignment-operators>Copy and Move Assignment Operators</a></li><li><a href=#assignment-operator-stdinitializer_list>Assignment Operator (std::initializer_list)</a></li><li><a href=#destructor>Destructor</a></li><li><a href=#begin-end><code>begin()</code>, <code>end()</code></a></li><li><a href=#empty><code>empty()</code></a></li><li><a href=#size><code>size()</code></a></li><li><a href=#max_size><code>max_size()</code></a></li><li><a href=#clear><code>clear()</code></a></li><li><a href=#push_backkv><code>push_back(kv)</code></a></li><li><a href=#emplace_backk-v><code>emplace_back(k, v)</code></a></li><li><a href=#pop_back><code>pop_back()</code></a></li><li><a href=#insertkv><code>insert(kv)</code></a></li><li><a href=#emplacek-v><code>emplace(k, v)</code></a></li><li><a href=#countk><code>count(k)</code></a></li><li><a href=#containsk><code>contains(k)</code></a></li><li><a href=#findk><code>find(k)</code></a></li><li><a href=#atk><code>at(k)</code></a></li><li><a href=#operatork><code>operator[](k)</code></a></li><li><a href=#erase><code>erase(...)</code></a></li><li><a href=#key_comp><code>key_comp()</code></a></li></ul></li><li><a href=#notes>Notes</a><ul><li><a href=#key-modification>Key Modification</a></li><li><a href=#order-preservation-details>Order Preservation Details</a></li></ul></li><li><a href=#related>Related</a></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
197
docs/reference/parser/index.html
Normal file
197
docs/reference/parser/index.html
Normal file
@@ -0,0 +1,197 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
parser.hpp
|
||||
#
|
||||
|
||||
Defines functions for parsing files or strings and the exceptions they use.
|
||||
While parse throws an exception on failure, try_parse returns error information.
|
||||
|
||||
parse
|
||||
#
|
||||
|
||||
Parses the content of a given file and returns a toml::basic_value.
|
||||
In case of failure, toml::syntax_error is thrown.
|
||||
The type information of basic_value is provided by a template, and the TOML language version is specified by toml::spec.
|
||||
|
||||
parse(std::string filename, toml::spec)
|
||||
#
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template<typename TC = type_config>
|
||||
basic_value<TC>
|
||||
parse(std::string fname,
|
||||
spec s = spec::default_version());
|
||||
}
|
||||
Parses the content of the given filename."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/parser/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="parser.hpp"><meta property="og:description" content="parser.hpp # Defines functions for parsing files or strings and the exceptions they use.
|
||||
While parse throws an exception on failure, try_parse returns error information.
|
||||
parse # Parses the content of a given file and returns a toml::basic_value.
|
||||
In case of failure, toml::syntax_error is thrown.
|
||||
The type information of basic_value is provided by a template, and the TOML language version is specified by toml::spec.
|
||||
parse(std::string filename, toml::spec) # namespace toml { template<typename TC = type_config> basic_value<TC> parse(std::string fname, spec s = spec::default_version()); } Parses the content of the given filename."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>parser.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/parser/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/parser/ title=parser.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/parser/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/ class=active>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>parser.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#parserhpp>parser.hpp</a></li><li><a href=#parse><code>parse</code></a><ul><li><ul><li><a href=#parsestdstring-filename-tomlspec><code>parse(std::string filename, toml::spec)</code></a></li><li><a href=#parseconst-char-n-filename-tomlspec><code>parse(const char (&)[N] filename, toml::spec)</code></a></li><li><a href=#parsestdfilesystempath-tomlspec><code>parse(std::filesystem::path, toml::spec)</code></a></li><li><a href=#parsestdistream-stdstring-filename-tomlspec><code>parse(std::istream&, std::string filename, toml::spec)</code></a></li><li><a href=#parsefile-stdstring-filename-tomlspec><code>parse(FILE*, std::string filename, toml::spec)</code></a></li><li><a href=#parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>parse(std::vector<unsigned char>, std::string filename, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#parse_str><code>parse_str</code></a><ul><li><ul><li><a href=#parse_strstdstring-tomlspec><code>parse_str(std::string, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#try_parse><code>try_parse</code></a><ul><li><ul><li><a href=#try_parsestdstring-filename-tomlspec><code>try_parse(std::string filename, toml::spec)</code></a></li><li><a href=#try_parseconst-char-n-filename-tomlspec><code>try_parse(const char (&)[N] filename, toml::spec)</code></a></li><li><a href=#try_parsestdfilesystempath-tomlspec><code>try_parse(std::filesystem::path, toml::spec)</code></a></li><li><a href=#try_parsestdistream-stdstring-filename-tomlspec><code>try_parse(std::istream&, std::string filename, toml::spec)</code></a></li><li><a href=#try_parsefile-stdstring-filename-tomlspec><code>try_parse(FILE*, std::string filename, toml::spec)</code></a></li><li><a href=#try_parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>try_parse(std::vector<unsigned char>, std::string filename, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#try_parse_str><code>try_parse_str</code></a><ul><li><ul><li><a href=#try_parse_strstdstring-tomlspec><code>try_parse_str(std::string, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#syntax_error><code>syntax_error</code></a></li><li><a href=#file_io_error><code>file_io_error</code></a><ul><li><ul><li><a href=#has_errno><code>has_errno</code></a></li><li><a href=#get_errno><code>get_errno</code></a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=parserhpp>parser.hpp
|
||||
<a class=anchor href=#parserhpp>#</a></h1><p>Defines functions for parsing files or strings and the exceptions they use.</p><p>While <code>parse</code> throws an exception on failure, <code>try_parse</code> returns error information.</p><h1 id=parse><code>parse</code>
|
||||
<a class=anchor href=#parse>#</a></h1><p>Parses the content of a given file and returns a <code>toml::basic_value</code>.</p><p>In case of failure, <code>toml::syntax_error</code> is thrown.</p><p>The type information of <code>basic_value</code> is provided by a <code>template</code>, and the TOML language version is specified by <code>toml::spec</code>.</p><h3 id=parsestdstring-filename-tomlspec><code>parse(std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#parsestdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse(std<span style=color:#f92672>::</span>string fname,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses the content of the given filename.</p><p>If reading the file fails, <code>toml::file_io_error</code> is thrown.</p><p>If parsing fails, <code>toml::syntax_error</code> is thrown.</p><h3 id=parseconst-char-n-filename-tomlspec><code>parse(const char (&)[N] filename, toml::spec)</code>
|
||||
<a class=anchor href=#parseconst-char-n-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config, std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>fname)[N],
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses the content of the given filename from a string literal.</p><p>If reading the file fails, <code>toml::file_io_error</code> is thrown.</p><p>If parsing fails, <code>toml::syntax_error</code> is thrown.</p><h3 id=parsestdfilesystempath-tomlspec><code>parse(std::filesystem::path, toml::spec)</code>
|
||||
<a class=anchor href=#parsestdfilesystempath-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>filesystem<span style=color:#f92672>::</span>path<span style=color:#f92672>&</span> fpath,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>This is defined only if <code><filesystem></code> is available.</p><p>Parses the content of the file at the given file path.</p><p>If reading the file fails, <code>toml::file_io_error</code> is thrown.</p><p>If parsing fails, <code>toml::syntax_error</code> is thrown.</p><h3 id=parsestdistream-stdstring-filename-tomlspec><code>parse(std::istream&, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#parsestdistream-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse(std<span style=color:#f92672>::</span>istream<span style=color:#f92672>&</span> is,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string fname <span style=color:#f92672>=</span> <span style=color:#e6db74>"unknown file"</span>,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses the content of the given <code>std::istream&</code>.</p><p>Open a stream in binary mode by passing <code>std::ios::binary</code> to avoid inconsistency between the file size and the number of characters due to automatic conversion of newline characters by the standard library.</p><p>The filename information is taken as the second argument. If the filename is not provided, it defaults to <code>"unknown file"</code>.</p><h3 id=parsefile-stdstring-filename-tomlspec><code>parse(FILE*, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#parsefile-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>parse(FILE<span style=color:#f92672>*</span> fp,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string filename,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses the content of the file pointed to by <code>FILE*</code>.</p><p>Open a stream in binary mode by passing <code>"rb"</code> to avoid inconsistency between the file size and the number of characters due to automatic conversion of newline characters by the standard library.</p><p>If reading the file fails, <code>file_io_error</code> containing <code>errno</code> is thrown.</p><p>If parsing fails, <code>syntax_error</code> is thrown.</p><h3 id=parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>parse(std::vector<unsigned char>, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#parsestdvectorunsigned-char-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse(std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span><span style=color:#66d9ef>unsigned</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>></span> content,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string filename,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses the byte sequence as a TOML file.</p><p>If parsing fails, <code>toml::syntax_error</code> is thrown.</p><h1 id=parse_str><code>parse_str</code>
|
||||
<a class=anchor href=#parse_str>#</a></h1><h3 id=parse_strstdstring-tomlspec><code>parse_str(std::string, toml::spec)</code>
|
||||
<a class=anchor href=#parse_strstdstring-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse_str(std<span style=color:#f92672>::</span>string content,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version(),
|
||||
</span></span><span style=display:flex><span> cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses a string as a TOML file.</p><p>In case of failure, <code>toml::syntax_error</code> is thrown.</p><p>The type information of <code>basic_value</code> is provided by a <code>template</code>, and the TOML language version is specified by <code>toml::spec</code>.</p><p>You generally don’t need to manually set the third argument, <code>cxx::source_location</code>.
|
||||
If <code>std::source_location</code>, <code>std::experimental::source_location</code>, or <code>__builtin_FILE</code> is available,
|
||||
the location information where <code>parse_str</code> was called will be stored.</p><h1 id=try_parse><code>try_parse</code>
|
||||
<a class=anchor href=#try_parse>#</a></h1><p>Parses the contents of the given file and returns a <code>toml::basic_value</code> if successful, or a <code>std::vector<toml::error_info></code> if it fails.</p><p>The type information of <code>basic_value</code> is specified by <code>template</code>, and the version of the TOML language is specified by <code>toml::spec</code>.</p><blockquote class="book-hint warning"><p>Unlike <code>parse</code>, <code>try_parse</code> does not throw exceptions defined in toml11 such as <code>syntax_error</code>.
|
||||
However, please note that exceptions thrown by the standard library will still propagate.</p><p>For instance, errors occurring internally within <code>std::ifstream</code> or memory exhaustion in <code>std::vector</code> will throw exceptions.</p></blockquote><h3 id=try_parsestdstring-filename-tomlspec><code>try_parse(std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#try_parsestdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(std<span style=color:#f92672>::</span>string fname,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a file name and parses its content.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h3 id=try_parseconst-char-n-filename-tomlspec><code>try_parse(const char (&)[N] filename, toml::spec)</code>
|
||||
<a class=anchor href=#try_parseconst-char-n-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config, std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>fname)[N],
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a string literal as a file name and parses its content.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h3 id=try_parsestdfilesystempath-tomlspec><code>try_parse(std::filesystem::path, toml::spec)</code>
|
||||
<a class=anchor href=#try_parsestdfilesystempath-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>filesystem<span style=color:#f92672>::</span>path<span style=color:#f92672>&</span> fpath,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a file path and parses its content.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h3 id=try_parsestdistream-stdstring-filename-tomlspec><code>try_parse(std::istream&, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#try_parsestdistream-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(std<span style=color:#f92672>::</span>istream<span style=color:#f92672>&</span> is,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string fname <span style=color:#f92672>=</span> <span style=color:#e6db74>"unknown file"</span>,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a <code>std::istream&</code> and parses its content.</p><p>Open a stream in binary mode by passing <code>std::ios::binary</code> to avoid inconsistency between the file size and the number of characters due to automatic conversion of newline characters by the standard library.</p><p>The file name information is taken as the second argument. If a file name is not provided, it defaults to <code>"unknown file"</code>.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h3 id=try_parsefile-stdstring-filename-tomlspec><code>try_parse(FILE*, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#try_parsefile-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(FILE<span style=color:#f92672>*</span> fp,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string filename,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a <code>FILE*</code> and parses its content.</p><p>Open a stream in binary mode by passing <code>"rb"</code> to avoid inconsistency between the file size and the number of characters due to automatic conversion of newline characters by the standard library.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h3 id=try_parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>try_parse(std::vector<unsigned char>, std::string filename, toml::spec)</code>
|
||||
<a class=anchor href=#try_parsestdvectorunsigned-char-stdstring-filename-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse(std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span><span style=color:#66d9ef>unsigned</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>></span> content,
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string filename,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Takes a byte array and parses its content as a TOML file.</p><p>If parsing fails, a <code>result</code> holding the error type <code>std::vector<error_info></code> is returned.</p><p>If successful, a <code>result</code> holding a <code>basic_value</code> is returned.</p><h1 id=try_parse_str><code>try_parse_str</code>
|
||||
<a class=anchor href=#try_parse_str>#</a></h1><h3 id=try_parse_strstdstring-tomlspec><code>try_parse_str(std::string, toml::spec)</code>
|
||||
<a class=anchor href=#try_parse_strstdstring-tomlspec>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC <span style=color:#f92672>=</span> type_config<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>></span>, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>try_parse_str(std<span style=color:#f92672>::</span>string content,
|
||||
</span></span><span style=display:flex><span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version(),
|
||||
</span></span><span style=display:flex><span> cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Parses a string as a TOML file, returning a <code>toml::basic_value</code> if successful, or a <code>std::vector<toml::error_info></code> if it fails.</p><p>Unlike <code>parse_str</code>, it does not throw <code>syntax_error</code>, but instead returns error information as the failure type of the <code>result</code>.</p><p>If <code>std::source_location</code>, <code>std::experimental::source_location</code>, or <code>__builtin_FILE</code> is available, it will record the location information.</p><p>Typically, you do not need to manually set the third argument <code>cxx::source_location</code>. If any of <code>std::source_location</code>, <code>std::experimental::source_location</code>, or <code>__builtin_FILE</code> are available, the information of the location where <code>parse_str</code> was called will be saved as the location information.</p><blockquote class="book-hint warning"><p>Unlike <code>parse</code>, <code>try_parse</code> does not throw exceptions defined in toml11 such as <code>syntax_error</code>. However, please note that exceptions thrown by the standard library will still propagate.</p><p>For instance, errors occurring internally within <code>std::ifstream</code> or memory exhaustion in <code>std::vector</code> will throw exceptions.</p></blockquote><h1 id=syntax_error><code>syntax_error</code>
|
||||
<a class=anchor href=#syntax_error>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>syntax_error</span> <span style=color:#66d9ef>final</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> <span style=color:#f92672>::</span>toml<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> syntax_error(std<span style=color:#f92672>::</span>string what_arg, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>></span> err);
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>syntax_error() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>error_info<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> errors() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>An exception thrown when a syntax error is detected in TOML.</p><p>It is thrown by <code>parse</code> but not by <code>try_parse</code>.</p><h1 id=file_io_error><code>file_io_error</code>
|
||||
<a class=anchor href=#file_io_error>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>file_io_error</span> <span style=color:#66d9ef>final</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> <span style=color:#f92672>::</span>toml<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> file_io_error(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> msg, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> fname);
|
||||
</span></span><span style=display:flex><span> file_io_error(<span style=color:#66d9ef>int</span> errnum, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> msg, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> fname);
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>file_io_error() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>has_errno</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>int</span> <span style=color:#a6e22e>get_errno</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>An exception thrown when reading the contents of a file fails.</p><p>When using <code>FILE*</code> to read a file, <code>errno</code> is set.</p><h3 id=has_errno><code>has_errno</code>
|
||||
<a class=anchor href=#has_errno>#</a></h3><p>If <code>std::ifstream</code> fails, <code>errno</code> is not set.</p><p>In this case, <code>has_errno</code> returns <code>false</code>.</p><h3 id=get_errno><code>get_errno</code>
|
||||
<a class=anchor href=#get_errno>#</a></h3><p>Particularly when passing a <code>FILE*</code>, retrieves the value of <code>errno</code>.</p><p>If <code>has_errno</code> is <code>false</code>, it returns <code>0</code>.</p><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/result/>result.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#parserhpp>parser.hpp</a></li><li><a href=#parse><code>parse</code></a><ul><li><ul><li><a href=#parsestdstring-filename-tomlspec><code>parse(std::string filename, toml::spec)</code></a></li><li><a href=#parseconst-char-n-filename-tomlspec><code>parse(const char (&)[N] filename, toml::spec)</code></a></li><li><a href=#parsestdfilesystempath-tomlspec><code>parse(std::filesystem::path, toml::spec)</code></a></li><li><a href=#parsestdistream-stdstring-filename-tomlspec><code>parse(std::istream&, std::string filename, toml::spec)</code></a></li><li><a href=#parsefile-stdstring-filename-tomlspec><code>parse(FILE*, std::string filename, toml::spec)</code></a></li><li><a href=#parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>parse(std::vector<unsigned char>, std::string filename, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#parse_str><code>parse_str</code></a><ul><li><ul><li><a href=#parse_strstdstring-tomlspec><code>parse_str(std::string, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#try_parse><code>try_parse</code></a><ul><li><ul><li><a href=#try_parsestdstring-filename-tomlspec><code>try_parse(std::string filename, toml::spec)</code></a></li><li><a href=#try_parseconst-char-n-filename-tomlspec><code>try_parse(const char (&)[N] filename, toml::spec)</code></a></li><li><a href=#try_parsestdfilesystempath-tomlspec><code>try_parse(std::filesystem::path, toml::spec)</code></a></li><li><a href=#try_parsestdistream-stdstring-filename-tomlspec><code>try_parse(std::istream&, std::string filename, toml::spec)</code></a></li><li><a href=#try_parsefile-stdstring-filename-tomlspec><code>try_parse(FILE*, std::string filename, toml::spec)</code></a></li><li><a href=#try_parsestdvectorunsigned-char-stdstring-filename-tomlspec><code>try_parse(std::vector<unsigned char>, std::string filename, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#try_parse_str><code>try_parse_str</code></a><ul><li><ul><li><a href=#try_parse_strstdstring-tomlspec><code>try_parse_str(std::string, toml::spec)</code></a></li></ul></li></ul></li><li><a href=#syntax_error><code>syntax_error</code></a></li><li><a href=#file_io_error><code>file_io_error</code></a><ul><li><ul><li><a href=#has_errno><code>has_errno</code></a></li><li><a href=#get_errno><code>get_errno</code></a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
313
docs/reference/result/index.html
Normal file
313
docs/reference/result/index.html
Normal file
@@ -0,0 +1,313 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
result.hpp
|
||||
#
|
||||
|
||||
result.hpp defines the result type, which can hold either a success value or a failure value.
|
||||
This is used as the return type for toml::try_parse, which does not throw exceptions.
|
||||
|
||||
success
|
||||
#
|
||||
|
||||
A type that holds a success value.
|
||||
namespace toml
|
||||
{
|
||||
template<typename T>
|
||||
struct success
|
||||
{
|
||||
using value_type = T;
|
||||
|
||||
explicit success(value_type v);
|
||||
|
||||
~success() = default;
|
||||
success(const success&) = default;
|
||||
success(success&&) = default;
|
||||
success& operator=(const success&) = default;
|
||||
success& operator=(success&&) = default;
|
||||
|
||||
template<typename U>
|
||||
explicit success(U&& v);
|
||||
template<typename U>
|
||||
explicit success(success<U> v);
|
||||
|
||||
value_type& get() noexcept;
|
||||
value_type const& get() const noexcept;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
success<typename std::decay<T>::type> ok(T&& v);
|
||||
template<std::size_t N>
|
||||
success<std::string> ok(const char (&literal)[N])
|
||||
}
|
||||
|
||||
Member Types
|
||||
#
|
||||
|
||||
using value_type = T;
|
||||
The type of the success value."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/result/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="result.hpp"><meta property="og:description" content="result.hpp # result.hpp defines the result type, which can hold either a success value or a failure value.
|
||||
This is used as the return type for toml::try_parse, which does not throw exceptions.
|
||||
success # A type that holds a success value.
|
||||
namespace toml { template<typename T> struct success { using value_type = T; explicit success(value_type v); ~success() = default; success(const success&) = default; success(success&&) = default; success& operator=(const success&) = default; success& operator=(success&&) = default; template<typename U> explicit success(U&& v); template<typename U> explicit success(success<U> v); value_type& get() noexcept; value_type const& get() const noexcept; }; template<typename T> success<typename std::decay<T>::type> ok(T&& v); template<std::size_t N> success<std::string> ok(const char (&literal)[N]) } Member Types # using value_type = T; The type of the success value."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>result.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/result/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/result/ title=result.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/result/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/ class=active>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>result.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#resulthpp>result.hpp</a></li><li><a href=#success>success</a><ul><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li><li><a href=#get><code>get()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#okt><code>ok(T)</code></a></li></ul></li></ul></li><li><a href=#successreference_wrappert><code>success<reference_wrapper<T>></code></a><ul><li><a href=#member-types-1>Member Types</a><ul><li><a href=#get-1><code>get()</code></a></li></ul></li></ul></li><li><a href=#failure>failure</a><ul><li><a href=#member-types-2>Member Types</a></li><li><a href=#member-functions-1>Member Functions</a><ul><li><a href=#constructor-1>Constructor</a></li><li><a href=#get-2><code>get()</code></a></li></ul></li><li><a href=#non-member-functions-1>Non-Member Functions</a><ul><li><a href=#errt><code>err(T)</code></a></li></ul></li></ul></li><li><a href=#failurereference_wrappert><code>failure<reference_wrapper<T>></code></a><ul><li><a href=#member-types-3>Member Types</a><ul><li><a href=#get-3><code>get()</code></a></li></ul></li></ul></li><li><a href=#result>result</a><ul><li><a href=#member-types-4>Member Types</a><ul><li><a href=#success_type><code>success_type</code></a></li><li><a href=#failure_type><code>failure_type</code></a></li><li><a href=#value_type><code>value_type</code></a></li><li><a href=#error_type><code>error_type</code></a></li></ul></li><li><a href=#member-functions-2>Member Functions</a><ul><li><a href=#constructor-2>Constructor</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#operator><code>operator=</code></a></li><li><a href=#is_ok><code>is_ok()</code></a></li><li><a href=#is_err><code>is_err()</code></a></li><li><a href=#operator-bool><code>operator bool()</code></a></li><li><a href=#unwrap><code>unwrap()</code></a></li><li><a href=#unwrap_or><code>unwrap_or()</code></a></li><li><a href=#unwrap_err><code>unwrap_err()</code></a></li><li><a href=#as_ok><code>as_ok()</code></a></li><li><a href=#as_err><code>as_err()</code></a></li></ul></li></ul></li><li><a href=#bad_result_access>bad_result_access</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=resulthpp>result.hpp
|
||||
<a class=anchor href=#resulthpp>#</a></h1><p><code>result.hpp</code> defines the <code>result</code> type, which can hold either a success value or a failure value.</p><p>This is used as the return type for <code>toml::try_parse</code>, which does not throw exceptions.</p><h1 id=success>success
|
||||
<a class=anchor href=#success>#</a></h1><p>A type that holds a success value.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>success</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>success</span>(value_type v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>success() <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> success(<span style=color:#66d9ef>const</span> success<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> success(success<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> success<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> success<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> success<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(success<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> success(U<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> success(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>success<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>decay<span style=color:#f92672><</span>T<span style=color:#f92672>>::</span>type<span style=color:#f92672>></span> ok(T<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>success<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> ok(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>literal)[N])
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-types>Member Types
|
||||
<a class=anchor href=#member-types>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span></code></pre></div><p>The type of the success value.</p><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=constructor>Constructor
|
||||
<a class=anchor href=#constructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>success</span>(value_type v);
|
||||
</span></span></code></pre></div><p>Constructs with a <code>value_type</code> argument.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>explicit</span> success(U<span style=color:#f92672>&&</span> v);
|
||||
</span></span></code></pre></div><p>Constructs with another type that can be converted to <code>value_type</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>explicit</span> success(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> v);
|
||||
</span></span></code></pre></div><p>Constructs with another <code>success</code> type that can be converted to <code>value_type</code>.</p><h3 id=get><code>get()</code>
|
||||
<a class=anchor href=#get>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Accesses the stored value.</p><h2 id=non-member-functions>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=okt><code>ok(T)</code>
|
||||
<a class=anchor href=#okt>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>success<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>decay<span style=color:#f92672><</span>T<span style=color:#f92672>>::</span>type<span style=color:#f92672>></span> ok(T<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>success<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> ok(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>literal)[N]);
|
||||
</span></span></code></pre></div><p>Constructs and returns a <code>success</code> type from a success value.</p><p>Converts a string literal into <code>std::string</code>.</p><h1 id=successreference_wrappert><code>success<reference_wrapper<T>></code>
|
||||
<a class=anchor href=#successreference_wrappert>#</a></h1><p>Specialization of <code>success</code> for when the success value is a reference.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>success</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>reference_wrapper<span style=color:#f92672><</span>T<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>success</span>(std<span style=color:#f92672>::</span>reference_wrapper<span style=color:#f92672><</span>value_type<span style=color:#f92672>></span> v) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-types-1>Member Types
|
||||
<a class=anchor href=#member-types-1>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span></code></pre></div><p>The type of the success value. It is <code>T</code> from <code>std::reference_wrapper<T></code>, not the reference itself.</p><h3 id=get-1><code>get()</code>
|
||||
<a class=anchor href=#get-1>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Accesses the stored value.</p><h1 id=failure>failure
|
||||
<a class=anchor href=#failure>#</a></h1><p>A type that holds a failure value.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>failure</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>failure</span>(value_type v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>failure() <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> failure(<span style=color:#66d9ef>const</span> failure<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> failure(failure<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> failure<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> failure<span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> failure<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(failure<span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> failure(U<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> failure(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> v);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>failure<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>decay<span style=color:#f92672><</span>T<span style=color:#f92672>>::</span>type<span style=color:#f92672>></span> err(T<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>failure<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> err(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>literal)[N]);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-types-2>Member Types
|
||||
<a class=anchor href=#member-types-2>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span></code></pre></div><p>The type of the failure value.</p><h2 id=member-functions-1>Member Functions
|
||||
<a class=anchor href=#member-functions-1>#</a></h2><h3 id=constructor-1>Constructor
|
||||
<a class=anchor href=#constructor-1>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>failure</span>(value_type v);
|
||||
</span></span></code></pre></div><p>Constructs with a <code>value_type</code> argument.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>explicit</span> failure(U<span style=color:#f92672>&&</span> v);
|
||||
</span></span></code></pre></div><p>Constructs with another type that can be converted to <code>value_type</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>explicit</span> failure(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> v);
|
||||
</span></span></code></pre></div><p>Constructs with another <code>failure</code> type that can be converted to <code>value_type</code>.</p><h3 id=get-2><code>get()</code>
|
||||
<a class=anchor href=#get-2>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Accesses the stored value.</p><h2 id=non-member-functions-1>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions-1>#</a></h2><h3 id=errt><code>err(T)</code>
|
||||
<a class=anchor href=#errt>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>failure<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> std<span style=color:#f92672>::</span>decay<span style=color:#f92672><</span>T<span style=color:#f92672>>::</span>type<span style=color:#f92672>></span> err(T<span style=color:#f92672>&&</span> v);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>size_t N<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>failure<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> err(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span> (<span style=color:#f92672>&</span>literal)[N]);
|
||||
</span></span></code></pre></div><p>Constructs and returns a <code>failure</code> type from a failure value.</p><p>Converts a string literal into <code>std::string</code>.</p><h1 id=failurereference_wrappert><code>failure<reference_wrapper<T>></code>
|
||||
<a class=anchor href=#failurereference_wrappert>#</a></h1><p>Specialization of <code>failure</code> for when the failure value is a reference.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>failure</span><span style=color:#f92672><</span>std<span style=color:#f92672>::</span>reference_wrapper<span style=color:#f92672><</span>T<span style=color:#f92672>>></span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>failure</span>(std<span style=color:#f92672>::</span>reference_wrapper<span style=color:#f92672><</span>value_type<span style=color:#f92672>></span> v) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span> {<span style=color:#66d9ef>return</span> value.get();}
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> {<span style=color:#66d9ef>return</span> value.get();}
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-types-3>Member Types
|
||||
<a class=anchor href=#member-types-3>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> T;
|
||||
</span></span></code></pre></div><p>The type of the failure value. It is <code>T</code> from <code>std::reference_wrapper<T></code>, not the reference itself.</p><h3 id=get-3><code>get()</code>
|
||||
<a class=anchor href=#get-3>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> get() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> get() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Accesses the stored value.</p><h1 id=result>result
|
||||
<a class=anchor href=#result>#</a></h1><p>A type that holds either a success value or a failure value.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#66d9ef>typename</span> E<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>result</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> success_type <span style=color:#f92672>=</span> success<span style=color:#f92672><</span>T<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> failure_type <span style=color:#f92672>=</span> failure<span style=color:#f92672><</span>E<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> value_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> success_type<span style=color:#f92672>::</span>value_type;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> error_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> failure_type<span style=color:#f92672>::</span>value_type;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> result(success_type s);
|
||||
</span></span><span style=display:flex><span> result(failure_type f);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> s);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> f);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(success_type s);
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(failure_type f);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> s);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> f);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>result() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> result(<span style=color:#66d9ef>const</span> result<span style=color:#f92672>&</span> other);
|
||||
</span></span><span style=display:flex><span> result(result<span style=color:#f92672>&&</span> other);
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> result<span style=color:#f92672>&</span> other);
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(result<span style=color:#f92672>&&</span> other);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U, <span style=color:#66d9ef>typename</span> F<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result(result<span style=color:#f92672><</span>U, F<span style=color:#f92672>></span> other);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U, <span style=color:#66d9ef>typename</span> F<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(result<span style=color:#f92672><</span>U, F<span style=color:#f92672>></span> other);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_ok</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_err</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> <span style=color:#66d9ef>operator</span> <span style=color:#a6e22e>bool</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> unwrap(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current()) <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> unwrap_or(value_type<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap_or(value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> error_type<span style=color:#f92672>&</span> unwrap_err(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span> error_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap_err(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current()) <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> value_type<span style=color:#f92672>&</span> as_ok() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_ok() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> error_type<span style=color:#f92672>&</span> as_err() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> error_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_err() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h2 id=member-types-4>Member Types
|
||||
<a class=anchor href=#member-types-4>#</a></h2><h3 id=success_type><code>success_type</code>
|
||||
<a class=anchor href=#success_type>#</a></h3><p><code>success<T></code>.</p><h3 id=failure_type><code>failure_type</code>
|
||||
<a class=anchor href=#failure_type>#</a></h3><p><code>failure<E></code>.</p><h3 id=value_type><code>value_type</code>
|
||||
<a class=anchor href=#value_type>#</a></h3><p>The type <code>T</code> of the success value, alias for <code>success_type::value_type</code>.</p><p>If <code>T</code> is <code>std::reference_wrapper<U></code>, then it is <code>U</code>.</p><h3 id=error_type><code>error_type</code>
|
||||
<a class=anchor href=#error_type>#</a></h3><p>The type <code>E</code> of the failure value, alias for <code>failure_type::value_type</code>.</p><p>If <code>E</code> is <code>std::reference_wrapper<F></code>, then it is <code>F</code>.</p><h2 id=member-functions-2>Member Functions
|
||||
<a class=anchor href=#member-functions-2>#</a></h2><h3 id=constructor-2>Constructor
|
||||
<a class=anchor href=#constructor-2>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>result() <span style=color:#f92672>=</span> <span style=color:#66d9ef>delete</span>;
|
||||
</span></span></code></pre></div><p>Cannot construct <code>result</code> type by default. Needs to be given either a success or failure type.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>result(success_type s);
|
||||
</span></span><span style=display:flex><span>result(failure_type f);
|
||||
</span></span></code></pre></div><p>Constructs with a <code>success_type</code> or <code>failure_type</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> s);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> f);
|
||||
</span></span></code></pre></div><p>Constructs with a <code>success<U></code> or <code>failure<U></code> that is convertible to <code>value_type</code> or <code>error_type</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U, <span style=color:#66d9ef>typename</span> F<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result(result<span style=color:#f92672><</span>U, F<span style=color:#f92672>></span> other);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U, <span style=color:#66d9ef>typename</span> F<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(result<span style=color:#f92672><</span>U, F<span style=color:#f92672>></span> other);
|
||||
</span></span></code></pre></div><p>Constructs from or assigns to another <code>result</code> with convertible <code>success</code> or <code>failure</code> types.</p><h3 id=copy-and-move-constructors>Copy and Move Constructors
|
||||
<a class=anchor href=#copy-and-move-constructors>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>result(<span style=color:#66d9ef>const</span> result<span style=color:#f92672>&</span> other);
|
||||
</span></span><span style=display:flex><span>result(result<span style=color:#f92672>&&</span> other);
|
||||
</span></span></code></pre></div><p>Can be copy or move constructed.</p><h3 id=operator><code>operator=</code>
|
||||
<a class=anchor href=#operator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> result<span style=color:#f92672>&</span> other);
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(result<span style=color:#f92672>&&</span> other);
|
||||
</span></span></code></pre></div><p>Can be copy or move assigned.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(success<span style=color:#f92672><</span>U<span style=color:#f92672>></span> s);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> U<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(failure<span style=color:#f92672><</span>U<span style=color:#f92672>></span> f);
|
||||
</span></span></code></pre></div><p>Can be assigned from convertible <code>success</code> or <code>failure</code> types.</p><h3 id=is_ok><code>is_ok()</code>
|
||||
<a class=anchor href=#is_ok>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_ok</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if it holds a success value, <code>false</code> otherwise.</p><h3 id=is_err><code>is_err()</code>
|
||||
<a class=anchor href=#is_err>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_err</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if it holds a failure value, <code>false</code> otherwise.</p><h3 id=operator-bool><code>operator bool()</code>
|
||||
<a class=anchor href=#operator-bool>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#66d9ef>operator</span> <span style=color:#a6e22e>bool</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if it holds a success value, <code>false</code> otherwise.</p><h3 id=unwrap><code>unwrap()</code>
|
||||
<a class=anchor href=#unwrap>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> unwrap(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current()) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Returns the stored success value.</p><p>Throws <code>toml::bad_result_access</code> if it holds a failure value.</p><p>If <code>std::source_location</code> or equivalent compiler extension is available, the file name and line number where <code>unwrap()</code> occurred are included in the <code>what()</code> string.</p><h3 id=unwrap_or><code>unwrap_or()</code>
|
||||
<a class=anchor href=#unwrap_or>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> unwrap_or(value_type<span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap_or(value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> opt) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the stored success value if present, otherwise returns the provided default value.</p><h3 id=unwrap_err><code>unwrap_err()</code>
|
||||
<a class=anchor href=#unwrap_err>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>error_type<span style=color:#f92672>&</span> unwrap_err(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current());
|
||||
</span></span><span style=display:flex><span>error_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> unwrap_err(cxx<span style=color:#f92672>::</span>source_location loc <span style=color:#f92672>=</span> cxx<span style=color:#f92672>::</span>source_location<span style=color:#f92672>::</span>current()) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Returns the stored failure value.</p><p>Throws <code>toml::bad_result_access</code> if it holds a success value.</p><p>If <code>std::source_location</code> or equivalent compiler extension is available, the file name and line number where <code>unwrap_err()</code> occurred are included in the <code>what()</code> string.</p><h3 id=as_ok><code>as_ok()</code>
|
||||
<a class=anchor href=#as_ok>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> as_ok() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_ok() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the success value without checking.</p><p>Behavior is undefined if it holds a failure value.</p><h3 id=as_err><code>as_err()</code>
|
||||
<a class=anchor href=#as_err>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>error_type<span style=color:#f92672>&</span> as_err() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>error_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_err() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the failure value without checking.</p><p>Behavior is undefined if it holds a success value.</p><h1 id=bad_result_access>bad_result_access
|
||||
<a class=anchor href=#bad_result_access>#</a></h1><p>An exception thrown when <code>unwrap</code> or <code>unwrap_err</code> fails in a <code>result</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>bad_result_access</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> <span style=color:#f92672>::</span>toml<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> bad_result_access(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> what_arg);
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>virtual</span> <span style=color:#f92672>~</span>bad_result_access() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>virtual</span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>protected</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string what_;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#resulthpp>result.hpp</a></li><li><a href=#success>success</a><ul><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li><li><a href=#get><code>get()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#okt><code>ok(T)</code></a></li></ul></li></ul></li><li><a href=#successreference_wrappert><code>success<reference_wrapper<T>></code></a><ul><li><a href=#member-types-1>Member Types</a><ul><li><a href=#get-1><code>get()</code></a></li></ul></li></ul></li><li><a href=#failure>failure</a><ul><li><a href=#member-types-2>Member Types</a></li><li><a href=#member-functions-1>Member Functions</a><ul><li><a href=#constructor-1>Constructor</a></li><li><a href=#get-2><code>get()</code></a></li></ul></li><li><a href=#non-member-functions-1>Non-Member Functions</a><ul><li><a href=#errt><code>err(T)</code></a></li></ul></li></ul></li><li><a href=#failurereference_wrappert><code>failure<reference_wrapper<T>></code></a><ul><li><a href=#member-types-3>Member Types</a><ul><li><a href=#get-3><code>get()</code></a></li></ul></li></ul></li><li><a href=#result>result</a><ul><li><a href=#member-types-4>Member Types</a><ul><li><a href=#success_type><code>success_type</code></a></li><li><a href=#failure_type><code>failure_type</code></a></li><li><a href=#value_type><code>value_type</code></a></li><li><a href=#error_type><code>error_type</code></a></li></ul></li><li><a href=#member-functions-2>Member Functions</a><ul><li><a href=#constructor-2>Constructor</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#operator><code>operator=</code></a></li><li><a href=#is_ok><code>is_ok()</code></a></li><li><a href=#is_err><code>is_err()</code></a></li><li><a href=#operator-bool><code>operator bool()</code></a></li><li><a href=#unwrap><code>unwrap()</code></a></li><li><a href=#unwrap_or><code>unwrap_or()</code></a></li><li><a href=#unwrap_err><code>unwrap_err()</code></a></li><li><a href=#as_ok><code>as_ok()</code></a></li><li><a href=#as_err><code>as_err()</code></a></li></ul></li></ul></li><li><a href=#bad_result_access>bad_result_access</a></li></ul></nav></div></aside></main></body></html>
|
||||
65
docs/reference/serializer/index.html
Normal file
65
docs/reference/serializer/index.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
serializer.hpp
|
||||
#
|
||||
|
||||
|
||||
format
|
||||
#
|
||||
|
||||
Serializes the data.
|
||||
namespace toml
|
||||
{
|
||||
template<typename TC>
|
||||
std::string format(const basic_value<TC>& v,
|
||||
const spec s = spec::default_version());
|
||||
template<typename TC>
|
||||
std::string format(const typename basic_value<TC>::key_type& k,
|
||||
const basic_value<TC>& v,
|
||||
const spec s = spec::default_version());
|
||||
template<typename TC>
|
||||
std::string format(const std::vector<typename basic_value<TC>::key_type>& ks,
|
||||
const basic_value<TC>& v,
|
||||
const spec s = spec::default_version());
|
||||
}
|
||||
If there’s a conflict between the format information and the spec, for example, when using v1.0.0 with table_format::multiline_oneline, the spec takes precedence."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/serializer/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="serializer.hpp"><meta property="og:description" content="serializer.hpp # format # Serializes the data.
|
||||
namespace toml { template<typename TC> std::string format(const basic_value<TC>& v, const spec s = spec::default_version()); template<typename TC> std::string format(const typename basic_value<TC>::key_type& k, const basic_value<TC>& v, const spec s = spec::default_version()); template<typename TC> std::string format(const std::vector<typename basic_value<TC>::key_type>& ks, const basic_value<TC>& v, const spec s = spec::default_version()); } If there’s a conflict between the format information and the spec, for example, when using v1.0.0 with table_format::multiline_oneline, the spec takes precedence."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>serializer.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/serializer/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/serializer/ title=serializer.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/serializer/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/ class=active>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>serializer.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#serializerhpp>serializer.hpp</a><ul><li><a href=#format><code>format</code></a><ul><li><a href=#formatv-spec><code>format(v, spec)</code></a></li><li><a href=#formatk-v-spec><code>format(k, v, spec)</code></a></li><li><a href=#formatk-v-spec-1><code>format([k,...], v, spec)</code></a></li></ul></li><li><a href=#serialization_error><code>serialization_error</code></a></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=serializerhpp>serializer.hpp
|
||||
<a class=anchor href=#serializerhpp>#</a></h1><h2 id=format><code>format</code>
|
||||
<a class=anchor href=#format>#</a></h2><p>Serializes the data.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format(<span style=color:#66d9ef>const</span> <span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>&</span> k,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>::</span>key_type<span style=color:#f92672>>&</span> ks,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> spec s <span style=color:#f92672>=</span> spec<span style=color:#f92672>::</span>default_version());
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>If there’s a conflict between the format information and the <code>spec</code>, for example, when using <code>v1.0.0</code> with <code>table_format::multiline_oneline</code>, the <code>spec</code> takes precedence.</p><h3 id=formatv-spec><code>format(v, spec)</code>
|
||||
<a class=anchor href=#formatv-spec>#</a></h3><p>Formats a <code>toml::value</code> according to its format information and the provided <code>spec</code>.</p><p>If it’s a <code>table_type</code>, it’s formatted as if it were the root table. Otherwise, only the value is formatted.</p><h3 id=formatk-v-spec><code>format(k, v, spec)</code>
|
||||
<a class=anchor href=#formatk-v-spec>#</a></h3><p>Formats a <code>toml::value</code> along with the given key.</p><p><code>v</code> is interpreted as being defined under that key.</p><h3 id=formatk-v-spec-1><code>format([k,...], v, spec)</code>
|
||||
<a class=anchor href=#formatk-v-spec-1>#</a></h3><p><code>v</code> is interpreted as being defined under those keys.
|
||||
If multiple keys are provided, it’s interpreted as a recursively defined table.</p><h2 id=serialization_error><code>serialization_error</code>
|
||||
<a class=anchor href=#serialization_error>#</a></h2><p>Reports errors that occurred during serialization.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>serialization_error</span> <span style=color:#66d9ef>final</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> <span style=color:#f92672>::</span>toml<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> serialization_error(std<span style=color:#f92672>::</span>string what_arg, source_location loc);
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>serialization_error() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span>;
|
||||
</span></span><span style=display:flex><span> source_location <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> location() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#serializerhpp>serializer.hpp</a><ul><li><a href=#format><code>format</code></a><ul><li><a href=#formatv-spec><code>format(v, spec)</code></a></li><li><a href=#formatk-v-spec><code>format(k, v, spec)</code></a></li><li><a href=#formatk-v-spec-1><code>format([k,...], v, spec)</code></a></li></ul></li><li><a href=#serialization_error><code>serialization_error</code></a></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
162
docs/reference/source_location/index.html
Normal file
162
docs/reference/source_location/index.html
Normal file
@@ -0,0 +1,162 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
source_location.hpp
|
||||
#
|
||||
|
||||
source_location.hpp defines a class representing a specific area within a TOML file.
|
||||
This class is used to represent problematic areas in error messages.
|
||||
|
||||
toml::source_location
|
||||
#
|
||||
|
||||
source_location is a class representing a specific area within a TOML file.
|
||||
namespace toml
|
||||
{
|
||||
struct source_location
|
||||
{
|
||||
public:
|
||||
|
||||
explicit source_location(/* implementation-defined */);
|
||||
~source_location() = default;
|
||||
source_location(source_location const&) = default;
|
||||
source_location(source_location &&) = default;
|
||||
source_location& operator=(source_location const&) = default;
|
||||
source_location& operator=(source_location &&) = default;
|
||||
|
||||
bool is_ok() const noexcept;
|
||||
std::size_t length() const noexcept;
|
||||
|
||||
std::size_t first_line_number() const noexcept;
|
||||
std::size_t first_column_number() const noexcept;
|
||||
std::size_t last_line_number() const noexcept;
|
||||
std::size_t last_column_number() const noexcept;
|
||||
|
||||
std::string const& file_name() const noexcept;
|
||||
|
||||
std::size_t num_lines() const noexcept;
|
||||
|
||||
std::string const& first_line() const;
|
||||
std::string const& last_line() const;
|
||||
|
||||
std::vector<std::string> const& lines() const noexcept;
|
||||
};
|
||||
|
||||
template<typename ... Ts>
|
||||
std::string format_location(const source_location& loc, const std::string& msg, const Ts& ... locs_and_msgs);
|
||||
} //toml
|
||||
|
||||
Member Functions
|
||||
#
|
||||
|
||||
|
||||
Constructor
|
||||
#
|
||||
|
||||
explicit source_location(/* implementation-defined */);
|
||||
toml::source_location can only be constructed via toml::parse or the _toml literal."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/source_location/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="source_location.hpp"><meta property="og:description" content="source_location.hpp # source_location.hpp defines a class representing a specific area within a TOML file.
|
||||
This class is used to represent problematic areas in error messages.
|
||||
toml::source_location # source_location is a class representing a specific area within a TOML file.
|
||||
namespace toml { struct source_location { public: explicit source_location(/* implementation-defined */); ~source_location() = default; source_location(source_location const&) = default; source_location(source_location &&) = default; source_location& operator=(source_location const&) = default; source_location& operator=(source_location &&) = default; bool is_ok() const noexcept; std::size_t length() const noexcept; std::size_t first_line_number() const noexcept; std::size_t first_column_number() const noexcept; std::size_t last_line_number() const noexcept; std::size_t last_column_number() const noexcept; std::string const& file_name() const noexcept; std::size_t num_lines() const noexcept; std::string const& first_line() const; std::string const& last_line() const; std::vector<std::string> const& lines() const noexcept; }; template<typename ... Ts> std::string format_location(const source_location& loc, const std::string& msg, const Ts& ... locs_and_msgs); } //toml Member Functions # Constructor # explicit source_location(/* implementation-defined */); toml::source_location can only be constructed via toml::parse or the _toml literal."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>source_location.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/source_location/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/source_location/ title=source_location.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/source_location/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/ class=active>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>source_location.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#source_locationhpp>source_location.hpp</a></li><li><a href=#tomlsource_location><code>toml::source_location</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li><li><a href=#is_ok><code>is_ok()</code></a></li><li><a href=#length><code>length()</code></a></li><li><a href=#first_line_number><code>first_line_number()</code></a></li><li><a href=#first_column_number><code>first_column_number()</code></a></li><li><a href=#last_line_number><code>last_line_number()</code></a></li><li><a href=#last_column_number><code>last_column_number()</code></a></li><li><a href=#file_name><code>file_name()</code></a></li><li><a href=#num_lines><code>num_lines()</code></a></li><li><a href=#first_line><code>first_line()</code></a></li><li><a href=#last_line><code>last_line()</code></a></li><li><a href=#lines><code>lines()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#format_location><code>format_location</code></a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=source_locationhpp>source_location.hpp
|
||||
<a class=anchor href=#source_locationhpp>#</a></h1><p><code>source_location.hpp</code> defines a class representing a specific area within a TOML file.</p><p>This class is used to represent problematic areas in error messages.</p><h1 id=tomlsource_location><code>toml::source_location</code>
|
||||
<a class=anchor href=#tomlsource_location>#</a></h1><p><code>source_location</code> is a class representing a specific area within a TOML file.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>source_location</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>explicit</span> source_location(<span style=color:#75715e>/* implementation-defined */</span>);
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>source_location() <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> source_location(source_location <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> source_location(source_location <span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> source_location<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(source_location <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span> source_location<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(source_location <span style=color:#f92672>&&</span>) <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_ok</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t length() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t first_line_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t first_column_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t last_line_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t last_column_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> file_name() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>size_t num_lines() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> first_line() <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> last_line() <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> lines() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_location(<span style=color:#66d9ef>const</span> source_location<span style=color:#f92672>&</span> loc, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> msg, <span style=color:#66d9ef>const</span> Ts<span style=color:#f92672>&</span> ... locs_and_msgs);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>//toml
|
||||
</span></span></span></code></pre></div><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=constructor>Constructor
|
||||
<a class=anchor href=#constructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>source_location</span>(<span style=color:#75715e>/* implementation-defined */</span>);
|
||||
</span></span></code></pre></div><p><code>toml::source_location</code> can only be constructed via <code>toml::parse</code> or the <code>_toml</code> literal.</p><h3 id=is_ok><code>is_ok()</code>
|
||||
<a class=anchor href=#is_ok>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_ok</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns <code>true</code> if the <code>source_location</code> holds a valid value, <code>false</code> otherwise.</p><p>The result of <code>location()</code> from <code>toml::value</code> constructed outside of <code>toml::parse</code> or <code>_toml</code> literals returns <code>false</code> for <code>is_ok</code> as it points to nothing.</p><h3 id=length><code>length()</code>
|
||||
<a class=anchor href=#length>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t length() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the length of the area pointed to by the <code>source_location</code>.</p><p>Returns <code>0</code> if it does not hold a valid value.</p><h3 id=first_line_number><code>first_line_number()</code>
|
||||
<a class=anchor href=#first_line_number>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t first_line_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the line number of the first line of the area pointed to by the <code>source_location</code>.</p><p>Returns <code>1</code> if it does not hold a valid value.</p><h3 id=first_column_number><code>first_column_number()</code>
|
||||
<a class=anchor href=#first_column_number>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t first_column_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the column number of the first column of the area pointed to by the <code>source_location</code>.</p><p>Returns <code>1</code> if it does not hold a valid value.</p><h3 id=last_line_number><code>last_line_number()</code>
|
||||
<a class=anchor href=#last_line_number>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t last_line_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the line number of the last line of the area pointed to by the <code>source_location</code>.</p><p>Returns <code>1</code> if it does not hold a valid value.</p><h3 id=last_column_number><code>last_column_number()</code>
|
||||
<a class=anchor href=#last_column_number>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t last_column_number() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the column number of the last column of the area pointed to by the <code>source_location</code>.</p><p>Returns <code>1</code> if it does not hold a valid value.</p><h3 id=file_name><code>file_name()</code>
|
||||
<a class=anchor href=#file_name>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> file_name() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the file name containing the area pointed to by the <code>source_location</code>.</p><p>Returns <code>"unknown file"</code> if it does not hold a valid value.</p><h3 id=num_lines><code>num_lines()</code>
|
||||
<a class=anchor href=#num_lines>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t num_lines() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns the number of lines in the area pointed to by the <code>source_location</code>.</p><p>Returns <code>0</code> if it does not hold a valid value.</p><h3 id=first_line><code>first_line()</code>
|
||||
<a class=anchor href=#first_line>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> first_line() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Returns the first line of the area pointed to by the <code>source_location</code>.</p><p>Throws <code>std::out_of_range</code> if it does not hold a valid value.</p><h3 id=last_line><code>last_line()</code>
|
||||
<a class=anchor href=#last_line>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> last_line() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><p>Returns the last line of the area pointed to by the <code>source_location</code>.</p><p>Throws <code>std::out_of_range</code> if it does not hold a valid value.</p><h3 id=lines><code>lines()</code>
|
||||
<a class=anchor href=#lines>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> lines() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Returns all lines in the area pointed to by the <code>source_location</code>.</p><p>Returns a reference to an empty <code>std::vector</code> if it does not hold a valid value.</p><h2 id=non-member-functions>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=format_location><code>format_location</code>
|
||||
<a class=anchor href=#format_location>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_location(<span style=color:#66d9ef>const</span> source_location<span style=color:#f92672>&</span> loc, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> msg,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> Ts<span style=color:#f92672>&</span> ... locs_and_msgs);
|
||||
</span></span></code></pre></div><p>Formats the specified <code>source_location</code> and its associated message as follows:</p><pre tabindex=0><code> -> {filename.toml}
|
||||
|
|
||||
1 | a = 42
|
||||
| ^-- {message}
|
||||
</code></pre><p>If colorization is enabled, ANSI escape sequences will be added for coloring.</p><p>When multiple <code>locs_and_msgs</code> are provided, they must be in the order of <code>const source_location&</code> followed by <code>const std::string&</code>, and the next pair in the same order, and so on.</p><h4 id=example-multiple-source_location-and-stdstring>Example: Multiple <code>source_location</code> and <code>std::string</code>
|
||||
<a class=anchor href=#example-multiple-source_location-and-stdstring>#</a></h4><p>When multiple <code>source_location</code> and <code>std::string</code> pairs are provided, they are formatted as follows:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>source_location<span style=color:#f92672>&</span> loc0;
|
||||
</span></span><span style=display:flex><span>source_location<span style=color:#f92672>&</span> loc1;
|
||||
</span></span><span style=display:flex><span>source_location<span style=color:#f92672>&</span> loc2;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string msg0;
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string msg1;
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string msg2;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>format_location(loc0, msg0,
|
||||
</span></span><span style=display:flex><span> loc1, msg1,
|
||||
</span></span><span style=display:flex><span> loc2, msg2);
|
||||
</span></span></code></pre></div><pre tabindex=0><code> -> {filename0.toml}
|
||||
|
|
||||
1 | a = 42
|
||||
| ^-- {message0}
|
||||
|
|
||||
-> {filename1.toml}
|
||||
|
|
||||
2 | b = 3.14
|
||||
| ^-- {message1}
|
||||
|
|
||||
-> {filename2.toml}
|
||||
|
|
||||
3 | c = "foo"
|
||||
| ^-- {message2}
|
||||
</code></pre><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#source_locationhpp>source_location.hpp</a></li><li><a href=#tomlsource_location><code>toml::source_location</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li><li><a href=#is_ok><code>is_ok()</code></a></li><li><a href=#length><code>length()</code></a></li><li><a href=#first_line_number><code>first_line_number()</code></a></li><li><a href=#first_column_number><code>first_column_number()</code></a></li><li><a href=#last_line_number><code>last_line_number()</code></a></li><li><a href=#last_column_number><code>last_column_number()</code></a></li><li><a href=#file_name><code>file_name()</code></a></li><li><a href=#num_lines><code>num_lines()</code></a></li><li><a href=#first_line><code>first_line()</code></a></li><li><a href=#last_line><code>last_line()</code></a></li><li><a href=#lines><code>lines()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#format_location><code>format_location</code></a></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
164
docs/reference/spec/index.html
Normal file
164
docs/reference/spec/index.html
Normal file
@@ -0,0 +1,164 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
spec.hpp
|
||||
#
|
||||
|
||||
spec.hpp defines classes for specifying the version of TOML.
|
||||
|
||||
toml::semantic_version
|
||||
#
|
||||
|
||||
semantic_version is a class that stores version information.
|
||||
namespace toml
|
||||
{
|
||||
struct semantic_version
|
||||
{
|
||||
constexpr semantic_version(std::uint32_t mjr, std::uint32_t mnr, std::uint32_t p) noexcept;
|
||||
|
||||
std::uint32_t major;
|
||||
std::uint32_t minor;
|
||||
std::uint32_t patch;
|
||||
};
|
||||
|
||||
constexpr semantic_version
|
||||
make_semver(std::uint32_t major, std::uint32_t minor, std::uint32_t patch) noexcept;
|
||||
|
||||
constexpr bool operator==(const semantic_version&, const semantic_version&) noexcept;
|
||||
constexpr bool operator!=(const semantic_version&, const semantic_version&) noexcept;
|
||||
constexpr bool operator< (const semantic_version&, const semantic_version&) noexcept;
|
||||
constexpr bool operator<=(const semantic_version&, const semantic_version&) noexcept;
|
||||
constexpr bool operator> (const semantic_version&, const semantic_version&) noexcept;
|
||||
constexpr bool operator>=(const semantic_version&, const semantic_version&) noexcept;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const semantic_version& ver);
|
||||
} //toml
|
||||
|
||||
Member Functions
|
||||
#
|
||||
|
||||
|
||||
Constructor
|
||||
#
|
||||
|
||||
constexpr semantic_version(std::uint32_t mjr, std::uint32_t mnr, std::uint32_t p) noexcept;
|
||||
Constructs a semantic_version instance with the specified major, minor, and patch version numbers."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/spec/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="spec.hpp"><meta property="og:description" content="spec.hpp # spec.hpp defines classes for specifying the version of TOML.
|
||||
toml::semantic_version # semantic_version is a class that stores version information.
|
||||
namespace toml { struct semantic_version { constexpr semantic_version(std::uint32_t mjr, std::uint32_t mnr, std::uint32_t p) noexcept; std::uint32_t major; std::uint32_t minor; std::uint32_t patch; }; constexpr semantic_version make_semver(std::uint32_t major, std::uint32_t minor, std::uint32_t patch) noexcept; constexpr bool operator==(const semantic_version&, const semantic_version&) noexcept; constexpr bool operator!=(const semantic_version&, const semantic_version&) noexcept; constexpr bool operator< (const semantic_version&, const semantic_version&) noexcept; constexpr bool operator<=(const semantic_version&, const semantic_version&) noexcept; constexpr bool operator> (const semantic_version&, const semantic_version&) noexcept; constexpr bool operator>=(const semantic_version&, const semantic_version&) noexcept; std::ostream& operator<<(std::ostream& os, const semantic_version& ver); } //toml Member Functions # Constructor # constexpr semantic_version(std::uint32_t mjr, std::uint32_t mnr, std::uint32_t p) noexcept; Constructs a semantic_version instance with the specified major, minor, and patch version numbers."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>spec.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/spec/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/spec/ title=spec.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/spec/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/ class=active>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>spec.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#spechpp>spec.hpp</a></li><li><a href=#tomlsemantic_version><code>toml::semantic_version</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#comparison-operators>Comparison Operators</a></li><li><a href=#stream-operator>Stream Operator</a></li><li><a href=#to_string><code>to_string</code></a></li></ul></li></ul></li><li><a href=#tomlspec><code>toml::spec</code></a><ul><li><a href=#member-functions-1>Member Functions</a><ul><li><a href=#constructor-1>Constructor</a></li><li><a href=#default_version><code>default_version()</code></a></li><li><a href=#vmajor-minor-patch><code>v(major, minor, patch)</code></a></li></ul></li><li><a href=#member-variables>Member Variables</a><ul><li><a href=#example>Example</a></li><li><a href=#v1_1_0_allow_control_characters_in_comments><code>v1_1_0_allow_control_characters_in_comments</code></a></li><li><a href=#v1_1_0_allow_newlines_in_inline_tables><code>v1_1_0_allow_newlines_in_inline_tables</code></a></li><li><a href=#v1_1_0_allow_trailing_comma_in_inline_tables><code>v1_1_0_allow_trailing_comma_in_inline_tables</code></a></li><li><a href=#v1_1_0_add_escape_sequence_e><code>v1_1_0_add_escape_sequence_e</code></a></li><li><a href=#v1_1_0_add_escape_sequence_x><code>v1_1_0_add_escape_sequence_x</code></a></li><li><a href=#v1_1_0_make_seconds_optional><code>v1_1_0_make_seconds_optional</code></a></li><li><a href=#ext_hex_float><code>ext_hex_float</code></a></li><li><a href=#ext_num_suffix><code>ext_num_suffix</code></a></li><li><a href=#ext_null_value><code>ext_null_value</code></a></li></ul></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=spechpp>spec.hpp
|
||||
<a class=anchor href=#spechpp>#</a></h1><p><code>spec.hpp</code> defines classes for specifying the version of TOML.</p><h1 id=tomlsemantic_version><code>toml::semantic_version</code>
|
||||
<a class=anchor href=#tomlsemantic_version>#</a></h1><p><code>semantic_version</code> is a class that stores version information.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>semantic_version</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>constexpr</span> <span style=color:#a6e22e>semantic_version</span>(std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mjr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mnr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> p) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> major;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> minor;
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> patch;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> semantic_version
|
||||
</span></span><span style=display:flex><span><span style=color:#a6e22e>make_semver</span>(std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> major, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> minor, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> patch) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>==</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>!=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><</span> (<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>></span> (<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>>=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span> ver);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>//toml
|
||||
</span></span></span></code></pre></div><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=constructor>Constructor
|
||||
<a class=anchor href=#constructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#a6e22e>semantic_version</span>(std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mjr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mnr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> p) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Constructs a <code>semantic_version</code> instance with the specified <code>major</code>, <code>minor</code>, and <code>patch</code> version numbers.</p><h2 id=non-member-functions>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=comparison-operators>Comparison Operators
|
||||
<a class=anchor href=#comparison-operators>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>==</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>!=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><</span> (<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>></span> (<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>>=</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Compares two <code>semantic_version</code> instances according to semantic versioning rules.</p><h3 id=stream-operator>Stream Operator
|
||||
<a class=anchor href=#stream-operator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, <span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span> ver);
|
||||
</span></span></code></pre></div><p>Outputs the version in the format <code>{major}.{minor}.{patch}</code>.</p><h3 id=to_string><code>to_string</code>
|
||||
<a class=anchor href=#to_string>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string to_string(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span> ver);
|
||||
</span></span></code></pre></div><p>Converts the version to a string in the format <code>{major}.{minor}.{patch}</code>.</p><h1 id=tomlspec><code>toml::spec</code>
|
||||
<a class=anchor href=#tomlspec>#</a></h1><p><code>spec</code> is a class that stores TOML version information.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>spec</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>static</span> spec <span style=color:#a6e22e>default_version</span>() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>static</span> spec <span style=color:#a6e22e>v</span>(std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mjr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mnr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> p) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>spec</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span> semver) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> semantic_version version; <span style=color:#75715e>// toml version
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#75715e>// diff from v1.0.0 -> v1.1.0
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>bool</span> v1_1_0_allow_control_characters_in_comments;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_allow_newlines_in_inline_tables;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_allow_trailing_comma_in_inline_tables;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_allow_non_english_in_bare_keys;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_add_escape_sequence_e;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_add_escape_sequence_x;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>bool</span> v1_1_0_make_seconds_optional;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#75715e>// library extensions
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>bool</span> ext_hex_float; <span style=color:#75715e>// allow hex float
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>bool</span> ext_num_suffix; <span style=color:#75715e>// allow number suffix
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>bool</span> ext_null_value; <span style=color:#75715e>// allow null value
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>};
|
||||
</span></span></code></pre></div><h2 id=member-functions-1>Member Functions
|
||||
<a class=anchor href=#member-functions-1>#</a></h2><h3 id=constructor-1>Constructor
|
||||
<a class=anchor href=#constructor-1>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>explicit</span> <span style=color:#a6e22e>spec</span>(<span style=color:#66d9ef>const</span> semantic_version<span style=color:#f92672>&</span> semver) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Constructs a <code>spec</code> with the specified TOML version.</p><p>Supports TOML v1.0.0 and TOML v1.1.0.</p><h3 id=default_version><code>default_version()</code>
|
||||
<a class=anchor href=#default_version>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>static</span> spec <span style=color:#a6e22e>default_version</span>() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Constructs a <code>spec</code> with the default version.</p><p>Used as the default value for <code>toml::parse</code> and <code>toml::format</code>.</p><p>In toml11 v4.4.0, the value is v1.0.0.</p><h3 id=vmajor-minor-patch><code>v(major, minor, patch)</code>
|
||||
<a class=anchor href=#vmajor-minor-patch>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>constexpr</span> <span style=color:#66d9ef>static</span> spec <span style=color:#a6e22e>v</span>(std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mjr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> mnr, std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint32_t</span> p) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><p>Constructs a <code>spec</code> with the specified version.</p><h2 id=member-variables>Member Variables
|
||||
<a class=anchor href=#member-variables>#</a></h2><p>Each flag is automatically set to <code>true</code> when the specified version includes the corresponding feature.</p><p>You can modify these flags to change the behavior of <code>toml::parse</code> and <code>toml::format</code>.</p><blockquote class="book-hint warning"><p>Some features of TOML v1.1.0 are still under fairly lengthy discussion and may still be reverted.</p><p>If they are indeed reverted, toml11 will remove those features in a minor version upgrade or move them to a corresponding later version.</p><p>As such, any features related to future versions should be considered unstable.</p></blockquote><h3 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>auto</span> spec <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>spec<span style=color:#f92672>::</span>v(<span style=color:#ae81ff>1</span>, <span style=color:#ae81ff>0</span>, <span style=color:#ae81ff>0</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>// Allow newlines in inline tables in addition to v1.0.0 features.
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>// Other v1.1.0 features are not enabled.
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>spec.v1_1_0_allow_newlines_in_inline_tables <span style=color:#f92672>=</span> true;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>auto</span> input <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>parse(<span style=color:#e6db74>"input_file.toml"</span>, spec);
|
||||
</span></span></code></pre></div><h3 id=v1_1_0_allow_control_characters_in_comments><code>v1_1_0_allow_control_characters_in_comments</code>
|
||||
<a class=anchor href=#v1_1_0_allow_control_characters_in_comments>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_allow_control_characters_in_comments;
|
||||
</span></span></code></pre></div><p>Allows most control characters in comments.</p><p>Added in TOML v1.1.0.</p><h3 id=v1_1_0_allow_newlines_in_inline_tables><code>v1_1_0_allow_newlines_in_inline_tables</code>
|
||||
<a class=anchor href=#v1_1_0_allow_newlines_in_inline_tables>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_allow_newlines_in_inline_tables;
|
||||
</span></span></code></pre></div><p>Allows newlines in inline tables.</p><p>Added in TOML v1.1.0.</p><h3 id=v1_1_0_allow_trailing_comma_in_inline_tables><code>v1_1_0_allow_trailing_comma_in_inline_tables</code>
|
||||
<a class=anchor href=#v1_1_0_allow_trailing_comma_in_inline_tables>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_allow_trailing_comma_in_inline_tables;
|
||||
</span></span></code></pre></div><p>Allows trailing commas in inline tables.</p><p>Added in TOML v1.1.0.</p><h3 id=v1_1_0_add_escape_sequence_e><code>v1_1_0_add_escape_sequence_e</code>
|
||||
<a class=anchor href=#v1_1_0_add_escape_sequence_e>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_add_escape_sequence_e;
|
||||
</span></span></code></pre></div><p>Allows <code>\e</code> to represent the ESC character.</p><p>Added in TOML v1.1.0.</p><h3 id=v1_1_0_add_escape_sequence_x><code>v1_1_0_add_escape_sequence_x</code>
|
||||
<a class=anchor href=#v1_1_0_add_escape_sequence_x>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_add_escape_sequence_x;
|
||||
</span></span></code></pre></div><p>Allows <code>\xHH</code> to represent a single byte character.</p><p>Added in TOML v1.1.0.</p><h3 id=v1_1_0_make_seconds_optional><code>v1_1_0_make_seconds_optional</code>
|
||||
<a class=anchor href=#v1_1_0_make_seconds_optional>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> v1_1_0_make_seconds_optional;
|
||||
</span></span></code></pre></div><p>Makes the seconds component in time optional.</p><p>Unspecified seconds default to <code>0</code>.</p><p>Added in TOML v1.1.0.</p><h3 id=ext_hex_float><code>ext_hex_float</code>
|
||||
<a class=anchor href=#ext_hex_float>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> ext_hex_float;
|
||||
</span></span></code></pre></div><p>This is a language extension specific to toml11.</p><p>It is initialized to <code>false</code> regardless of the specified version.
|
||||
You must explicitly set it to <code>true</code> if you want to use it.</p><p>Allows hexadecimal representation of floating-point numbers.</p><p>The hexadecimal representation conforms to the <code>printf</code> format specifier <code>%a/%A</code>.</p><pre tabindex=0><code>hexf = 0xC0FFEEp-10
|
||||
</code></pre><p><code>toml::format</code> will format using hexadecimal notation only if the passed <code>toml::spec</code> has <code>ext_hex_float</code> set to <code>true</code>.
|
||||
If the format specifier indicates <code>hex</code> but the <code>toml::spec</code> passed to <code>toml::format</code> has <code>ext_hex_float</code> set to <code>false</code>, the hexadecimal specification is ignored, and the number is output in decimal notation with maximum precision.</p><h3 id=ext_num_suffix><code>ext_num_suffix</code>
|
||||
<a class=anchor href=#ext_num_suffix>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> ext_num_suffix;
|
||||
</span></span></code></pre></div><p>This is a language extension specific to toml11.</p><p>It is initialized to <code>false</code> regardless of the specified version.
|
||||
You must explicitly set it to <code>true</code> if you want to use it.</p><p>Allows the addition of suffixes to decimal integers and floating-point numbers. This does not apply to hexadecimal, octal, or binary notations.</p><p>There must be an <code>_</code> separator between the number and the suffix.</p><p>The suffix cannot start with a digit to avoid confusion with the numeric part.</p><pre tabindex=0><code>distance = 10_m # valid
|
||||
distance = 10_2m # invalid
|
||||
distance = 10_2_m # valid
|
||||
</code></pre><p>The suffix is stored in the format information as <code>std::string suffix</code>.
|
||||
The <code>_</code> separating the number from the suffix is not included in the <code>suffix</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>toml<span style=color:#f92672>::</span>value distance <span style=color:#f92672>=</span> toml<span style=color:#f92672>::</span>find(input, <span style=color:#e6db74>"distance"</span>);
|
||||
</span></span><span style=display:flex><span>assert(distance.as_integer_fmt().suffix <span style=color:#f92672>==</span> std<span style=color:#f92672>::</span>string(<span style=color:#e6db74>"m"</span>));
|
||||
</span></span></code></pre></div><p><code>toml::format</code> will format the value with the suffix only if the passed <code>toml::spec</code> has <code>ext_num_suffix</code> set to <code>true</code>.</p><p>The <code>suffix</code> follows the grammar defined as:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-abnf data-lang=abnf><span style=display:flex><span><span style=color:#a6e22e>non-digit-graph</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>ALPHA</span> <span style=color:#f92672>/</span> <span style=color:#a6e22e>non-ascii</span>
|
||||
</span></span><span style=display:flex><span><span style=color:#a6e22e>graph</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>ALPHA</span> <span style=color:#f92672>/</span> <span style=color:#66d9ef>DIGIT</span> <span style=color:#f92672>/</span> <span style=color:#a6e22e>non-ascii</span>
|
||||
</span></span><span style=display:flex><span><span style=color:#a6e22e>suffix</span> <span style=color:#f92672>=</span> _ <span style=color:#a6e22e>non-digit-graph</span> <span style=color:#f92672>*</span>( <span style=color:#a6e22e>graph</span> <span style=color:#f92672>/</span> ( _ <span style=color:#a6e22e>graph</span> ) )
|
||||
</span></span></code></pre></div><h3 id=ext_null_value><code>ext_null_value</code>
|
||||
<a class=anchor href=#ext_null_value>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> ext_null_value;
|
||||
</span></span></code></pre></div><p>This is a language extension specific to toml11.</p><p>Allows the use of <code>null</code> as a value.</p><p>A <code>toml::value</code> specified as <code>null</code> will have no value, and <code>is_empty()</code> will return <code>true</code>.</p><p><code>toml::format</code> will format it as <code>null</code> only if the passed <code>toml::spec</code> has <code>ext_null_value</code> set to <code>true</code>.
|
||||
Otherwise, <code>toml::format</code> will terminate with an error.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#spechpp>spec.hpp</a></li><li><a href=#tomlsemantic_version><code>toml::semantic_version</code></a><ul><li><a href=#member-functions>Member Functions</a><ul><li><a href=#constructor>Constructor</a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#comparison-operators>Comparison Operators</a></li><li><a href=#stream-operator>Stream Operator</a></li><li><a href=#to_string><code>to_string</code></a></li></ul></li></ul></li><li><a href=#tomlspec><code>toml::spec</code></a><ul><li><a href=#member-functions-1>Member Functions</a><ul><li><a href=#constructor-1>Constructor</a></li><li><a href=#default_version><code>default_version()</code></a></li><li><a href=#vmajor-minor-patch><code>v(major, minor, patch)</code></a></li></ul></li><li><a href=#member-variables>Member Variables</a><ul><li><a href=#example>Example</a></li><li><a href=#v1_1_0_allow_control_characters_in_comments><code>v1_1_0_allow_control_characters_in_comments</code></a></li><li><a href=#v1_1_0_allow_newlines_in_inline_tables><code>v1_1_0_allow_newlines_in_inline_tables</code></a></li><li><a href=#v1_1_0_allow_trailing_comma_in_inline_tables><code>v1_1_0_allow_trailing_comma_in_inline_tables</code></a></li><li><a href=#v1_1_0_add_escape_sequence_e><code>v1_1_0_add_escape_sequence_e</code></a></li><li><a href=#v1_1_0_add_escape_sequence_x><code>v1_1_0_add_escape_sequence_x</code></a></li><li><a href=#v1_1_0_make_seconds_optional><code>v1_1_0_make_seconds_optional</code></a></li><li><a href=#ext_hex_float><code>ext_hex_float</code></a></li><li><a href=#ext_num_suffix><code>ext_num_suffix</code></a></li><li><a href=#ext_null_value><code>ext_null_value</code></a></li></ul></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
19
docs/reference/toml/index.html
Normal file
19
docs/reference/toml/index.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
toml.hpp
|
||||
#
|
||||
|
||||
toml.hpp includes all other headers.
|
||||
This allows access to all features of toml11.
|
||||
This header file and toml_fwd.hpp are located under ${TOML11_INCLUDE_DIR}/,
|
||||
while other header files are located under ${toml11_include_dir}/toml11/."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/toml/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="toml.hpp"><meta property="og:description" content="toml.hpp # toml.hpp includes all other headers.
|
||||
This allows access to all features of toml11.
|
||||
This header file and toml_fwd.hpp are located under ${TOML11_INCLUDE_DIR}/, while other header files are located under ${toml11_include_dir}/toml11/."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>toml.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/toml/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/toml/ title=toml.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/toml/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/ class=active>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>toml.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#tomlhpp>toml.hpp</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=tomlhpp>toml.hpp
|
||||
<a class=anchor href=#tomlhpp>#</a></h1><p><code>toml.hpp</code> includes all other headers.</p><p>This allows access to all features of toml11.</p><p>This header file and <code>toml_fwd.hpp</code> are located under <code>${TOML11_INCLUDE_DIR}/</code>,
|
||||
while other header files are located under <code>${toml11_include_dir}/toml11/</code>.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#tomlhpp>toml.hpp</a></li></ul></nav></div></aside></main></body></html>
|
||||
21
docs/reference/toml_fwd/index.html
Normal file
21
docs/reference/toml_fwd/index.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
toml_fwd.hpp
|
||||
#
|
||||
|
||||
toml_fwd.hpp contains forward declarations of structures defined in toml11 and macro definitions.
|
||||
When only forward declarations of toml11 structures are needed and implementation is not required, including toml_fwd.hpp instead of toml.hpp can reduce compilation time.
|
||||
|
||||
Since this file only contains forward declarations, you cannot use toml::table, defined as toml::basic_value<toml::type_config>::table_type, and similarly defined toml::array. This is because they require the implementation of basic_value.
|
||||
|
||||
|
||||
This header file and toml.hpp are located under ${TOML11_INCLUDE_DIR}/, while other header files are located under ${TOML11_INCLUDE_DIR}/toml11/."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/toml_fwd/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="toml_fwd.hpp"><meta property="og:description" content="toml_fwd.hpp # toml_fwd.hpp contains forward declarations of structures defined in toml11 and macro definitions.
|
||||
When only forward declarations of toml11 structures are needed and implementation is not required, including toml_fwd.hpp instead of toml.hpp can reduce compilation time.
|
||||
Since this file only contains forward declarations, you cannot use toml::table, defined as toml::basic_value<toml::type_config>::table_type, and similarly defined toml::array. This is because they require the implementation of basic_value. This header file and toml.hpp are located under ${TOML11_INCLUDE_DIR}/, while other header files are located under ${TOML11_INCLUDE_DIR}/toml11/."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>toml_fwd.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/toml_fwd/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/toml_fwd/ title=toml_fwd.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/toml_fwd/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/ class=active>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>toml_fwd.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#toml_fwdhpp>toml_fwd.hpp</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=toml_fwdhpp>toml_fwd.hpp
|
||||
<a class=anchor href=#toml_fwdhpp>#</a></h1><p><code>toml_fwd.hpp</code> contains forward declarations of structures defined in toml11 and macro definitions.</p><p>When only forward declarations of toml11 structures are needed and implementation is not required, including <code>toml_fwd.hpp</code> instead of <code>toml.hpp</code> can reduce compilation time.</p><blockquote class="book-hint warning">Since this file only contains forward declarations, you cannot use <code>toml::table</code>, defined as <code>toml::basic_value<toml::type_config>::table_type</code>, and similarly defined <code>toml::array</code>. This is because they require the implementation of <code>basic_value</code>.</blockquote><p>This header file and <code>toml.hpp</code> are located under <code>${TOML11_INCLUDE_DIR}/</code>, while other header files are located under <code>${TOML11_INCLUDE_DIR}/toml11/</code>.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#toml_fwdhpp>toml_fwd.hpp</a></li></ul></nav></div></aside></main></body></html>
|
||||
148
docs/reference/types/index.html
Normal file
148
docs/reference/types/index.html
Normal file
@@ -0,0 +1,148 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
types.hpp
|
||||
#
|
||||
|
||||
This document defines classes that specifies type information.
|
||||
|
||||
type_config
|
||||
#
|
||||
|
||||
type_config is a type that encapsulates parameters given to toml::basic_value.
|
||||
When using different types within toml::basic_value<T>, you need to define and pass this type separately.
|
||||
All elements listed are required.
|
||||
If you use numerical types that cannot use standard stream operators, define and replace the equivalents for read_int and read_float.
|
||||
namespace toml
|
||||
{
|
||||
struct type_config
|
||||
{
|
||||
using comment_type = preserve_comments;
|
||||
|
||||
using boolean_type = bool;
|
||||
using integer_type = std::int64_t;
|
||||
using floating_type = double;
|
||||
using string_type = std::string;
|
||||
|
||||
template<typename T>
|
||||
using array_type = std::vector<T>;
|
||||
template<typename K, typename T>
|
||||
using table_type = std::unordered_map<K, T>;
|
||||
|
||||
static result<integer_type, error_info>
|
||||
parse_int(const std::string& str, const source_location src, const std::uint8_t base);
|
||||
|
||||
static result<floating_type, error_info>
|
||||
parse_float(const std::string& str, const source_location src, const bool is_hex);
|
||||
};
|
||||
|
||||
using value = basic_value<type_config>;
|
||||
using table = typename value::table_type;
|
||||
using array = typename value::array_type;
|
||||
|
||||
} // toml
|
||||
|
||||
static Member Functions
|
||||
#
|
||||
|
||||
|
||||
parse_int(str, src, base)
|
||||
#
|
||||
|
||||
static result<integer_type, error_info>
|
||||
parse_int(const std::string& str, const source_location src, const std::uint8_t base);
|
||||
If you use a type as integer_type that cannot utilize standard stream operators, implement this function.
|
||||
Otherwise, use read_int described later."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/types/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="types.hpp"><meta property="og:description" content="types.hpp # This document defines classes that specifies type information.
|
||||
type_config # type_config is a type that encapsulates parameters given to toml::basic_value.
|
||||
When using different types within toml::basic_value<T>, you need to define and pass this type separately. All elements listed are required.
|
||||
If you use numerical types that cannot use standard stream operators, define and replace the equivalents for read_int and read_float.
|
||||
namespace toml { struct type_config { using comment_type = preserve_comments; using boolean_type = bool; using integer_type = std::int64_t; using floating_type = double; using string_type = std::string; template<typename T> using array_type = std::vector<T>; template<typename K, typename T> using table_type = std::unordered_map<K, T>; static result<integer_type, error_info> parse_int(const std::string& str, const source_location src, const std::uint8_t base); static result<floating_type, error_info> parse_float(const std::string& str, const source_location src, const bool is_hex); }; using value = basic_value<type_config>; using table = typename value::table_type; using array = typename value::array_type; } // toml static Member Functions # parse_int(str, src, base) # static result<integer_type, error_info> parse_int(const std::string& str, const source_location src, const std::uint8_t base); If you use a type as integer_type that cannot utilize standard stream operators, implement this function. Otherwise, use read_int described later."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>types.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/types/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/types/ title=types.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/types/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/ class=active>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>types.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#typeshpp>types.hpp</a></li><li><a href=#type_config><code>type_config</code></a><ul><li><a href=#static-member-functions><code>static</code> Member Functions</a><ul><li><a href=#parse_intstr-src-base><code>parse_int(str, src, base)</code></a></li><li><a href=#parse_floatstr-src-is_hex><code>parse_float(str, src, is_hex)</code></a></li></ul></li><li><a href=#non-member-functions>Non-member Functions</a><ul><li><a href=#read_int><code>read_int</code></a></li><li><a href=#read_float><code>read_float</code></a></li></ul></li></ul></li><li><a href=#ordered_type_config><code>ordered_type_config</code></a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=typeshpp>types.hpp
|
||||
<a class=anchor href=#typeshpp>#</a></h1><p>This document defines classes that specifies type information.</p><h1 id=type_config><code>type_config</code>
|
||||
<a class=anchor href=#type_config>#</a></h1><p><code>type_config</code> is a type that encapsulates parameters given to <code>toml::basic_value</code>.</p><p>When using different types within <code>toml::basic_value<T></code>, you need to define and pass this type separately.
|
||||
All elements listed are required.</p><p>If you use numerical types that cannot use standard stream operators, define and replace the equivalents for <code>read_int</code> and <code>read_float</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>type_config</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> comment_type <span style=color:#f92672>=</span> preserve_comments;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> boolean_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>bool</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> integer_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>int64_t</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> floating_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>double</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> string_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>string;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> array_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>T<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> K, <span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> table_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>unordered_map<span style=color:#f92672><</span>K, T<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>integer_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> parse_int(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint8_t</span> base);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>floating_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> parse_float(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>bool</span> is_hex);
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> value <span style=color:#f92672>=</span> basic_value<span style=color:#f92672><</span>type_config<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> table <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> value<span style=color:#f92672>::</span>table_type;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> array <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> value<span style=color:#f92672>::</span>array_type;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=static-member-functions><code>static</code> Member Functions
|
||||
<a class=anchor href=#static-member-functions>#</a></h2><h3 id=parse_intstr-src-base><code>parse_int(str, src, base)</code>
|
||||
<a class=anchor href=#parse_intstr-src-base>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>integer_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse_int(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint8_t</span> base);
|
||||
</span></span></code></pre></div><p>If you use a type as <code>integer_type</code> that cannot utilize standard stream operators, implement this function.
|
||||
Otherwise, use <code>read_int</code> described later.</p><p>The <code>str</code> parameter receives a string with prefixes, leading zeros, and underscores removed.</p><p>The <code>src</code> parameter receives a <code>source_location</code> pointing to where the string was defined.</p><p>The <code>base</code> parameter receives one of <code>10</code>, <code>2</code>, <code>8</code>, or <code>16</code>.</p><h3 id=parse_floatstr-src-is_hex><code>parse_float(str, src, is_hex)</code>
|
||||
<a class=anchor href=#parse_floatstr-src-is_hex>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>floating_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>parse_float(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>bool</span> is_hex);
|
||||
</span></span></code></pre></div><p>If you use a type as <code>floating_type</code> that cannot utilize standard stream operators, implement this function.
|
||||
Otherwise, use <code>read_float</code> described later.</p><p>The <code>str</code> parameter receives a string with prefixes, leading zeros, and underscores removed.</p><p>The <code>src</code> parameter receives a <code>source_location</code> pointing to where the string was defined.</p><p>The <code>is_hex</code> parameter indicates whether the format is <code>hexfloat</code>. If you don’t use the <code>hexfloat</code> extension, you don’t need to implement this.</p><p>For details on the <code>hexfloat</code> extension, refer to <a href=https://toruniina.github.io/toml11/docs/reference/spec/>spec.hpp</a>.</p><h2 id=non-member-functions>Non-member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=read_int><code>read_int</code>
|
||||
<a class=anchor href=#read_int>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>T, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>read_int(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint8_t</span> base);
|
||||
</span></span></code></pre></div><p>This is the default function used. It parses using <code>std::istringstream</code>.</p><p>If <code>operator>></code> and manipulators like <code>std::hex</code>, and <code>std::numeric_limits<T></code> are defined (such as for <code>boost::multiprecision</code>), you can use this without modifications.</p><h3 id=read_float><code>read_float</code>
|
||||
<a class=anchor href=#read_float>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>result<span style=color:#f92672><</span>T, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>read_float(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>bool</span> is_hex);
|
||||
</span></span></code></pre></div><p>This is the default function used. It parses decimals using <code>std::istringstream</code> and hexfloats using <code>sscanf()</code>.</p><p>It supports <code>double</code> and <code>float</code>.</p><p>For other types, if <code>operator>></code> is defined and <code>hex</code> is not used, you can use this function.</p><h1 id=ordered_type_config><code>ordered_type_config</code>
|
||||
<a class=anchor href=#ordered_type_config>#</a></h1><p><code>ordered_type_config</code> is a variation of <code>toml::type_config</code> where the table type is replaced with <code>toml::ordered_map</code>.
|
||||
Additionally, it defines the <code>toml::ordered_value</code> alias.</p><p>Other than these changes, it is identical to <code>type_config</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>ordered_type_config</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> comment_type <span style=color:#f92672>=</span> preserve_comments;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> boolean_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>bool</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> integer_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>int64_t</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> floating_type <span style=color:#f92672>=</span> <span style=color:#66d9ef>double</span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> string_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>string;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> array_type <span style=color:#f92672>=</span> std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>T<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> K, <span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>using</span> table_type <span style=color:#f92672>=</span> ordered_map<span style=color:#f92672><</span>K, T<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>integer_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> parse_int(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint8_t</span> base)
|
||||
</span></span><span style=display:flex><span> {
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> read_int<span style=color:#f92672><</span>integer_type<span style=color:#f92672>></span>(str, src, base);
|
||||
</span></span><span style=display:flex><span> }
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>static</span> result<span style=color:#f92672><</span>floating_type, error_info<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span> parse_float(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>string<span style=color:#f92672>&</span> str, <span style=color:#66d9ef>const</span> source_location src, <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>bool</span> is_hex)
|
||||
</span></span><span style=display:flex><span> {
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> read_float<span style=color:#f92672><</span>floating_type<span style=color:#f92672>></span>(str, src, is_hex);
|
||||
</span></span><span style=display:flex><span> }
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_value <span style=color:#f92672>=</span> basic_value<span style=color:#f92672><</span>ordered_type_config<span style=color:#f92672>></span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_table <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> ordered_value<span style=color:#f92672>::</span>table_type;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>using</span> ordered_array <span style=color:#f92672>=</span> <span style=color:#66d9ef>typename</span> ordered_value<span style=color:#f92672>::</span>array_type;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#typeshpp>types.hpp</a></li><li><a href=#type_config><code>type_config</code></a><ul><li><a href=#static-member-functions><code>static</code> Member Functions</a><ul><li><a href=#parse_intstr-src-base><code>parse_int(str, src, base)</code></a></li><li><a href=#parse_floatstr-src-is_hex><code>parse_float(str, src, is_hex)</code></a></li></ul></li><li><a href=#non-member-functions>Non-member Functions</a><ul><li><a href=#read_int><code>read_int</code></a></li><li><a href=#read_float><code>read_float</code></a></li></ul></li></ul></li><li><a href=#ordered_type_config><code>ordered_type_config</code></a></li></ul></nav></div></aside></main></body></html>
|
||||
439
docs/reference/value/index.html
Normal file
439
docs/reference/value/index.html
Normal file
@@ -0,0 +1,439 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
value.hpp
|
||||
#
|
||||
|
||||
value.hpp defines basic_value.
|
||||
|
||||
toml::basic_value
|
||||
#
|
||||
|
||||
basic_value is a class that stores TOML values.
|
||||
namespace toml
|
||||
{
|
||||
template <class TypeConfig>
|
||||
class basic_value;
|
||||
|
||||
// Defined in types.hpp
|
||||
// using value = basic_value<type_config>;
|
||||
// using table = typename basic_value<type_config>::table_type;
|
||||
// using array = typename basic_value<type_config>::array_type;
|
||||
|
||||
template<typename TC>
|
||||
bool operator==(const basic_value<TC>&, const basic_value<TC>&);
|
||||
template<typename TC>
|
||||
bool operator!=(const basic_value<TC>&, const basic_value<TC>&);
|
||||
template<typename TC>
|
||||
bool operator< (const basic_value<TC>&, const basic_value<TC>&);
|
||||
template<typename TC>
|
||||
bool operator<=(const basic_value<TC>&, const basic_value<TC>&);
|
||||
template<typename TC>
|
||||
bool operator> (const basic_value<TC>&, const basic_value<TC>&);
|
||||
template<typename TC>
|
||||
bool operator>=(const basic_value<TC>&, const basic_value<TC>&);
|
||||
} //toml
|
||||
|
||||
Member Types
|
||||
#
|
||||
|
||||
The following member types are defined."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/value/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="value.hpp"><meta property="og:description" content="value.hpp # value.hpp defines basic_value.
|
||||
toml::basic_value # basic_value is a class that stores TOML values.
|
||||
namespace toml { template <class TypeConfig> class basic_value; // Defined in types.hpp // using value = basic_value<type_config>; // using table = typename basic_value<type_config>::table_type; // using array = typename basic_value<type_config>::array_type; template<typename TC> bool operator==(const basic_value<TC>&, const basic_value<TC>&); template<typename TC> bool operator!=(const basic_value<TC>&, const basic_value<TC>&); template<typename TC> bool operator< (const basic_value<TC>&, const basic_value<TC>&); template<typename TC> bool operator<=(const basic_value<TC>&, const basic_value<TC>&); template<typename TC> bool operator> (const basic_value<TC>&, const basic_value<TC>&); template<typename TC> bool operator>=(const basic_value<TC>&, const basic_value<TC>&); } //toml Member Types # The following member types are defined."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>value.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/value/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/value/ title=value.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/value/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/ class=active>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>value.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#valuehpp>value.hpp</a></li><li><a href=#tomlbasic_value><code>toml::basic_value</code></a><ul><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#default-constructor>Default Constructor</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#copy-and-move-constructors-with-comments>Copy and Move Constructors with Comments</a></li><li><a href=#conversion-constructors>Conversion Constructors</a></li><li><a href=#constructor-boolean>Constructor (boolean)</a></li><li><a href=#constructor-integer>Constructor (integer)</a></li><li><a href=#constructor-floating>Constructor (floating)</a></li><li><a href=#constructor-string>Constructor (string)</a></li><li><a href=#constructor-local_date>Constructor (local_date)</a></li><li><a href=#constructor-local_time>Constructor (local_time)</a></li><li><a href=#constructor-local_datetime>Constructor (local_datetime)</a></li><li><a href=#constructor-offset_datetime>Constructor (offset_datetime)</a></li><li><a href=#constructor-array>Constructor (array)</a></li><li><a href=#constructor-table>Constructor (table)</a></li><li><a href=#constructor-user-defined>Constructor (user-defined)</a></li><li><a href=#operatorbasic_value><code>operator=(basic_value)</code></a></li><li><a href=#operatort><code>operator=(T)</code></a></li><li><a href=#ist><code>is<T>()</code></a></li><li><a href=#istomlvalue_t><code>is(toml::value_t)</code></a></li><li><a href=#is_xxx><code>is_xxx()</code></a></li><li><a href=#is_empty><code>is_empty()</code></a></li><li><a href=#is_array_of_tables><code>is_array_of_tables()</code></a></li><li><a href=#type><code>type()</code></a></li><li><a href=#as_xxx><code>as_xxx()</code></a></li><li><a href=#as_xxxstdnothrow><code>as_xxx(std::nothrow)</code></a></li><li><a href=#as_xxx_fmt><code>as_xxx_fmt()</code></a></li><li><a href=#as_xxx_fmtstdnothrow><code>as_xxx_fmt(std::nothrow)</code></a></li><li><a href=#atkey><code>at(key)</code></a></li><li><a href=#countkey><code>count(key)</code></a></li><li><a href=#containskey><code>contains(key)</code></a></li><li><a href=#atidx><code>at(idx)</code></a></li><li><a href=#operatoridx><code>operator[](idx)</code></a></li><li><a href=#push_backvalue><code>push_back(value)</code></a></li><li><a href=#emplace_backargs><code>emplace_back(args...)</code></a></li><li><a href=#size><code>size()</code></a></li><li><a href=#location><code>location()</code></a></li><li><a href=#comments><code>comments()</code></a></li><li><a href=#accessed><code>accessed()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#operator><code>operator==</code></a></li><li><a href=#operator-1><code>operator!=</code></a></li><li><a href=#operator-2><code>operator<</code></a></li><li><a href=#operator-3><code>operator<=</code></a></li><li><a href=#operator-4><code>operator></code></a></li><li><a href=#operator-5><code>operator>=</code></a></li></ul></li></ul></li><li><a href=#tomltype_error><code>toml::type_error</code></a></li><li><a href=#tomlmake_error_info><code>toml::make_error_info</code></a></li><li><a href=#tomlformat_error><code>toml::format_error</code></a></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=valuehpp>value.hpp
|
||||
<a class=anchor href=#valuehpp>#</a></h1><p><code>value.hpp</code> defines <code>basic_value</code>.</p><h1 id=tomlbasic_value><code>toml::basic_value</code>
|
||||
<a class=anchor href=#tomlbasic_value>#</a></h1><p><code>basic_value</code> is a class that stores TOML values.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span> <span style=color:#f92672><</span><span style=color:#66d9ef>class</span> <span style=color:#a6e22e>TypeConfig</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>class</span> <span style=color:#a6e22e>basic_value</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>// Defined in types.hpp
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>// using value = basic_value<type_config>;
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>// using table = typename basic_value<type_config>::table_type;
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>// using array = typename basic_value<type_config>::array_type;
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>==</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>!=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><</span> (<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>></span> (<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>>=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>//toml
|
||||
</span></span></span></code></pre></div><h2 id=member-types>Member Types
|
||||
<a class=anchor href=#member-types>#</a></h2><p>The following member types are defined.</p><p>You can modify the member types using <code>TypeConfig</code>.</p><p>See also: <a href=https://toruniina.github.io/toml11/docs/reference/types/>types.hpp</a></p><table><thead><tr><th style=text-align:left>Name</th><th style=text-align:left>Definition</th></tr></thead><tbody><tr><td style=text-align:left><code>char_type</code></td><td style=text-align:left><code>typename TypeConfig::char_type</code></td></tr><tr><td style=text-align:left><code>key_type</code></td><td style=text-align:left><code>typename TypeConfig::string_type</code></td></tr><tr><td style=text-align:left><code>value_type</code></td><td style=text-align:left><code>basic_value<TypeConfig></code></td></tr><tr><td style=text-align:left><code>boolean_type</code></td><td style=text-align:left><code>typename TypeConfig::boolean_type</code></td></tr><tr><td style=text-align:left><code>integer_type</code></td><td style=text-align:left><code>typename TypeConfig::integer_type</code></td></tr><tr><td style=text-align:left><code>floating_type</code></td><td style=text-align:left><code>typename TypeConfig::floating_type</code></td></tr><tr><td style=text-align:left><code>string_type</code></td><td style=text-align:left><code>typename TypeConfig::string_type</code></td></tr><tr><td style=text-align:left><code>local_time_type</code></td><td style=text-align:left><code>toml::local_time</code></td></tr><tr><td style=text-align:left><code>local_date_type</code></td><td style=text-align:left><code>toml::local_date</code></td></tr><tr><td style=text-align:left><code>local_datetime_type</code></td><td style=text-align:left><code>toml::local_datetime</code></td></tr><tr><td style=text-align:left><code>offset_datetime_type</code></td><td style=text-align:left><code>toml::offset_datetime</code></td></tr><tr><td style=text-align:left><code>array_type</code></td><td style=text-align:left><code>typename TypeConfig::template array_type<value_type></code></td></tr><tr><td style=text-align:left><code>table_type</code></td><td style=text-align:left><code>typename TypeConfig::template table_type<key_type, value_type></code></td></tr><tr><td style=text-align:left><code>comment_type</code></td><td style=text-align:left><code>typename TypeConfig::comment_type</code></td></tr></tbody></table><h2 id=member-functions>Member Functions
|
||||
<a class=anchor href=#member-functions>#</a></h2><h3 id=default-constructor>Default Constructor
|
||||
<a class=anchor href=#default-constructor>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value() <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><p>Constructs an empty <code>toml::value</code>.</p><p>The constructed <code>toml::value</code> will be empty.</p><h3 id=copy-and-move-constructors>Copy and Move Constructors
|
||||
<a class=anchor href=#copy-and-move-constructors>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&</span> v)
|
||||
</span></span><span style=display:flex><span>basic_value(basic_value<span style=color:#f92672>&&</span> v)
|
||||
</span></span></code></pre></div><p>Copies or moves all information including values, format information, comments, and file regions.</p><h3 id=copy-and-move-constructors-with-comments>Copy and Move Constructors with Comments
|
||||
<a class=anchor href=#copy-and-move-constructors-with-comments>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(basic_value v, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Copies or moves the object while overwriting comments.</p><h3 id=conversion-constructors>Conversion Constructors
|
||||
<a class=anchor href=#conversion-constructors>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TI<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(basic_value<span style=color:#f92672><</span>TI<span style=color:#f92672>></span> other)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TI<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(basic_value<span style=color:#f92672><</span>TI<span style=color:#f92672>></span> other, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Copies or moves from a <code>basic_value</code> with a different <code>type_config</code>.</p><h3 id=constructor-boolean>Constructor (boolean)
|
||||
<a class=anchor href=#constructor-boolean>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(boolean_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(boolean_type x, boolean_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(boolean_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(boolean_type x, boolean_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>bool</code>, its format information, and comments.</p><h3 id=constructor-integer>Constructor (integer)
|
||||
<a class=anchor href=#constructor-integer>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_integral<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_integral<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, integer_format_info fmt)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_integral<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_integral<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, integer_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with an <code>integer</code>, its format information, and comments.</p><h3 id=constructor-floating>Constructor (floating)
|
||||
<a class=anchor href=#constructor-floating>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_floating_point<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_floating_point<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, floating_format_info fmt)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_floating_point<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* std::is_floating_point<T> is true */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, floating_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>floating</code> point number, its format information, and comments.</p><h3 id=constructor-string>Constructor (string)
|
||||
<a class=anchor href=#constructor-string>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(string_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(string_type x, string_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(string_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(string_type x, string_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> x)
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> x, string_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> string_type<span style=color:#f92672>::</span>value_type<span style=color:#f92672>*</span> x, string_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>// C++17以降
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>basic_value(string_view_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(string_view_type x, string_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(string_view_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(string_view_type x, string_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>string</code>, its format information, and comments.</p><p><code>string_view_type</code> shares the same <code>value_type</code> and <code>traits_type</code> as <code>string_type</code>.</p><h3 id=constructor-local_date>Constructor (local_date)
|
||||
<a class=anchor href=#constructor-local_date>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(local_date_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(local_date_type x, local_date_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(local_date_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(local_date_type x, local_date_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>local_date_type</code>, its format information, and comments.</p><h3 id=constructor-local_time>Constructor (local_time)
|
||||
<a class=anchor href=#constructor-local_time>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(local_time_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(local_time_type x, local_time_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(local_time_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(local_time_type x, local_time_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Rep, <span style=color:#66d9ef>typename</span> Period<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>duration<span style=color:#f92672><</span>Rep, Period<span style=color:#f92672>>&</span> x)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Rep, <span style=color:#66d9ef>typename</span> Period<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>duration<span style=color:#f92672><</span>Rep, Period<span style=color:#f92672>>&</span> x, local_time_format_info fmt)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Rep, <span style=color:#66d9ef>typename</span> Period<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>duration<span style=color:#f92672><</span>Rep, Period<span style=color:#f92672>>&</span> x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Rep, <span style=color:#66d9ef>typename</span> Period<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>duration<span style=color:#f92672><</span>Rep, Period<span style=color:#f92672>>&</span> x, local_time_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>local_time_type</code>, its format information, and comments.</p><p>For <code>std::chrono::duration</code>, constructs as a time span from <code>00:00:00</code>.</p><h3 id=constructor-local_datetime>Constructor (local_datetime)
|
||||
<a class=anchor href=#constructor-local_datetime>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(local_datetime_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(local_datetime_type x, local_date_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(local_datetime_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(local_datetime_type x, local_date_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>local_datetime_type</code>, its format information, and comments.</p><h3 id=constructor-offset_datetime>Constructor (offset_datetime)
|
||||
<a class=anchor href=#constructor-offset_datetime>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(offset_datetime_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(offset_datetime_type x, offset_date_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(offset_datetime_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(offset_datetime_type x, offset_date_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>basic_value(std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>system_clock<span style=color:#f92672>::</span>time_point x)
|
||||
</span></span><span style=display:flex><span>basic_value(std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>system_clock<span style=color:#f92672>::</span>time_point x, offset_date_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>system_clock<span style=color:#f92672>::</span>time_point x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(std<span style=color:#f92672>::</span>chrono<span style=color:#f92672>::</span>system_clock<span style=color:#f92672>::</span>time_point x, offset_date_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with an <code>offset_datetime_type</code>, its format information, and comments.</p><p>For <code>std::chrono::system_clock::time_point</code>, constructs for the pointed time.</p><h3 id=constructor-array>Constructor (array)
|
||||
<a class=anchor href=#constructor-array>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(array_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(array_type x, integer_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(array_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(array_type x, integer_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is array-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is array-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, array_format_info fmt)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is array-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is array-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, array_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with an <code>array</code>, its format information, and comments.</p><p><code>array-like</code> types must meet the following criteria:</p><ul><li>Has <code>T::iterator</code>.</li><li>Has <code>T::value_type</code>.</li><li>Does <strong>not</strong> have <code>T::key_type</code>.</li><li>Does <strong>not</strong> have <code>T::mapped_type</code>.</li><li>Is <strong>not</strong> <code>std::string</code>.</li><li>Is <strong>not</strong> <code>std::string_view</code> (since C++17).</li></ul><h3 id=constructor-table>Constructor (table)
|
||||
<a class=anchor href=#constructor-table>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value(table_type x)
|
||||
</span></span><span style=display:flex><span>basic_value(table_type x, integer_format_info fmt)
|
||||
</span></span><span style=display:flex><span>basic_value(table_type x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>basic_value(table_type x, integer_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is table-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is table-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, table_format_info fmt)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is table-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T, <span style=color:#75715e>/* T is table-like */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(T x, table_format_info fmt, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com)
|
||||
</span></span></code></pre></div><p>Constructs an object with a <code>table</code>, its format information, and comments.</p><p><code>table-like</code> types must meet the following criteria:</p><ul><li>Has <code>T::iterator</code>.</li><li>Has <code>T::value_type</code>.</li><li>Has <code>T::key_type</code>.</li><li>Has <code>T::mapped_type</code>.</li></ul><h3 id=constructor-user-defined>Constructor (user-defined)
|
||||
<a class=anchor href=#constructor-user-defined>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T <span style=color:#75715e>/* toml::into<T> is defined */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> ud);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T <span style=color:#75715e>/* toml::into<T> is defined */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> ud, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T <span style=color:#75715e>/* toml::into<T> is not defined, but T{}.into_toml() exists */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> ud);
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T <span style=color:#75715e>/* toml::into<T> is not defined, but T{}.into_toml() exists */</span><span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value(<span style=color:#66d9ef>const</span> T<span style=color:#f92672>&</span> ud, std<span style=color:#f92672>::</span>vector<span style=color:#f92672><</span>std<span style=color:#f92672>::</span>string<span style=color:#f92672>></span> com);
|
||||
</span></span></code></pre></div><p>If <code>toml::into<T></code> is defined, constructs from the result of <code>toml::into<T>(ud)</code>.</p><p>If <code>toml::into<T></code> is not defined but <code>T</code> has a <code>into_toml()</code> member function, constructs from the result of <code>ud.into_toml()</code>.</p><hr><h3 id=operatorbasic_value><code>operator=(basic_value)</code>
|
||||
<a class=anchor href=#operatorbasic_value>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>basic_value<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672>&</span> v)
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(basic_value<span style=color:#f92672>&&</span> v)
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TI<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(basic_value<span style=color:#f92672><</span>TI<span style=color:#f92672>></span> other)
|
||||
</span></span></code></pre></div><p>Assigns the right-hand side <code>basic_value</code> to the current object.</p><h3 id=operatort><code>operator=(T)</code>
|
||||
<a class=anchor href=#operatort>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> T<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>basic_value<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>=</span>(T x)
|
||||
</span></span></code></pre></div><p>Assigns a value corresponding to <code>T</code>.</p><p>The contents pointed to by <code>source_location</code> are discarded.</p><p>If the object already holds a value of the same type, the original format information is retained.</p><hr><h3 id=ist><code>is<T>()</code>
|
||||
<a class=anchor href=#ist>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> is<span style=color:#f92672><</span>T<span style=color:#f92672>></span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><h4 id=requirements>Requirements
|
||||
<a class=anchor href=#requirements>#</a></h4><p><code>T</code> must be an exact TOML type, meaning it corresponds to one of the <code>toml::value::xxx_type</code>.</p><h4 id=return-value>Return Value
|
||||
<a class=anchor href=#return-value>#</a></h4><p>Returns <code>true</code> if the stored type matches <code>T</code>, otherwise returns <code>false</code>.</p><hr><h3 id=istomlvalue_t><code>is(toml::value_t)</code>
|
||||
<a class=anchor href=#istomlvalue_t>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> is(toml<span style=color:#f92672>::</span>value_t t) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><h4 id=return-value-1>Return Value
|
||||
<a class=anchor href=#return-value-1>#</a></h4><p>Returns <code>true</code> if the tag of the stored type matches <code>t</code>, otherwise returns <code>false</code>.</p><hr><h3 id=is_xxx><code>is_xxx()</code>
|
||||
<a class=anchor href=#is_xxx>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_boolean</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_integer</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_floating</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_string</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_offset_datetime</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_local_datetime</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_local_date</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_local_time</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_array</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_table</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-2>Return Value
|
||||
<a class=anchor href=#return-value-2>#</a></h4><p>Returns <code>true</code> if the stored type matches the corresponding type, otherwise returns <code>false</code>.</p><hr><h3 id=is_empty><code>is_empty()</code>
|
||||
<a class=anchor href=#is_empty>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_empty</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-3>Return Value
|
||||
<a class=anchor href=#return-value-3>#</a></h4><p>Returns <code>true</code> if the object is default constructed and no value is assigned, otherwise returns <code>false</code>.</p><h3 id=is_array_of_tables><code>is_array_of_tables()</code>
|
||||
<a class=anchor href=#is_array_of_tables>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>is_array_of_tables</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-4>Return Value
|
||||
<a class=anchor href=#return-value-4>#</a></h4><p>Returns <code>true</code> if the stored type is an array that is not empty and all elements are tables, otherwise returns <code>false</code>.</p><hr><h3 id=type><code>type()</code>
|
||||
<a class=anchor href=#type>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>toml<span style=color:#f92672>::</span>value_t type() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>
|
||||
</span></span></code></pre></div><h4 id=return-value-5>Return Value
|
||||
<a class=anchor href=#return-value-5>#</a></h4><p>Returns the tag corresponding to the stored type.</p><hr><h3 id=as_xxx><code>as_xxx()</code>
|
||||
<a class=anchor href=#as_xxx>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>boolean_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_boolean () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>integer_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_integer () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>floating_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_floating () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>string_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_string () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_offset_datetime() <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_datetime () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_date_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_date () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_time_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_time () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>array_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_array () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>table_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_table () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>boolean_type <span style=color:#f92672>&</span> as_boolean ();
|
||||
</span></span><span style=display:flex><span>integer_type <span style=color:#f92672>&</span> as_integer ();
|
||||
</span></span><span style=display:flex><span>floating_type <span style=color:#f92672>&</span> as_floating ();
|
||||
</span></span><span style=display:flex><span>string_type <span style=color:#f92672>&</span> as_string ();
|
||||
</span></span><span style=display:flex><span>offset_datetime_type<span style=color:#f92672>&</span> as_offset_datetime();
|
||||
</span></span><span style=display:flex><span>local_datetime_type <span style=color:#f92672>&</span> as_local_datetime ();
|
||||
</span></span><span style=display:flex><span>local_date_type <span style=color:#f92672>&</span> as_local_date ();
|
||||
</span></span><span style=display:flex><span>local_time_type <span style=color:#f92672>&</span> as_local_time ();
|
||||
</span></span><span style=display:flex><span>array_type <span style=color:#f92672>&</span> as_array ();
|
||||
</span></span><span style=display:flex><span>table_type <span style=color:#f92672>&</span> as_table ();
|
||||
</span></span></code></pre></div><h4 id=return-value-6>Return Value
|
||||
<a class=anchor href=#return-value-6>#</a></h4><p>Returns a reference to the value of the specified type.</p><h4 id=exception>Exception
|
||||
<a class=anchor href=#exception>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value’s type does not match the specified type.</p><hr><h3 id=as_xxxstdnothrow><code>as_xxx(std::nothrow)</code>
|
||||
<a class=anchor href=#as_xxxstdnothrow>#</a></h3><p>Invoke with a <code>std::nothrow</code> object.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>boolean_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_boolean (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>integer_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_integer (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>floating_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_floating (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>string_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_string (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_offset_datetime(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_datetime (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_date_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_date (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_time_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_time (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>array_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_array (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>table_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_table (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>boolean_type <span style=color:#f92672>&</span> as_boolean (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>integer_type <span style=color:#f92672>&</span> as_integer (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>floating_type <span style=color:#f92672>&</span> as_floating (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>string_type <span style=color:#f92672>&</span> as_string (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_type<span style=color:#f92672>&</span> as_offset_datetime(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_type <span style=color:#f92672>&</span> as_local_datetime (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_date_type <span style=color:#f92672>&</span> as_local_date (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_time_type <span style=color:#f92672>&</span> as_local_time (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>array_type <span style=color:#f92672>&</span> as_array (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>table_type <span style=color:#f92672>&</span> as_table (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-7>Return Value
|
||||
<a class=anchor href=#return-value-7>#</a></h4><p>Returns a reference to the value of the specified type.</p><h4 id=note>Note
|
||||
<a class=anchor href=#note>#</a></h4><p>If the type of the stored value does not match the specified type, the behavior is undefined.</p><hr><h3 id=as_xxx_fmt><code>as_xxx_fmt()</code>
|
||||
<a class=anchor href=#as_xxx_fmt>#</a></h3><p>Accesses format information.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>boolean_format_info <span style=color:#f92672>&</span> as_boolean_fmt ();
|
||||
</span></span><span style=display:flex><span>integer_format_info <span style=color:#f92672>&</span> as_integer_fmt ();
|
||||
</span></span><span style=display:flex><span>floating_format_info <span style=color:#f92672>&</span> as_floating_fmt ();
|
||||
</span></span><span style=display:flex><span>string_format_info <span style=color:#f92672>&</span> as_string_fmt ();
|
||||
</span></span><span style=display:flex><span>offset_datetime_format_info<span style=color:#f92672>&</span> as_offset_datetime_fmt();
|
||||
</span></span><span style=display:flex><span>local_datetime_format_info <span style=color:#f92672>&</span> as_local_datetime_fmt ();
|
||||
</span></span><span style=display:flex><span>local_date_format_info <span style=color:#f92672>&</span> as_local_date_fmt ();
|
||||
</span></span><span style=display:flex><span>local_time_format_info <span style=color:#f92672>&</span> as_local_time_fmt ();
|
||||
</span></span><span style=display:flex><span>array_format_info <span style=color:#f92672>&</span> as_array_fmt ();
|
||||
</span></span><span style=display:flex><span>table_format_info <span style=color:#f92672>&</span> as_table_fmt ();
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>boolean_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_boolean_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>integer_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_integer_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>floating_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_floating_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>string_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_string_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_offset_datetime_fmt() <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_datetime_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_date_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_date_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>local_time_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_time_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>array_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_array_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span><span style=display:flex><span>table_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_table_fmt () <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-8>Return Value
|
||||
<a class=anchor href=#return-value-8>#</a></h4><p>Returns a reference to the structure holding the format information for the specified type.</p><h4 id=exception-1>Exception
|
||||
<a class=anchor href=#exception-1>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value’s type does not match the specified type.</p><hr><h3 id=as_xxx_fmtstdnothrow><code>as_xxx_fmt(std::nothrow)</code>
|
||||
<a class=anchor href=#as_xxx_fmtstdnothrow>#</a></h3><p>Invoke with a <code>std::nothrow</code> object.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>boolean_format_info <span style=color:#f92672>&</span> as_boolean_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>integer_format_info <span style=color:#f92672>&</span> as_integer_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>floating_format_info <span style=color:#f92672>&</span> as_floating_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>string_format_info <span style=color:#f92672>&</span> as_string_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_format_info<span style=color:#f92672>&</span> as_offset_datetime_fmt(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_format_info <span style=color:#f92672>&</span> as_local_datetime_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_date_format_info <span style=color:#f92672>&</span> as_local_date_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_time_format_info <span style=color:#f92672>&</span> as_local_time_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>array_format_info <span style=color:#f92672>&</span> as_array_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>table_format_info <span style=color:#f92672>&</span> as_table_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>boolean_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_boolean_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>integer_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_integer_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>floating_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_floating_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>string_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_string_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>offset_datetime_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_offset_datetime_fmt(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_datetime_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_datetime_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_date_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_date_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>local_time_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_local_time_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>array_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_array_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>table_format_info <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> as_table_fmt (<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>nothrow_t<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-9>Return Value
|
||||
<a class=anchor href=#return-value-9>#</a></h4><p>Returns a reference to the structure holding the format information for the specified type.</p><h4 id=note-1>Note
|
||||
<a class=anchor href=#note-1>#</a></h4><p>If the type of the stored value does not match the specified type, the behavior is undefined.</p><hr><h3 id=atkey><code>at(key)</code>
|
||||
<a class=anchor href=#atkey>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key);
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-10>Return Value
|
||||
<a class=anchor href=#return-value-10>#</a></h4><p>Casts the current <code>value</code> to a <code>table</code> and returns the element specified by <code>key</code>.</p><h4 id=exception-2>Exception
|
||||
<a class=anchor href=#exception-2>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not a <code>table</code>.</p><p>Throws <code>std::out_of_range</code> if the <code>table</code> does not contain the specified element.</p><hr><h4 id=operatorkey><code>operator[](key)</code>
|
||||
<a class=anchor href=#operatorkey>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span>[](<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> k);
|
||||
</span></span></code></pre></div><h5 id=return-value-11>Return Value
|
||||
<a class=anchor href=#return-value-11>#</a></h5><p>Casts the current <code>value</code> to a <code>table</code> and returns a reference to the element specified by <code>key</code>.</p><p>If the element specified by <code>key</code> does not exist, it is default-constructed.</p><h5 id=exception-3>Exception
|
||||
<a class=anchor href=#exception-3>#</a></h5><p>Throws <code>toml::type_error</code> if the stored value is not a <code>table</code>.</p><hr><h3 id=countkey><code>count(key)</code>
|
||||
<a class=anchor href=#countkey>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t count(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-12>Return Value
|
||||
<a class=anchor href=#return-value-12>#</a></h4><p>Casts the current <code>value</code> to a <code>table</code> and returns <code>1</code> if the element corresponding to <code>key</code> is present, otherwise returns <code>0</code>.</p><h4 id=exception-4>Exception
|
||||
<a class=anchor href=#exception-4>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not a <code>table</code>.</p><hr><h3 id=containskey><code>contains(key)</code>
|
||||
<a class=anchor href=#containskey>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>contains</span>(<span style=color:#66d9ef>const</span> key_type<span style=color:#f92672>&</span> key) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-13>Return Value
|
||||
<a class=anchor href=#return-value-13>#</a></h4><p>Casts the current <code>value</code> to a <code>table</code> and returns <code>true</code> if the element corresponding to <code>key</code> is present, otherwise returns <code>false</code>.</p><h4 id=exception-5>Exception
|
||||
<a class=anchor href=#exception-5>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not a <code>table</code>.</p><hr><h3 id=atidx><code>at(idx)</code>
|
||||
<a class=anchor href=#atidx>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t idx);
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> at(<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t idx) <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-14>Return Value
|
||||
<a class=anchor href=#return-value-14>#</a></h4><p>Casts the current <code>value</code> to an <code>array</code> and returns the element specified by <code>idx</code>.</p><h4 id=exception-6>Exception
|
||||
<a class=anchor href=#exception-6>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not an <code>array</code>.</p><p>Throws <code>std::out_of_range</code> if the specified element does not exist in the <code>array</code>.</p><hr><h3 id=operatoridx><code>operator[](idx)</code>
|
||||
<a class=anchor href=#operatoridx>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>value_type<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span>[](<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t idx) <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>value_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span>[](<span style=color:#66d9ef>const</span> std<span style=color:#f92672>::</span>size_t idx) <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-15>Return Value
|
||||
<a class=anchor href=#return-value-15>#</a></h4><p>Casts the current <code>value</code> to an <code>array</code> and returns a reference to the element specified by <code>idx</code>.</p><h4 id=note-2>Note
|
||||
<a class=anchor href=#note-2>#</a></h4><p>Performs no checks. Behavior is undefined if the stored value is not an <code>array</code> or if the specified element does not exist.</p><hr><h3 id=push_backvalue><code>push_back(value)</code>
|
||||
<a class=anchor href=#push_backvalue>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>push_back</span>(<span style=color:#66d9ef>const</span> value_type<span style=color:#f92672>&</span> x);
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>void</span> <span style=color:#a6e22e>push_back</span>(value_type<span style=color:#f92672>&&</span> x);
|
||||
</span></span></code></pre></div><p>Casts the current <code>value</code> to an <code>array</code> and performs <code>push_back</code> on the <code>array</code>.</p><h4 id=return-value-16>Return Value
|
||||
<a class=anchor href=#return-value-16>#</a></h4><p>None.</p><h4 id=exception-7>Exception
|
||||
<a class=anchor href=#exception-7>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not an <code>array</code>.</p><hr><h3 id=emplace_backargs><code>emplace_back(args...)</code>
|
||||
<a class=anchor href=#emplace_backargs>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>value_type<span style=color:#f92672>&</span> emplace_back(Ts<span style=color:#f92672>&&</span> ... args)
|
||||
</span></span></code></pre></div><p>Casts the current <code>value</code> to an <code>array</code> and performs <code>emplace_back</code> on the <code>array</code>.</p><h4 id=return-value-17>Return Value
|
||||
<a class=anchor href=#return-value-17>#</a></h4><p>A reference to the constructed value.</p><h4 id=exception-8>Exception
|
||||
<a class=anchor href=#exception-8>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not an <code>array</code>.</p><hr><h3 id=size><code>size()</code>
|
||||
<a class=anchor href=#size>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>size_t size() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-18>Return Value
|
||||
<a class=anchor href=#return-value-18>#</a></h4><p>Casts the current <code>value</code> to an <code>array</code>, <code>string</code>, or <code>table</code> and returns the number of elements. For a <code>string</code>, it returns the number of characters.</p><h4 id=exception-9>Exception
|
||||
<a class=anchor href=#exception-9>#</a></h4><p>Throws <code>toml::type_error</code> if the stored value is not an <code>array</code>, <code>string</code>, or <code>table</code>.</p><hr><h3 id=location><code>location()</code>
|
||||
<a class=anchor href=#location>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>source_location <span style=color:#a6e22e>location</span>() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-19>Return Value
|
||||
<a class=anchor href=#return-value-19>#</a></h4><p>Returns a <code>source_location</code> object representing the position within the TOML document where the <code>value</code> is defined.</p><p>If the <code>value</code> was not constructed by parsing a TOML document, returns a <code>source_location</code> that points to nowhere.</p><hr><h3 id=comments><code>comments()</code>
|
||||
<a class=anchor href=#comments>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>comment_type <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> comments() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>comment_type<span style=color:#f92672>&</span> comments() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-20>Return Value
|
||||
<a class=anchor href=#return-value-20>#</a></h4><p>Returns a reference to the comment container.</p><hr><h3 id=accessed><code>accessed()</code>
|
||||
<a class=anchor href=#accessed>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#a6e22e>accessed</span>() <span style=color:#66d9ef>const</span>;
|
||||
</span></span></code></pre></div><h4 id=return-value-21>Return Value
|
||||
<a class=anchor href=#return-value-21>#</a></h4><p>Returns <code>true</code> only if the <code>value</code> has been accessed via <code>as_xxx</code> or <code>is_xxx</code>.
|
||||
Otherwise, it returns <code>false</code>.</p><h4 id=remarks>Remarks
|
||||
<a class=anchor href=#remarks>#</a></h4><p>It exists only when <code>TOML11_ENABLE_ACCESS_CHECK</code> is defined.</p><h2 id=non-member-functions>Non-Member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=operator><code>operator==</code>
|
||||
<a class=anchor href=#operator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>==</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span></code></pre></div><p>Two <code>basic_value<T></code> instances are considered equal if they satisfy the following conditions:</p><ul><li>The contained type is the same.</li><li>The contained values are identical.</li><li>The comments are identical at the byte level.</li></ul><h3 id=operator-1><code>operator!=</code>
|
||||
<a class=anchor href=#operator-1>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>!=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> lhs, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> rhs)
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#f92672>!</span>(lhs <span style=color:#f92672>==</span> rhs);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h3 id=operator-2><code>operator<</code>
|
||||
<a class=anchor href=#operator-2>#</a></h3><p>Defined only if <code>array_type</code> and <code>table_type</code> have <code>operator<</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span>);
|
||||
</span></span></code></pre></div><p>Comparison order:</p><ol><li>TOML type</li><li>If TOML types are the same, their values</li><li>If both the TOML types and values are the same, the comments</li></ol><p>TOML types have the following order (from smallest to largest):</p><ol><li><code>toml::value_t::empty</code></li><li><code>toml::value_t::boolean</code></li><li><code>toml::value_t::integer</code></li><li><code>toml::value_t::floating</code></li><li><code>toml::value_t::string</code></li><li><code>toml::value_t::offset_datetime</code></li><li><code>toml::value_t::local_datetime</code></li><li><code>toml::value_t::local_date</code></li><li><code>toml::value_t::local_time</code></li><li><code>toml::value_t::array</code></li><li><code>toml::value_t::table</code></li></ol><h3 id=operator-3><code>operator<=</code>
|
||||
<a class=anchor href=#operator-3>#</a></h3><p>Defined only if <code>array_type</code> and <code>table_type</code> have <code>operator<</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> lhs, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> rhs)
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> (lhs <span style=color:#f92672><</span> rhs) <span style=color:#f92672>||</span> (lhs <span style=color:#f92672>==</span> rhs);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h3 id=operator-4><code>operator></code>
|
||||
<a class=anchor href=#operator-4>#</a></h3><p>Defined only if <code>array_type</code> and <code>table_type</code> have <code>operator<</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>></span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> lhs, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> rhs)
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#f92672>!</span>(lhs <span style=color:#f92672><=</span> rhs);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h3 id=operator-5><code>operator>=</code>
|
||||
<a class=anchor href=#operator-5>#</a></h3><p>Defined only if <code>array_type</code> and <code>table_type</code> have <code>operator<</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>bool</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672>>=</span>(<span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> lhs, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> rhs)
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>return</span> <span style=color:#f92672>!</span>(lhs <span style=color:#f92672><</span> rhs);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h1 id=tomltype_error><code>toml::type_error</code>
|
||||
<a class=anchor href=#tomltype_error>#</a></h1><p>Exception thrown in case of a type error.</p><p>Contains the location information of the value that caused the type error.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>type_error</span> <span style=color:#66d9ef>final</span> <span style=color:#f92672>:</span> <span style=color:#66d9ef>public</span> <span style=color:#f92672>::</span>toml<span style=color:#f92672>::</span>exception
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>public</span><span style=color:#f92672>:</span>
|
||||
</span></span><span style=display:flex><span> type_error(std<span style=color:#f92672>::</span>string what_arg, source_location loc);
|
||||
</span></span><span style=display:flex><span> <span style=color:#f92672>~</span>type_error() <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span> <span style=color:#f92672>=</span> <span style=color:#66d9ef>default</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>what</span>() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span> <span style=color:#66d9ef>override</span>;
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span> source_location <span style=color:#66d9ef>const</span><span style=color:#f92672>&</span> location() <span style=color:#66d9ef>const</span> <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span></code></pre></div><h1 id=tomlmake_error_info><code>toml::make_error_info</code>
|
||||
<a class=anchor href=#tomlmake_error_info>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>error_info make_error_info(
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string title, <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span></code></pre></div><p>Calls <code>location()</code> on a <code>basic_value</code>, passes the resulting <code>source_location</code> to
|
||||
<a href=https://toruniina.github.io/toml11/docs/reference/error_info/#make_error_info><code>make_error_info</code></a>
|
||||
to create an <code>error_info</code>.</p><p>Refer to <a href=https://toruniina.github.io/toml11/docs/reference/error_info/><code>error_info</code></a> for more details.</p><h1 id=tomlformat_error><code>toml::format_error</code>
|
||||
<a class=anchor href=#tomlformat_error>#</a></h1><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> TC, <span style=color:#66d9ef>typename</span> ... Ts<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string format_error(std<span style=color:#f92672>::</span>string title,
|
||||
</span></span><span style=display:flex><span> <span style=color:#66d9ef>const</span> basic_value<span style=color:#f92672><</span>TC<span style=color:#f92672>>&</span> v, std<span style=color:#f92672>::</span>string msg, Ts<span style=color:#f92672>&&</span> ... tail);
|
||||
</span></span></code></pre></div><p>Calls <code>location()</code> on a <code>basic_value</code>, passes the resulting <code>source_location</code> to
|
||||
<a href=https://toruniina.github.io/toml11/docs/reference/error_info/#format_error><code>format_error</code></a>
|
||||
to create an <code>error_info</code>, then converts it to a string and returns it.</p><p>Refer to <a href=https://toruniina.github.io/toml11/docs/reference/error_info/><code>error_info</code></a> for more details.</p><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/types/>types.hpp</a></li><li><a href=https://toruniina.github.io/toml11/docs/reference/visit/>visit.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#valuehpp>value.hpp</a></li><li><a href=#tomlbasic_value><code>toml::basic_value</code></a><ul><li><a href=#member-types>Member Types</a></li><li><a href=#member-functions>Member Functions</a><ul><li><a href=#default-constructor>Default Constructor</a></li><li><a href=#copy-and-move-constructors>Copy and Move Constructors</a></li><li><a href=#copy-and-move-constructors-with-comments>Copy and Move Constructors with Comments</a></li><li><a href=#conversion-constructors>Conversion Constructors</a></li><li><a href=#constructor-boolean>Constructor (boolean)</a></li><li><a href=#constructor-integer>Constructor (integer)</a></li><li><a href=#constructor-floating>Constructor (floating)</a></li><li><a href=#constructor-string>Constructor (string)</a></li><li><a href=#constructor-local_date>Constructor (local_date)</a></li><li><a href=#constructor-local_time>Constructor (local_time)</a></li><li><a href=#constructor-local_datetime>Constructor (local_datetime)</a></li><li><a href=#constructor-offset_datetime>Constructor (offset_datetime)</a></li><li><a href=#constructor-array>Constructor (array)</a></li><li><a href=#constructor-table>Constructor (table)</a></li><li><a href=#constructor-user-defined>Constructor (user-defined)</a></li><li><a href=#operatorbasic_value><code>operator=(basic_value)</code></a></li><li><a href=#operatort><code>operator=(T)</code></a></li><li><a href=#ist><code>is<T>()</code></a></li><li><a href=#istomlvalue_t><code>is(toml::value_t)</code></a></li><li><a href=#is_xxx><code>is_xxx()</code></a></li><li><a href=#is_empty><code>is_empty()</code></a></li><li><a href=#is_array_of_tables><code>is_array_of_tables()</code></a></li><li><a href=#type><code>type()</code></a></li><li><a href=#as_xxx><code>as_xxx()</code></a></li><li><a href=#as_xxxstdnothrow><code>as_xxx(std::nothrow)</code></a></li><li><a href=#as_xxx_fmt><code>as_xxx_fmt()</code></a></li><li><a href=#as_xxx_fmtstdnothrow><code>as_xxx_fmt(std::nothrow)</code></a></li><li><a href=#atkey><code>at(key)</code></a></li><li><a href=#countkey><code>count(key)</code></a></li><li><a href=#containskey><code>contains(key)</code></a></li><li><a href=#atidx><code>at(idx)</code></a></li><li><a href=#operatoridx><code>operator[](idx)</code></a></li><li><a href=#push_backvalue><code>push_back(value)</code></a></li><li><a href=#emplace_backargs><code>emplace_back(args...)</code></a></li><li><a href=#size><code>size()</code></a></li><li><a href=#location><code>location()</code></a></li><li><a href=#comments><code>comments()</code></a></li><li><a href=#accessed><code>accessed()</code></a></li></ul></li><li><a href=#non-member-functions>Non-Member Functions</a><ul><li><a href=#operator><code>operator==</code></a></li><li><a href=#operator-1><code>operator!=</code></a></li><li><a href=#operator-2><code>operator<</code></a></li><li><a href=#operator-3><code>operator<=</code></a></li><li><a href=#operator-4><code>operator></code></a></li><li><a href=#operator-5><code>operator>=</code></a></li></ul></li></ul></li><li><a href=#tomltype_error><code>toml::type_error</code></a></li><li><a href=#tomlmake_error_info><code>toml::make_error_info</code></a></li><li><a href=#tomlformat_error><code>toml::format_error</code></a></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
74
docs/reference/value_t/index.html
Normal file
74
docs/reference/value_t/index.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
value_t.hpp
|
||||
#
|
||||
|
||||
|
||||
value_t
|
||||
#
|
||||
|
||||
value_t is used to handle the type information of toml::value.
|
||||
namespace toml
|
||||
{
|
||||
enum class value_t : std::uint8_t
|
||||
{
|
||||
empty = 0,
|
||||
boolean = 1,
|
||||
integer = 2,
|
||||
floating = 3,
|
||||
string = 4,
|
||||
offset_datetime = 5,
|
||||
local_datetime = 6,
|
||||
local_date = 7,
|
||||
local_time = 8,
|
||||
array = 9,
|
||||
table = 10
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, value_t t);
|
||||
std::string to_string(value_t t);
|
||||
} // toml
|
||||
|
||||
Non-member Functions
|
||||
#
|
||||
|
||||
|
||||
Stream Operator
|
||||
#
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, value_t t);
|
||||
Outputs the string representation of the value_t to the stream."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/value_t/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="value_t.hpp"><meta property="og:description" content="value_t.hpp # value_t # value_t is used to handle the type information of toml::value.
|
||||
namespace toml { enum class value_t : std::uint8_t { empty = 0, boolean = 1, integer = 2, floating = 3, string = 4, offset_datetime = 5, local_datetime = 6, local_date = 7, local_time = 8, array = 9, table = 10 }; std::ostream& operator<<(std::ostream& os, value_t t); std::string to_string(value_t t); } // toml Non-member Functions # Stream Operator # std::ostream& operator<<(std::ostream& os, value_t t); Outputs the string representation of the value_t to the stream."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>value_t.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/value_t/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/value_t/ title=value_t.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/value_t/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/ class=active>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>value_t.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#value_thpp>value_t.hpp</a></li><li><a href=#value_t><code>value_t</code></a><ul><li><a href=#non-member-functions>Non-member Functions</a><ul><li><a href=#stream-operator>Stream Operator</a></li><li><a href=#to_string><code>to_string</code></a></li></ul></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=value_thpp>value_t.hpp
|
||||
<a class=anchor href=#value_thpp>#</a></h1><h1 id=value_t><code>value_t</code>
|
||||
<a class=anchor href=#value_t>#</a></h1><p><code>value_t</code> is used to handle the type information of <code>toml::value</code>.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>enum</span> <span style=color:#66d9ef>class</span> <span style=color:#a6e22e>value_t</span> <span style=color:#f92672>:</span> std<span style=color:#f92672>::</span><span style=color:#66d9ef>uint8_t</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> empty <span style=color:#f92672>=</span> <span style=color:#ae81ff>0</span>,
|
||||
</span></span><span style=display:flex><span> boolean <span style=color:#f92672>=</span> <span style=color:#ae81ff>1</span>,
|
||||
</span></span><span style=display:flex><span> integer <span style=color:#f92672>=</span> <span style=color:#ae81ff>2</span>,
|
||||
</span></span><span style=display:flex><span> floating <span style=color:#f92672>=</span> <span style=color:#ae81ff>3</span>,
|
||||
</span></span><span style=display:flex><span> string <span style=color:#f92672>=</span> <span style=color:#ae81ff>4</span>,
|
||||
</span></span><span style=display:flex><span> offset_datetime <span style=color:#f92672>=</span> <span style=color:#ae81ff>5</span>,
|
||||
</span></span><span style=display:flex><span> local_datetime <span style=color:#f92672>=</span> <span style=color:#ae81ff>6</span>,
|
||||
</span></span><span style=display:flex><span> local_date <span style=color:#f92672>=</span> <span style=color:#ae81ff>7</span>,
|
||||
</span></span><span style=display:flex><span> local_time <span style=color:#f92672>=</span> <span style=color:#ae81ff>8</span>,
|
||||
</span></span><span style=display:flex><span> array <span style=color:#f92672>=</span> <span style=color:#ae81ff>9</span>,
|
||||
</span></span><span style=display:flex><span> table <span style=color:#f92672>=</span> <span style=color:#ae81ff>10</span>
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, value_t t);
|
||||
</span></span><span style=display:flex><span>std<span style=color:#f92672>::</span>string to_string(value_t t);
|
||||
</span></span><span style=display:flex><span>} <span style=color:#75715e>// toml
|
||||
</span></span></span></code></pre></div><h2 id=non-member-functions>Non-member Functions
|
||||
<a class=anchor href=#non-member-functions>#</a></h2><h3 id=stream-operator>Stream Operator
|
||||
<a class=anchor href=#stream-operator>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> <span style=color:#66d9ef>operator</span><span style=color:#f92672><<</span>(std<span style=color:#f92672>::</span>ostream<span style=color:#f92672>&</span> os, value_t t);
|
||||
</span></span></code></pre></div><p>Outputs the string representation of the <code>value_t</code> to the stream.</p><h3 id=to_string><code>to_string</code>
|
||||
<a class=anchor href=#to_string>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span>std<span style=color:#f92672>::</span>string to_string(value_t t);
|
||||
</span></span></code></pre></div><p>Returns the string representation of the <code>value_t</code>.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#value_thpp>value_t.hpp</a></li><li><a href=#value_t><code>value_t</code></a><ul><li><a href=#non-member-functions>Non-member Functions</a><ul><li><a href=#stream-operator>Stream Operator</a></li><li><a href=#to_string><code>to_string</code></a></li></ul></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
61
docs/reference/version/index.html
Normal file
61
docs/reference/version/index.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
version.hpp
|
||||
#
|
||||
|
||||
In version.hpp, macros related to the version information of toml11 are defined.
|
||||
|
||||
Macros
|
||||
#
|
||||
|
||||
|
||||
TOML11_VERSION_MAJOR
|
||||
#
|
||||
|
||||
The major version of toml11.
|
||||
|
||||
TOML11_VERSION_MINOR
|
||||
#
|
||||
|
||||
The minor version of toml11.
|
||||
|
||||
TOML11_VERSION_PATCH
|
||||
#
|
||||
|
||||
The patch version of toml11.
|
||||
|
||||
Function
|
||||
#
|
||||
|
||||
|
||||
license_notice
|
||||
#
|
||||
|
||||
namespace toml
|
||||
{
|
||||
const char* license_notice() noexcept;
|
||||
}
|
||||
Returns the license notice.
|
||||
Provided for convenience when redistributing without source code."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/version/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="version.hpp"><meta property="og:description" content="version.hpp # In version.hpp, macros related to the version information of toml11 are defined.
|
||||
Macros # TOML11_VERSION_MAJOR # The major version of toml11.
|
||||
TOML11_VERSION_MINOR # The minor version of toml11.
|
||||
TOML11_VERSION_PATCH # The patch version of toml11.
|
||||
Function # license_notice # namespace toml { const char* license_notice() noexcept; } Returns the license notice.
|
||||
Provided for convenience when redistributing without source code."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>version.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/version/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/version/ title=version.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/version/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/ class=active>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>version.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#versionhpp>version.hpp</a><ul><li><a href=#macros>Macros</a><ul><li><a href=#toml11_version_major><code>TOML11_VERSION_MAJOR</code></a></li><li><a href=#toml11_version_minor><code>TOML11_VERSION_MINOR</code></a></li><li><a href=#toml11_version_patch><code>TOML11_VERSION_PATCH</code></a></li></ul></li><li><a href=#function>Function</a><ul><li><a href=#license_notice><code>license_notice</code></a></li></ul></li></ul></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=versionhpp>version.hpp
|
||||
<a class=anchor href=#versionhpp>#</a></h1><p>In <code>version.hpp</code>, macros related to the version information of toml11 are defined.</p><h2 id=macros>Macros
|
||||
<a class=anchor href=#macros>#</a></h2><h3 id=toml11_version_major><code>TOML11_VERSION_MAJOR</code>
|
||||
<a class=anchor href=#toml11_version_major>#</a></h3><p>The major version of toml11.</p><h3 id=toml11_version_minor><code>TOML11_VERSION_MINOR</code>
|
||||
<a class=anchor href=#toml11_version_minor>#</a></h3><p>The minor version of toml11.</p><h3 id=toml11_version_patch><code>TOML11_VERSION_PATCH</code>
|
||||
<a class=anchor href=#toml11_version_patch>#</a></h3><p>The patch version of toml11.</p><h2 id=function>Function
|
||||
<a class=anchor href=#function>#</a></h2><h3 id=license_notice><code>license_notice</code>
|
||||
<a class=anchor href=#license_notice>#</a></h3><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>const</span> <span style=color:#66d9ef>char</span><span style=color:#f92672>*</span> <span style=color:#a6e22e>license_notice</span>() <span style=color:#66d9ef>noexcept</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p>Returns the license notice.</p><p>Provided for convenience when redistributing without source code.</p></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#versionhpp>version.hpp</a><ul><li><a href=#macros>Macros</a><ul><li><a href=#toml11_version_major><code>TOML11_VERSION_MAJOR</code></a></li><li><a href=#toml11_version_minor><code>TOML11_VERSION_MINOR</code></a></li><li><a href=#toml11_version_patch><code>TOML11_VERSION_PATCH</code></a></li></ul></li><li><a href=#function>Function</a><ul><li><a href=#license_notice><code>license_notice</code></a></li></ul></li></ul></li></ul></nav></div></aside></main></body></html>
|
||||
69
docs/reference/visit/index.html
Normal file
69
docs/reference/visit/index.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!doctype html><html lang=en dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="
|
||||
visit.hpp
|
||||
#
|
||||
|
||||
In visit.hpp, toml::visit is defined.
|
||||
|
||||
toml::visit
|
||||
#
|
||||
|
||||
|
||||
Functions
|
||||
#
|
||||
|
||||
namespace toml
|
||||
{
|
||||
template<typename Visitor, typename ... Args>
|
||||
/* Return value when Visitor is called with a value of basic_value<TC> */
|
||||
visit(Visitor&& visitor, Args&& ... args);
|
||||
}
|
||||
toml::visit calls the overload of Visitor corresponding to the type held by basic_value<TC>, and returns the result.
|
||||
|
||||
Requirements
|
||||
#
|
||||
|
||||
Visitor must be a function or function object callable with any type held by basic_value<TC>."><meta name=theme-color media="(prefers-color-scheme: light)" content="#ffffff"><meta name=theme-color media="(prefers-color-scheme: dark)" content="#343a40"><meta name=color-scheme content="light dark"><meta property="og:url" content="https://toruniina.github.io/toml11/docs/reference/visit/"><meta property="og:site_name" content="toml11"><meta property="og:title" content="visit.hpp"><meta property="og:description" content="visit.hpp # In visit.hpp, toml::visit is defined.
|
||||
toml::visit # Functions # namespace toml { template<typename Visitor, typename ... Args> /* Return value when Visitor is called with a value of basic_value<TC> */ visit(Visitor&& visitor, Args&& ... args); } toml::visit calls the overload of Visitor corresponding to the type held by basic_value<TC>, and returns the result.
|
||||
Requirements # Visitor must be a function or function object callable with any type held by basic_value<TC>."><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><title>visit.hpp | toml11</title><link rel=manifest href=/toml11/manifest.json><link rel=icon href=/toml11/favicon.png><link rel=canonical href=https://toruniina.github.io/toml11/docs/reference/visit/><link rel=alternate hreflang=ja href=https://toruniina.github.io/toml11/ja/docs/reference/visit/ title=visit.hpp><link rel=stylesheet href=/toml11/book.min.6d8037b375fe949eee1b70501c5fb9478914c9c5eb3ef7696163fd3031c69421.css integrity="sha256-bYA3s3X+lJ7uG3BQHF+5R4kUycXrPvdpYWP9MDHGlCE=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/en.search.min.87bec23503963d7026bfa3a917b92707789d315c9c9e005e23226b35dce643f5.js integrity="sha256-h77CNQOWPXAmv6OpF7knB3idMVycngBeIyJrNdzmQ/U=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
|
||||
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/toml11/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><script>document.querySelector(".book-search").classList.remove("hidden")</script><ul class=book-languages><li><input type=checkbox id=languages class=toggle>
|
||||
<label for=languages class="flex justify-between"><a role=button class="flex align-center"><img src=/toml11/svg/translate.svg class=book-icon alt=Languages>
|
||||
English</a></label><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/visit/>日本語</a></li></ul></li></ul><ul><li><a href=/toml11/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-291123c850af98d8b815ccdbb4c33657 class=toggle>
|
||||
<label for=section-291123c850af98d8b815ccdbb4c33657 class="flex justify-between"><a href=/toml11/docs/features/>features</a></label><ul><li><a href=/toml11/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/docs/features/value/>getting values</a></li><li><a href=/toml11/docs/features/error_message/>error message</a></li><li><a href=/toml11/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/docs/features/literal/>toml literal</a></li><li><a href=/toml11/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-e2e812e55021b82e114feaae98f1a02e class=toggle checked>
|
||||
<label for=section-e2e812e55021b82e114feaae98f1a02e class="flex justify-between"><a href=/toml11/docs/reference/>reference</a></label><ul><li><a href=/toml11/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/docs/reference/source_location/>source_location.hpp</a></li><li><a href=/toml11/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/docs/reference/visit/ class=active>visit.hpp</a></li></ul></li><li><a href=/toml11/docs/changelog/>changelog</a><ul></ul></li></ul><ul><li><a href=https://github.com/ToruNiina/toml11 target=_blank rel=noopener>GitHub</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/toml11/svg/menu.svg class=book-icon alt=Menu>
|
||||
</label><strong>visit.hpp</strong>
|
||||
<label for=toc-control><img src=/toml11/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#visithpp>visit.hpp</a></li><li><a href=#tomlvisit><code>toml::visit</code></a><ul><li><a href=#functions>Functions</a><ul><li></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></aside></header><article class="markdown book-article"><h1 id=visithpp>visit.hpp
|
||||
<a class=anchor href=#visithpp>#</a></h1><p>In <code>visit.hpp</code>, <code>toml::visit</code> is defined.</p><h1 id=tomlvisit><code>toml::visit</code>
|
||||
<a class=anchor href=#tomlvisit>#</a></h1><h2 id=functions>Functions
|
||||
<a class=anchor href=#functions>#</a></h2><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#66d9ef>namespace</span> toml
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>template</span><span style=color:#f92672><</span><span style=color:#66d9ef>typename</span> Visitor, <span style=color:#66d9ef>typename</span> ... Args<span style=color:#f92672>></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#75715e>/* Return value when Visitor is called with a value of basic_value<TC> */</span>
|
||||
</span></span><span style=display:flex><span>visit(Visitor<span style=color:#f92672>&&</span> visitor, Args<span style=color:#f92672>&&</span> ... args);
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><p><code>toml::visit</code> calls the overload of <code>Visitor</code> corresponding to the type held by <code>basic_value<TC></code>, and returns the result.</p><h4 id=requirements>Requirements
|
||||
<a class=anchor href=#requirements>#</a></h4><p><code>Visitor</code> must be a function or function object callable with any type held by <code>basic_value<TC></code>.</p><p>Additionally, the return value must be consistent across all overloads.</p><h4 id=example>Example
|
||||
<a class=anchor href=#example>#</a></h4><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><toml.hpp></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e>#include</span> <span style=color:#75715e><iostream></span><span style=color:#75715e>
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>struct</span> <span style=color:#a6e22e>type_name_of</span>
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>boolean_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"boolean"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>integer_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"integer"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>floating_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"floating"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>string_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"string"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>local_time_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"local_time"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>local_date_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"local_date"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>local_datetime_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"local_datetime"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>offset_datetime_type<span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"offset_datetime"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>array_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"array"</span>;}
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>string <span style=color:#66d9ef>operator</span>()(<span style=color:#66d9ef>const</span> toml<span style=color:#f92672>::</span>value<span style=color:#f92672>::</span>table_type <span style=color:#f92672>&</span>) <span style=color:#66d9ef>const</span> {<span style=color:#66d9ef>return</span> <span style=color:#e6db74>"table"</span>;}
|
||||
</span></span><span style=display:flex><span>};
|
||||
</span></span><span style=display:flex><span>
|
||||
</span></span><span style=display:flex><span><span style=color:#66d9ef>int</span> <span style=color:#a6e22e>main</span>()
|
||||
</span></span><span style=display:flex><span>{
|
||||
</span></span><span style=display:flex><span> toml<span style=color:#f92672>::</span>value v(<span style=color:#ae81ff>3.14</span>);
|
||||
</span></span><span style=display:flex><span> std<span style=color:#f92672>::</span>cout <span style=color:#f92672><<</span> toml<span style=color:#f92672>::</span>visit(type_name_of{}, v) <span style=color:#f92672><<</span> std<span style=color:#f92672>::</span>endl; <span style=color:#75715e>// floating
|
||||
</span></span></span><span style=display:flex><span><span style=color:#75715e></span> <span style=color:#66d9ef>return</span> <span style=color:#ae81ff>0</span>;
|
||||
</span></span><span style=display:flex><span>}
|
||||
</span></span></code></pre></div><h1 id=related>Related
|
||||
<a class=anchor href=#related>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/value/>value.hpp</a></li></ul></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#visithpp>visit.hpp</a></li><li><a href=#tomlvisit><code>toml::visit</code></a><ul><li><a href=#functions>Functions</a><ul><li></li></ul></li></ul></li><li><a href=#related>Related</a></li></ul></nav></div></aside></main></body></html>
|
||||
Reference in New Issue
Block a user