mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-20 04:38:09 +08:00
162 lines
30 KiB
HTML
162 lines
30 KiB
HTML
<!doctype html><html lang=ja 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では、TOMLファイル内のある領域を指すクラスが定義されます。
|
|
このクラスは、エラーメッセージで問題の箇所を指摘するために使われます。
|
|
|
|
toml::source_location
|
|
#
|
|
|
|
source_locationは、TOMLファイル内のある領域を指すクラスです。
|
|
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
|
|
|
|
メンバ関数
|
|
#
|
|
|
|
|
|
コンストラクタ
|
|
#
|
|
|
|
explicit source_location(/* implementation-defined */);
|
|
toml::source_locationをtoml::parseまたは_tomlリテラル以外で構築することはできません。"><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/ja/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では、TOMLファイル内のある領域を指すクラスが定義されます。
|
|
このクラスは、エラーメッセージで問題の箇所を指摘するために使われます。
|
|
toml::source_location # source_locationは、TOMLファイル内のある領域を指すクラスです。
|
|
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 メンバ関数 # コンストラクタ # explicit source_location(/* implementation-defined */); toml::source_locationをtoml::parseまたは_tomlリテラル以外で構築することはできません。"><meta property="og:locale" content="ja"><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/ja/docs/reference/source_location/><link rel=alternate hreflang=en href=https://toruniina.github.io/toml11/docs/reference/source_location/ title=source_location.hpp><link rel=stylesheet href=/toml11/book.min.ddac3efe7ea4c1007ff53e5a8fd67f12517e5d2e99984d8c67a18668f7ecaa03.css integrity="sha256-3aw+/n6kwQB/9T5aj9Z/ElF+XS6ZmE2MZ6GGaPfsqgM=" crossorigin=anonymous><script defer src=/toml11/fuse.min.js></script><script defer src=/toml11/ja.search.min.13aefbf6a803b591c02d5bc9a01dfe65fe37c31e2915c91573708d38e805d86c.js integrity="sha256-E6779qgDtZHALVvJoB3+Zf43wx4pFckVc3CNOOgF2Gw=" 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/ja/><span>toml11</span></a></h2><div class="book-search hidden"><input type=text id=book-search-input placeholder=検索 aria-label=検索 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>
|
|
日本語</a></label><ul><li><a href=https://toruniina.github.io/toml11/docs/reference/source_location/>English</a></li></ul></li></ul><ul><li><a href=/toml11/ja/docs/installation/>installation</a><ul></ul></li><li><input type=checkbox id=section-b4cfb5b55e913a8d853eacf5e8fba05f class=toggle>
|
|
<label for=section-b4cfb5b55e913a8d853eacf5e8fba05f class="flex justify-between"><a href=/toml11/ja/docs/features/>features</a></label><ul><li><a href=/toml11/ja/docs/features/parsing_files/>parsing files</a></li><li><a href=/toml11/ja/docs/features/value/>getting values</a></li><li><a href=/toml11/ja/docs/features/error_message/>error message</a></li><li><a href=/toml11/ja/docs/features/serialize/>serializing values</a></li><li><a href=/toml11/ja/docs/features/configure_types/>configuring types</a></li><li><a href=/toml11/ja/docs/features/literal/>toml literal</a></li><li><a href=/toml11/ja/docs/features/toml_spec/>toml spec</a></li><li><a href=/toml11/ja/docs/features/extension/>extension</a></li></ul></li><li><input type=checkbox id=section-01b096afc5186aea96713b408b47c967 class=toggle checked>
|
|
<label for=section-01b096afc5186aea96713b408b47c967 class="flex justify-between"><a href=/toml11/ja/docs/reference/>reference</a></label><ul><li><a href=/toml11/ja/docs/reference/color/>color.hpp</a></li><li><a href=/toml11/ja/docs/reference/comments/>comments.hpp</a></li><li><a href=/toml11/ja/docs/reference/conversion/>conversion.hpp</a></li><li><a href=/toml11/ja/docs/reference/datetime/>datetime.hpp</a></li><li><a href=/toml11/ja/docs/reference/error_info/>error_info.hpp</a></li><li><a href=/toml11/ja/docs/reference/exception/>exception.hpp</a></li><li><a href=/toml11/ja/docs/reference/find/>find.hpp</a></li><li><a href=/toml11/ja/docs/reference/format/>format.hpp</a></li><li><a href=/toml11/ja/docs/reference/from/>from.hpp</a></li><li><a href=/toml11/ja/docs/reference/get/>get.hpp</a></li><li><a href=/toml11/ja/docs/reference/into/>into.hpp</a></li><li><a href=/toml11/ja/docs/reference/literal/>literal.hpp</a></li><li><a href=/toml11/ja/docs/reference/ordered_map/>ordered_map.hpp</a></li><li><a href=/toml11/ja/docs/reference/parser/>parser.hpp</a></li><li><a href=/toml11/ja/docs/reference/result/>result.hpp</a></li><li><a href=/toml11/ja/docs/reference/serializer/>serializer.hpp</a></li><li><a href=/toml11/ja/docs/reference/source_location/ class=active>source_location.hpp</a></li><li><a href=/toml11/ja/docs/reference/spec/>spec.hpp</a></li><li><a href=/toml11/ja/docs/reference/toml_fwd/>toml_fwd.hpp</a></li><li><a href=/toml11/ja/docs/reference/toml/>toml.hpp</a></li><li><a href=/toml11/ja/docs/reference/types/>types.hpp</a></li><li><a href=/toml11/ja/docs/reference/value_t/>value_t.hpp</a></li><li><a href=/toml11/ja/docs/reference/value/>value.hpp</a></li><li><a href=/toml11/ja/docs/reference/version/>version.hpp</a></li><li><a href=/toml11/ja/docs/reference/visit/>visit.hpp</a></li></ul></li><li><a href=/toml11/ja/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=#メンバ関数>メンバ関数</a><ul><li><a href=#コンストラクタ>コンストラクタ</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=#非メンバ関数>非メンバ関数</a><ul><li><a href=#format_location><code>format_location</code></a></li></ul></li></ul></li><li><a href=#関連項目>関連項目</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>では、TOMLファイル内のある領域を指すクラスが定義されます。</p><p>このクラスは、エラーメッセージで問題の箇所を指摘するために使われます。</p><h1 id=tomlsource_location><code>toml::source_location</code>
|
|
<a class=anchor href=#tomlsource_location>#</a></h1><p><code>source_location</code>は、TOMLファイル内のある領域を指すクラスです。</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=メンバ関数>メンバ関数
|
|
<a class=anchor href=#%e3%83%a1%e3%83%b3%e3%83%90%e9%96%a2%e6%95%b0>#</a></h2><h3 id=コンストラクタ>コンストラクタ
|
|
<a class=anchor href=#%e3%82%b3%e3%83%b3%e3%82%b9%e3%83%88%e3%83%a9%e3%82%af%e3%82%bf>#</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>を<code>toml::parse</code>または<code>_toml</code>リテラル以外で構築することはできません。</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><code>source_location</code>が有効な値を保持している場合、<code>true</code>を、そうでない場合<code>false</code>を返します。</p><p><code>toml::parse</code>や<code>_toml</code>リテラル以外から構築した<code>toml::value</code>の<code>location()</code>の結果は、指す対象がないため、<code>is_ok</code>は<code>false</code>を返します。</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><code>source_location</code>が指す領域の長さを返します。</p><p>有効な値を保持していない場合、<code>0</code>を返します。</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><code>source_location</code>が指す領域の最初の行の行番号を返します。</p><p>有効な値を保持していない場合、<code>1</code>を返します。</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><code>source_location</code>が指す領域の最初の列の列番号を返します。</p><p>有効な値を保持していない場合、<code>1</code>を返します。</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><code>source_location</code>が指す領域の最後の行の行番号を返します。</p><p>有効な値を保持していない場合、<code>1</code>を返します。</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><code>source_location</code>が指す領域の最後の列の列番号を返します。</p><p>有効な値を保持していない場合、<code>1</code>を返します。</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><code>source_location</code>が指す領域を含むファイルのファイル名を返します。</p><p>有効な値を保持していない場合、<code>"unknown file"</code>を返します。</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><code>source_location</code>が指す領域の行数を返します。</p><p>有効な値を保持していない場合、<code>0</code>を返します。</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><code>source_location</code>が指す領域の最初の行を返します。</p><p>有効な値を保持していない場合、<code>std::out_of_range</code>例外が送出されます。</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><code>source_location</code>が指す領域の最後の行を返します。</p><p>有効な値を保持していない場合、<code>std::out_of_range</code>例外が送出されます。</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><code>source_location</code>が指す領域の全ての行を返します。</p><p>有効な値を保持していない場合、空の<code>std::vector</code>への参照を返します。</p><h2 id=非メンバ関数>非メンバ関数
|
|
<a class=anchor href=#%e9%9d%9e%e3%83%a1%e3%83%b3%e3%83%90%e9%96%a2%e6%95%b0>#</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 style=color:#66d9ef>const</span> Ts<span style=color:#f92672>&</span> ... locs_and_msgs);
|
|
</span></span></code></pre></div><p><code>source_location</code>が指す箇所と、それについてのメッセージを以下のようにフォーマットします。</p><pre tabindex=0><code> -> {filename.toml}
|
|
|
|
|
1 | a = 42
|
|
| ^-- {message}
|
|
</code></pre><p>この時、色付けがONになっている場合、ANSIエスケープシーケンスによって色情報が追加されます。</p><p>locs_and_msgsが複数個ある場合、それらは<code>const source_location&</code>と<code>const std::string&</code>の順である必要があります。</p><h4 id=例複数のsource_locationとstdstring>例:複数の<code>source_location</code>と<code>std::string</code>
|
|
<a class=anchor href=#%e4%be%8b%e8%a4%87%e6%95%b0%e3%81%aesource_location%e3%81%a8stdstring>#</a></h4><p>複数の<code>source_location</code>と<code>std::string</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>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=関連項目>関連項目
|
|
<a class=anchor href=#%e9%96%a2%e9%80%a3%e9%a0%85%e7%9b%ae>#</a></h1><ul><li><a href=https://toruniina.github.io/toml11/ja/docs/reference/error_info/>error_info.hpp</a></li><li><a href=https://toruniina.github.io/toml11/ja/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=#メンバ関数>メンバ関数</a><ul><li><a href=#コンストラクタ>コンストラクタ</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=#非メンバ関数>非メンバ関数</a><ul><li><a href=#format_location><code>format_location</code></a></li></ul></li></ul></li><li><a href=#関連項目>関連項目</a></li></ul></nav></div></aside></main></body></html> |