/usr/share/doc/libucommon-dev/a00198_source.html is in libucommon-doc 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
<title>UCommon: ucommon/numbers.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>ucommon/numbers.h</h1><a href="a00198.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span>
<a name="l00017"></a>00017
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef _UCOMMON_NUMBERS_H_</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_NUMBERS_H_</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="preprocessor">#ifndef _UCOMMON_CONFIG_H_</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00201.html" title="Various miscelanous platform specific headers and defines.">ucommon/platform.h</a>></span>
<a name="l00031"></a>00031 <span class="preprocessor">#endif</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>
<a name="l00033"></a>00033 NAMESPACE_UCOMMON
<a name="l00034"></a>00034
<a name="l00046"></a><a class="code" href="a00092.html">00046</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00092.html" title="A number manipulation class.">Number</a>
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048 <span class="keyword">protected</span>:
<a name="l00049"></a>00049 <span class="keywordtype">char</span> *buffer;
<a name="l00050"></a>00050 <span class="keywordtype">unsigned</span> size;
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="keyword">public</span>:
<a name="l00058"></a>00058 <a class="code" href="a00092.html" title="A number manipulation class.">Number</a>(<span class="keywordtype">char</span> *buffer, <span class="keywordtype">unsigned</span> size);
<a name="l00059"></a>00059
<a name="l00064"></a>00064 <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keywordtype">long</span> value);
<a name="l00065"></a>00065
<a name="l00070"></a><a class="code" href="a00092.html#a19aa5ec7e641b11bd9cf558b4c70d83d">00070</a> <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *c_str()<span class="keyword"> const</span>
<a name="l00071"></a>00071 <span class="keyword"> </span>{<span class="keywordflow">return</span> buffer;};
<a name="l00072"></a>00072
<a name="l00077"></a>00077 <span class="keywordtype">long</span> <span class="keyword">get</span>() <span class="keyword">const</span>;
<a name="l00078"></a>00078
<a name="l00083"></a><a class="code" href="a00092.html#acdb0e50f24ad517fc9bb15e893e23e31">00083</a> <span class="keyword">inline</span> <span class="keywordtype">long</span> operator()()
<a name="l00084"></a>00084 {<span class="keywordflow">return</span> <span class="keyword">get</span>();};
<a name="l00085"></a>00085
<a name="l00090"></a><a class="code" href="a00092.html#a5ab84a2c2dccec7194a98f7c42ebc175">00090</a> <span class="keyword">inline</span> operator long()
<a name="l00091"></a>00091 {<span class="keywordflow">return</span> <span class="keyword">get</span>();};
<a name="l00092"></a>00092
<a name="l00097"></a><a class="code" href="a00092.html#aa82e7ae5da6e4cdb349aeadaee91b55e">00097</a> <span class="keyword">inline</span> operator char*()
<a name="l00098"></a>00098 {<span class="keywordflow">return</span> buffer;};
<a name="l00099"></a>00099
<a name="l00105"></a>00105 <span class="keywordtype">long</span> operator=(<span class="keywordtype">long</span> value);
<a name="l00106"></a>00106
<a name="l00112"></a>00112 <span class="keywordtype">long</span> operator=(<span class="keyword">const</span> <a class="code" href="a00092.html" title="A number manipulation class.">Number</a>& number);
<a name="l00113"></a>00113
<a name="l00119"></a>00119 <span class="keywordtype">long</span> operator+=(<span class="keyword">const</span> <span class="keywordtype">long</span> value);
<a name="l00120"></a>00120
<a name="l00126"></a>00126 <span class="keywordtype">long</span> operator-=(<span class="keyword">const</span> <span class="keywordtype">long</span> value);
<a name="l00127"></a>00127
<a name="l00132"></a>00132 <span class="keywordtype">long</span> operator--();
<a name="l00133"></a>00133
<a name="l00138"></a>00138 <span class="keywordtype">long</span> operator++();
<a name="l00139"></a>00139 };
<a name="l00140"></a>00140
<a name="l00147"></a><a class="code" href="a00184.html">00147</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00184.html" title="A number manipulation class that maintains a zero lead filled string.">ZNumber</a> : <span class="keyword">public</span> <a class="code" href="a00092.html" title="A number manipulation class.">Number</a>
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 <span class="keyword">public</span>:
<a name="l00155"></a>00155 <a class="code" href="a00184.html" title="A number manipulation class that maintains a zero lead filled string.">ZNumber</a>(<span class="keywordtype">char</span> *<a class="code" href="a00015.html" title="Typed smart pointer class.">pointer</a>, <span class="keywordtype">unsigned</span> size);
<a name="l00156"></a>00156
<a name="l00162"></a>00162 <span class="keywordtype">void</span> <span class="keyword">set</span>(<span class="keywordtype">long</span> value);
<a name="l00163"></a>00163
<a name="l00169"></a>00169 <span class="keywordtype">long</span> <a class="code" href="a00092.html#a80e442677d7bf486f9bf0c71decc31a7" title="Assign a value to the number.">operator=</a>(<span class="keywordtype">long</span> value);
<a name="l00170"></a>00170 };
<a name="l00171"></a>00171
<a name="l00175"></a><a class="code" href="a00214.html#a0e97369dc8568c429ed8919b79d7421a">00175</a> <span class="keyword">typedef</span> <a class="code" href="a00092.html" title="A number manipulation class.">Number</a> <a class="code" href="a00092.html" title="A number manipulation class.">number_t</a>;
<a name="l00176"></a>00176
<a name="l00180"></a><a class="code" href="a00214.html#a8d8a85f952a0be87481240d9c4d59f27">00180</a> <span class="keyword">typedef</span> <a class="code" href="a00184.html" title="A number manipulation class that maintains a zero lead filled string.">ZNumber</a> <a class="code" href="a00184.html" title="A number manipulation class that maintains a zero lead filled string.">znumber_t</a>;
<a name="l00181"></a>00181
<a name="l00187"></a>00187 <span class="keyword">template</span><<span class="keyword">typename</span> T>
<a name="l00188"></a><a class="code" href="a00214.html#a9e26ac6e96914a13b26276d1c1d12305">00188</a> <span class="keyword">inline</span> <span class="keyword">const</span> T <a class="code" href="a00214.html#a9e26ac6e96914a13b26276d1c1d12305" title="Template for absolute value of a type.">abs</a>(<span class="keyword">const</span> T& value)
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190 <span class="keywordflow">if</span>(value < (T)0)
<a name="l00191"></a>00191 <span class="keywordflow">return</span> -value;
<a name="l00192"></a>00192 <span class="keywordflow">return</span> value;
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194
<a name="l00195"></a>00195
<a name="l00202"></a>00202 <span class="keyword">template</span><<span class="keyword">typename</span> T>
<a name="l00203"></a><a class="code" href="a00214.html#a12c25876ddd218e42a739cea9e7af3d1">00203</a> <span class="keyword">inline</span> <span class="keyword">const</span> T (<a class="code" href="a00214.html#a12c25876ddd218e42a739cea9e7af3d1" title="Template for min value of a type.">min</a>)(<span class="keyword">const</span> T& v1, <span class="keyword">const</span> T& v2)
<a name="l00204"></a>00204 {
<a name="l00205"></a>00205 <span class="keywordflow">return</span> ((v1 < v2) ? v1 : v2);
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207
<a name="l00214"></a>00214 <span class="keyword">template</span><<span class="keyword">typename</span> T>
<a name="l00215"></a><a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05">00215</a> <span class="keyword">inline</span> <span class="keyword">const</span> T (<a class="code" href="a00214.html#a8049d3aa4d2ad2df40e33d0104fe0c05" title="Template for max value of a type.">max</a>)(<span class="keyword">const</span> T& v1, <span class="keyword">const</span> T& v2)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217 <span class="keywordflow">return</span> ((v1 > v2) ? v1 : v2);
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00220"></a>00220 END_NAMESPACE
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|