• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6<meta name="generator" content="Doxygen 1.8.15"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>Oboe: oboe::ResultWithValue&lt; T &gt; Class Template Reference</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16</head>
17<body>
18<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19<div id="titlearea">
20<table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr style="height: 56px;">
23  <td id="projectalign" style="padding-left: 0.5em;">
24   <div id="projectname">Oboe
25   &#160;<span id="projectnumber">1.5</span>
26   </div>
27   <div id="projectbrief">A library for creating real-time audio apps on Android</div>
28  </td>
29 </tr>
30 </tbody>
31</table>
32</div>
33<!-- end header part -->
34<!-- Generated by Doxygen 1.8.15 -->
35<script type="text/javascript">
36/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
37var searchBox = new SearchBox("searchBox", "search",false,'Search');
38/* @license-end */
39</script>
40<script type="text/javascript" src="menudata.js"></script>
41<script type="text/javascript" src="menu.js"></script>
42<script type="text/javascript">
43/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
44$(function() {
45  initMenu('',true,false,'search.php','Search');
46  $(document).ready(function() { init_search(); });
47});
48/* @license-end */</script>
49<div id="main-nav"></div>
50<!-- window showing the filter options -->
51<div id="MSearchSelectWindow"
52     onmouseover="return searchBox.OnSearchSelectShow()"
53     onmouseout="return searchBox.OnSearchSelectHide()"
54     onkeydown="return searchBox.OnSearchSelectKey(event)">
55</div>
56
57<!-- iframe showing the search results (closed by default) -->
58<div id="MSearchResultsWindow">
59<iframe src="javascript:void(0)" frameborder="0"
60        name="MSearchResults" id="MSearchResults">
61</iframe>
62</div>
63
64<div id="nav-path" class="navpath">
65  <ul>
66<li class="navelem"><a class="el" href="namespaceoboe.html">oboe</a></li><li class="navelem"><a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a></li>  </ul>
67</div>
68</div><!-- top -->
69<div class="header">
70  <div class="summary">
71<a href="#pub-methods">Public Member Functions</a> &#124;
72<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
73<a href="classoboe_1_1_result_with_value-members.html">List of all members</a>  </div>
74  <div class="headertitle">
75<div class="title">oboe::ResultWithValue&lt; T &gt; Class Template Reference</div>  </div>
76</div><!--header-->
77<div class="contents">
78
79<p><code>#include &lt;<a class="el" href="_result_with_value_8h_source.html">ResultWithValue.h</a>&gt;</code></p>
80<table class="memberdecls">
81<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
82Public Member Functions</h2></td></tr>
83<tr class="memitem:aae75caa0d16a9e23a012f77fb50c5927"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#aae75caa0d16a9e23a012f77fb50c5927">ResultWithValue</a> (<a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a> <a class="el" href="classoboe_1_1_result_with_value.html#adfc76ae6db81535c2e82b856975eed41">error</a>)</td></tr>
84<tr class="separator:aae75caa0d16a9e23a012f77fb50c5927"><td class="memSeparator" colspan="2">&#160;</td></tr>
85<tr class="memitem:a600309367db58d71f0ec16e90f7ebea5"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a600309367db58d71f0ec16e90f7ebea5">ResultWithValue</a> (T <a class="el" href="classoboe_1_1_result_with_value.html#a45f5c99a2c9f8fbaca502276f7ebb434">value</a>)</td></tr>
86<tr class="separator:a600309367db58d71f0ec16e90f7ebea5"><td class="memSeparator" colspan="2">&#160;</td></tr>
87<tr class="memitem:adfc76ae6db81535c2e82b856975eed41"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#adfc76ae6db81535c2e82b856975eed41">error</a> () const</td></tr>
88<tr class="separator:adfc76ae6db81535c2e82b856975eed41"><td class="memSeparator" colspan="2">&#160;</td></tr>
89<tr class="memitem:a45f5c99a2c9f8fbaca502276f7ebb434"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a45f5c99a2c9f8fbaca502276f7ebb434">value</a> () const</td></tr>
90<tr class="separator:a45f5c99a2c9f8fbaca502276f7ebb434"><td class="memSeparator" colspan="2">&#160;</td></tr>
91<tr class="memitem:ae32b1953b777af7d1d0c94862ca39986"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#ae32b1953b777af7d1d0c94862ca39986">operator bool</a> () const</td></tr>
92<tr class="separator:ae32b1953b777af7d1d0c94862ca39986"><td class="memSeparator" colspan="2">&#160;</td></tr>
93<tr class="memitem:a6fb3c61c5716a045ba48dc5a5dfc8169"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a6fb3c61c5716a045ba48dc5a5dfc8169">operator !</a> () const</td></tr>
94<tr class="separator:a6fb3c61c5716a045ba48dc5a5dfc8169"><td class="memSeparator" colspan="2">&#160;</td></tr>
95<tr class="memitem:af62107817c0bc76047e6b655a78504ba"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#af62107817c0bc76047e6b655a78504ba">operator Result</a> () const</td></tr>
96<tr class="separator:af62107817c0bc76047e6b655a78504ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
97</table><table class="memberdecls">
98<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
99Static Public Member Functions</h2></td></tr>
100<tr class="memitem:a2304c6120e2aad8f2189383a98c7b0a7"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a>&lt; T &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_result_with_value.html#a2304c6120e2aad8f2189383a98c7b0a7">createBasedOnSign</a> (T numericResult)</td></tr>
101<tr class="separator:a2304c6120e2aad8f2189383a98c7b0a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
102</table>
103<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
104<div class="textblock"><h3>template&lt;typename T&gt;<br />
105class oboe::ResultWithValue&lt; T &gt;</h3>
106
107<p>A <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> can store both the result of an operation (either OK or an error) and a value.</p>
108<p>It has been designed for cases where the caller needs to know whether an operation succeeded and, if it did, a value which was obtained during the operation.</p>
109<p>For example, when reading from a stream the caller needs to know the result of the read operation and, if it was successful, how many frames were read. Note that <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> can be evaluated as a boolean so it's simple to check whether the result is OK.</p>
110<p><code> ResultWithValue&lt;int32_t&gt; resultOfRead = myStream.read(&amp;buffer, numFrames, timeoutNanoseconds);</code></p>
111<p><code>if (resultOfRead) { LOGD("Frames read: %d", resultOfRead.value()); } else { LOGD("Error reading from stream: %s", resultOfRead.error()); } </code> </p>
112</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
113<a id="aae75caa0d16a9e23a012f77fb50c5927"></a>
114<h2 class="memtitle"><span class="permalink"><a href="#aae75caa0d16a9e23a012f77fb50c5927">&#9670;&nbsp;</a></span>ResultWithValue() <span class="overload">[1/2]</span></h2>
115
116<div class="memitem">
117<div class="memproto">
118<div class="memtemplate">
119template&lt;typename T&gt; </div>
120<table class="mlabels">
121  <tr>
122  <td class="mlabels-left">
123      <table class="memname">
124        <tr>
125          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::<a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> </td>
126          <td>(</td>
127          <td class="paramtype"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a>&#160;</td>
128          <td class="paramname"><em>error</em></td><td>)</td>
129          <td></td>
130        </tr>
131      </table>
132  </td>
133  <td class="mlabels-right">
134<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
135  </tr>
136</table>
137</div><div class="memdoc">
138<p>Construct a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> containing an error result.</p>
139<dl class="params"><dt>Parameters</dt><dd>
140  <table class="params">
141    <tr><td class="paramname">error</td><td>The error </td></tr>
142  </table>
143  </dd>
144</dl>
145
146</div>
147</div>
148<a id="a600309367db58d71f0ec16e90f7ebea5"></a>
149<h2 class="memtitle"><span class="permalink"><a href="#a600309367db58d71f0ec16e90f7ebea5">&#9670;&nbsp;</a></span>ResultWithValue() <span class="overload">[2/2]</span></h2>
150
151<div class="memitem">
152<div class="memproto">
153<div class="memtemplate">
154template&lt;typename T&gt; </div>
155<table class="mlabels">
156  <tr>
157  <td class="mlabels-left">
158      <table class="memname">
159        <tr>
160          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::<a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> </td>
161          <td>(</td>
162          <td class="paramtype">T&#160;</td>
163          <td class="paramname"><em>value</em></td><td>)</td>
164          <td></td>
165        </tr>
166      </table>
167  </td>
168  <td class="mlabels-right">
169<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
170  </tr>
171</table>
172</div><div class="memdoc">
173<p>Construct a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> containing an OK result and a value.</p>
174<dl class="params"><dt>Parameters</dt><dd>
175  <table class="params">
176    <tr><td class="paramname">value</td><td>the value to store </td></tr>
177  </table>
178  </dd>
179</dl>
180
181</div>
182</div>
183<h2 class="groupheader">Member Function Documentation</h2>
184<a id="a2304c6120e2aad8f2189383a98c7b0a7"></a>
185<h2 class="memtitle"><span class="permalink"><a href="#a2304c6120e2aad8f2189383a98c7b0a7">&#9670;&nbsp;</a></span>createBasedOnSign()</h2>
186
187<div class="memitem">
188<div class="memproto">
189<div class="memtemplate">
190template&lt;typename T&gt; </div>
191<table class="mlabels">
192  <tr>
193  <td class="mlabels-left">
194      <table class="memname">
195        <tr>
196          <td class="memname">static <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a>&lt;T&gt; <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::createBasedOnSign </td>
197          <td>(</td>
198          <td class="paramtype">T&#160;</td>
199          <td class="paramname"><em>numericResult</em></td><td>)</td>
200          <td></td>
201        </tr>
202      </table>
203  </td>
204  <td class="mlabels-right">
205<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
206  </tr>
207</table>
208</div><div class="memdoc">
209<p>Create a <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> from a number. If the number is positive the <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> will have a result of Result::OK and the value will contain the number. If the number is negative the result will be obtained from the negative number (numeric error codes can be found in AAudio.h) and the value will be null. </p>
210
211</div>
212</div>
213<a id="adfc76ae6db81535c2e82b856975eed41"></a>
214<h2 class="memtitle"><span class="permalink"><a href="#adfc76ae6db81535c2e82b856975eed41">&#9670;&nbsp;</a></span>error()</h2>
215
216<div class="memitem">
217<div class="memproto">
218<div class="memtemplate">
219template&lt;typename T&gt; </div>
220<table class="mlabels">
221  <tr>
222  <td class="mlabels-left">
223      <table class="memname">
224        <tr>
225          <td class="memname"><a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a> <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::error </td>
226          <td>(</td>
227          <td class="paramname"></td><td>)</td>
228          <td> const</td>
229        </tr>
230      </table>
231  </td>
232  <td class="mlabels-right">
233<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
234  </tr>
235</table>
236</div><div class="memdoc">
237<p>Get the result.</p>
238<dl class="section return"><dt>Returns</dt><dd>the result </dd></dl>
239
240</div>
241</div>
242<a id="a6fb3c61c5716a045ba48dc5a5dfc8169"></a>
243<h2 class="memtitle"><span class="permalink"><a href="#a6fb3c61c5716a045ba48dc5a5dfc8169">&#9670;&nbsp;</a></span>operator !()</h2>
244
245<div class="memitem">
246<div class="memproto">
247<div class="memtemplate">
248template&lt;typename T&gt; </div>
249<table class="mlabels">
250  <tr>
251  <td class="mlabels-left">
252      <table class="memname">
253        <tr>
254          <td class="memname">bool <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator ! </td>
255          <td>(</td>
256          <td class="paramname"></td><td>)</td>
257          <td> const</td>
258        </tr>
259      </table>
260  </td>
261  <td class="mlabels-right">
262<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
263  </tr>
264</table>
265</div><div class="memdoc">
266<p>Quick way to check for an error.</p>
267<p>The caller could write something like this: <code> if (!result) { printf("Got error %s\n", convertToText(result.error())); } </code></p>
268<dl class="section return"><dt>Returns</dt><dd>true if an error occurred </dd></dl>
269
270</div>
271</div>
272<a id="ae32b1953b777af7d1d0c94862ca39986"></a>
273<h2 class="memtitle"><span class="permalink"><a href="#ae32b1953b777af7d1d0c94862ca39986">&#9670;&nbsp;</a></span>operator bool()</h2>
274
275<div class="memitem">
276<div class="memproto">
277<div class="memtemplate">
278template&lt;typename T&gt; </div>
279<table class="mlabels">
280  <tr>
281  <td class="mlabels-left">
282      <table class="memname">
283        <tr>
284          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator bool </td>
285          <td>(</td>
286          <td class="paramname"></td><td>)</td>
287          <td> const</td>
288        </tr>
289      </table>
290  </td>
291  <td class="mlabels-right">
292<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span>  </td>
293  </tr>
294</table>
295</div><div class="memdoc">
296<dl class="section return"><dt>Returns</dt><dd>true if OK </dd></dl>
297
298</div>
299</div>
300<a id="af62107817c0bc76047e6b655a78504ba"></a>
301<h2 class="memtitle"><span class="permalink"><a href="#af62107817c0bc76047e6b655a78504ba">&#9670;&nbsp;</a></span>operator Result()</h2>
302
303<div class="memitem">
304<div class="memproto">
305<div class="memtemplate">
306template&lt;typename T&gt; </div>
307<table class="mlabels">
308  <tr>
309  <td class="mlabels-left">
310      <table class="memname">
311        <tr>
312          <td class="memname"><a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::operator <a class="el" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a> </td>
313          <td>(</td>
314          <td class="paramname"></td><td>)</td>
315          <td> const</td>
316        </tr>
317      </table>
318  </td>
319  <td class="mlabels-right">
320<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
321  </tr>
322</table>
323</div><div class="memdoc">
324<p>Implicitly convert to a Result. This enables easy comparison with Result values. Example:</p>
325<p><code> <a class="el" href="classoboe_1_1_result_with_value.html">ResultWithValue</a> result = openStream(); if (result == Result::ErrorNoMemory){ // tell user they're out of memory } </code> </p>
326
327</div>
328</div>
329<a id="a45f5c99a2c9f8fbaca502276f7ebb434"></a>
330<h2 class="memtitle"><span class="permalink"><a href="#a45f5c99a2c9f8fbaca502276f7ebb434">&#9670;&nbsp;</a></span>value()</h2>
331
332<div class="memitem">
333<div class="memproto">
334<div class="memtemplate">
335template&lt;typename T&gt; </div>
336<table class="mlabels">
337  <tr>
338  <td class="mlabels-left">
339      <table class="memname">
340        <tr>
341          <td class="memname">T <a class="el" href="classoboe_1_1_result_with_value.html">oboe::ResultWithValue</a>&lt; T &gt;::value </td>
342          <td>(</td>
343          <td class="paramname"></td><td>)</td>
344          <td> const</td>
345        </tr>
346      </table>
347  </td>
348  <td class="mlabels-right">
349<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
350  </tr>
351</table>
352</div><div class="memdoc">
353<p>Get the value </p><dl class="section return"><dt>Returns</dt><dd></dd></dl>
354
355</div>
356</div>
357<hr/>The documentation for this class was generated from the following file:<ul>
358<li>include/oboe/<a class="el" href="_result_with_value_8h_source.html">ResultWithValue.h</a></li>
359</ul>
360</div><!-- contents -->
361<!-- start footer part -->
362<hr class="footer"/><address class="footer"><small>
363Generated by &#160;<a href="http://www.doxygen.org/index.html">
364<img class="footer" src="doxygen.png" alt="doxygen"/>
365</a> 1.8.15
366</small></address>
367</body>
368</html>
369