Files
rippled/owners_8cpp_source.html
2024-01-12 17:45:35 +00:00

158 lines
20 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: owners.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_120ed4da3e3217b1e7fc0b4f48568e79.html">test</a></li><li class="navelem"><a class="el" href="dir_ffd09a46879067226d7ad9ce2abbf5ef.html">jtx</a></li><li class="navelem"><a class="el" href="dir_b6e1af3af959840d44bdaef0b719b3f9.html">impl</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">owners.cpp</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">//------------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"> This file is part of rippled: https://github.com/ripple/rippled</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> Copyright (c) 2012, 2013 Ripple Labs Inc.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> Permission to use, copy, modify, and/or distribute this software for any</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment"> purpose with or without fee is hereby granted, provided that the above</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment"> copyright notice and this permission notice appear in all copies.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment"> THE SOFTWARE IS PROVIDED &quot;AS IS&quot; AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment"> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment"> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"> ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment"> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment"> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment"> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment">*/</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment">//==============================================================================</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;test/jtx/owners.h&gt;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160; </div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="keyword">namespace </span>test {</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="keyword">namespace </span>jtx {</div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="keyword">namespace </span>detail {</div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<a class="codeRef" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a></div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="namespaceripple_1_1test_1_1jtx_1_1detail.html#a23ff162f378b858613247f4d4237eabb"> 29</a></span>&#160;<a class="code" href="namespaceripple_1_1test_1_1jtx_1_1detail.html#a23ff162f378b858613247f4d4237eabb">owned_count_of</a>(<a class="code" href="classripple_1_1ReadView.html">ReadView</a> <span class="keyword">const</span>&amp; view, <a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span>&amp; <span class="keywordtype">id</span>, <a class="code" href="namespaceripple.html#ac151bf19e1f4daae2b04c65c65117139">LedgerEntryType</a> type)</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;{</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> count = 0;</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <a class="code" href="namespaceripple.html#accc8ce88b24f653a30e40f7d22e428c5">forEachItem</a>(</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; view, <span class="keywordtype">id</span>, [&amp;count, type](<a class="codeRef" href="http://en.cppreference.com/w/cpp/memory/shared_ptr.html">std::shared_ptr&lt;SLE const&gt;</a> <span class="keyword">const</span>&amp; sle) {</div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <span class="keywordflow">if</span> (sle-&gt;getType() == type)</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; ++count;</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; });</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keywordflow">return</span> count;</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;}</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; </div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="keywordtype">void</span></div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="namespaceripple_1_1test_1_1jtx_1_1detail.html#ab2554af4bd7864d80e4d605d6690386c"> 41</a></span>&#160;<a class="code" href="namespaceripple_1_1test_1_1jtx_1_1detail.html#ab2554af4bd7864d80e4d605d6690386c">owned_count_helper</a>(</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; <a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html">Env</a>&amp; env,</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; <a class="code" href="classripple_1_1base__uint.html">AccountID</a> <span class="keyword">const</span>&amp; <span class="keywordtype">id</span>,</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <a class="code" href="namespaceripple.html#ac151bf19e1f4daae2b04c65c65117139">LedgerEntryType</a> type,</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <a class="codeRef" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a> value)</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;{</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; env.<a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html#a404fe165c9a8096d23b0ec3f2f99dada">test</a>.expect(<a class="code" href="namespaceripple_1_1test_1_1jtx_1_1detail.html#a23ff162f378b858613247f4d4237eabb">owned_count_of</a>(*env.<a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html#ace0420a6e752f5dc5400df6f2097647e">current</a>(), <span class="keywordtype">id</span>, type) == value);</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;}</div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;} <span class="comment">// namespace detail</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="keywordtype">void</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classripple_1_1test_1_1jtx_1_1owners.html#a3a90197b4b46f3c97c9c17fc6dd89953"> 53</a></span>&#160;<a class="code" href="classripple_1_1test_1_1jtx_1_1owners.html#a3a90197b4b46f3c97c9c17fc6dd89953">owners::operator()</a>(<a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html">Env</a>&amp; env)<span class="keyword"> const</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; env.<a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html#a404fe165c9a8096d23b0ec3f2f99dada">test</a>.expect(env.<a class="code" href="classripple_1_1test_1_1jtx_1_1Env.html#ad63e69c823183e7e8991752b1cf8985f">le</a>(<a class="code" href="classripple_1_1test_1_1jtx_1_1owners.html#a846ccfd84a42e27522b659c2535e2948">account_</a>)-&gt;getFieldU32(<a class="code" href="namespaceripple.html#aee6c41ec9be20b8705502ae9290ef2b0">sfOwnerCount</a>) == <a class="code" href="classripple_1_1test_1_1jtx_1_1owners.html#a153ab4bb76eca720ded3d424957f7a92">value_</a>);</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;}</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;} <span class="comment">// namespace jtx</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;} <span class="comment">// namespace test</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;} <span class="comment">// namespace ripple</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="anamespaceripple_html_aee6c41ec9be20b8705502ae9290ef2b0"><div class="ttname"><a href="namespaceripple.html#aee6c41ec9be20b8705502ae9290ef2b0">ripple::sfOwnerCount</a></div><div class="ttdeci">const SF_UINT32 sfOwnerCount</div></div>
<div class="ttc" id="ashared_ptr_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/memory/shared_ptr.html">std::shared_ptr</a></div><div class="ttdoc">STL class.</div></div>
<div class="ttc" id="anamespaceripple_1_1test_1_1jtx_1_1detail_html_a23ff162f378b858613247f4d4237eabb"><div class="ttname"><a href="namespaceripple_1_1test_1_1jtx_1_1detail.html#a23ff162f378b858613247f4d4237eabb">ripple::test::jtx::detail::owned_count_of</a></div><div class="ttdeci">std::uint32_t owned_count_of(ReadView const &amp;view, AccountID const &amp;id, LedgerEntryType type)</div><div class="ttdef"><b>Definition:</b> <a href="owners_8cpp_source.html#l00029">owners.cpp:29</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1owners_html_a846ccfd84a42e27522b659c2535e2948"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1owners.html#a846ccfd84a42e27522b659c2535e2948">ripple::test::jtx::owners::account_</a></div><div class="ttdeci">Account account_</div><div class="ttdef"><b>Definition:</b> <a href="owners_8h_source.html#l00072">owners.h:72</a></div></div>
<div class="ttc" id="anamespaceripple_1_1test_1_1jtx_1_1detail_html_ab2554af4bd7864d80e4d605d6690386c"><div class="ttname"><a href="namespaceripple_1_1test_1_1jtx_1_1detail.html#ab2554af4bd7864d80e4d605d6690386c">ripple::test::jtx::detail::owned_count_helper</a></div><div class="ttdeci">void owned_count_helper(Env &amp;env, AccountID const &amp;id, LedgerEntryType type, std::uint32_t value)</div><div class="ttdef"><b>Definition:</b> <a href="owners_8cpp_source.html#l00041">owners.cpp:41</a></div></div>
<div class="ttc" id="aclassripple_1_1base__uint_html"><div class="ttname"><a href="classripple_1_1base__uint.html">ripple::base_uint&lt; 160, detail::AccountIDTag &gt;</a></div></div>
<div class="ttc" id="ainteger_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1Env_html_a404fe165c9a8096d23b0ec3f2f99dada"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1Env.html#a404fe165c9a8096d23b0ec3f2f99dada">ripple::test::jtx::Env::test</a></div><div class="ttdeci">beast::unit_test::suite &amp; test</div><div class="ttdef"><b>Definition:</b> <a href="Env_8h_source.html#l00119">Env.h:119</a></div></div>
<div class="ttc" id="aclassripple_1_1ReadView_html"><div class="ttname"><a href="classripple_1_1ReadView.html">ripple::ReadView</a></div><div class="ttdoc">A view into a ledger.</div><div class="ttdef"><b>Definition:</b> <a href="ReadView_8h_source.html#l00054">ReadView.h:54</a></div></div>
<div class="ttc" id="anamespaceripple_html"><div class="ttname"><a href="namespaceripple.html">ripple</a></div><div class="ttdoc">Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="RCLCensorshipDetector_8h_source.html#l00029">RCLCensorshipDetector.h:29</a></div></div>
<div class="ttc" id="anamespaceripple_html_ac151bf19e1f4daae2b04c65c65117139"><div class="ttname"><a href="namespaceripple.html#ac151bf19e1f4daae2b04c65c65117139">ripple::LedgerEntryType</a></div><div class="ttdeci">LedgerEntryType</div><div class="ttdoc">Identifiers for on-ledger objects.</div><div class="ttdef"><b>Definition:</b> <a href="LedgerFormats_8h_source.html#l00053">LedgerFormats.h:53</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1Env_html_ad63e69c823183e7e8991752b1cf8985f"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1Env.html#ad63e69c823183e7e8991752b1cf8985f">ripple::test::jtx::Env::le</a></div><div class="ttdeci">std::shared_ptr&lt; SLE const &gt; le(Account const &amp;account) const</div><div class="ttdoc">Return an account root.</div><div class="ttdef"><b>Definition:</b> <a href="Env_8cpp_source.html#l00216">Env.cpp:216</a></div></div>
<div class="ttc" id="anamespaceripple_html_accc8ce88b24f653a30e40f7d22e428c5"><div class="ttname"><a href="namespaceripple.html#accc8ce88b24f653a30e40f7d22e428c5">ripple::forEachItem</a></div><div class="ttdeci">void forEachItem(ReadView const &amp;view, Keylet const &amp;root, std::function&lt; void(std::shared_ptr&lt; SLE const &gt; const &amp;)&gt; const &amp;f)</div><div class="ttdoc">Iterate all items in the given directory.</div><div class="ttdef"><b>Definition:</b> <a href="View_8cpp_source.html#l00384">View.cpp:384</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1owners_html_a3a90197b4b46f3c97c9c17fc6dd89953"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1owners.html#a3a90197b4b46f3c97c9c17fc6dd89953">ripple::test::jtx::owners::operator()</a></div><div class="ttdeci">void operator()(Env &amp;env) const</div><div class="ttdef"><b>Definition:</b> <a href="owners_8cpp_source.html#l00053">owners.cpp:53</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1owners_html_a153ab4bb76eca720ded3d424957f7a92"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1owners.html#a153ab4bb76eca720ded3d424957f7a92">ripple::test::jtx::owners::value_</a></div><div class="ttdeci">std::uint32_t value_</div><div class="ttdef"><b>Definition:</b> <a href="owners_8h_source.html#l00073">owners.h:73</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1Env_html_ace0420a6e752f5dc5400df6f2097647e"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1Env.html#ace0420a6e752f5dc5400df6f2097647e">ripple::test::jtx::Env::current</a></div><div class="ttdeci">std::shared_ptr&lt; OpenView const &gt; current() const</div><div class="ttdoc">Returns the current ledger.</div><div class="ttdef"><b>Definition:</b> <a href="Env_8h_source.html#l00311">Env.h:311</a></div></div>
<div class="ttc" id="aclassripple_1_1test_1_1jtx_1_1Env_html"><div class="ttname"><a href="classripple_1_1test_1_1jtx_1_1Env.html">ripple::test::jtx::Env</a></div><div class="ttdoc">A transaction testing environment.</div><div class="ttdef"><b>Definition:</b> <a href="Env_8h_source.html#l00116">Env.h:116</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>