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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: wxNumberFormatter Class Reference</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="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-types">Public Types</a> |
<a href="#pub-static-methods">Static Public Member Functions</a> |
<a href="classwx_number_formatter-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wxNumberFormatter Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include <wx/numformatter.h></code></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Helper class for formatting and parsing numbers with thousands separators. </p>
<p>This class contains only static functions, so users must not create instances but directly call the member functions.</p>
<dl class="section since"><dt>Since</dt><dd>2.9.2</dd></dl>
<h2></h2>
<div><span class="lib">Library:</span>  <span class="lib_text"><a class="el" href="page_libs.html#page_libs_wxbase">wxBase</a></span></div> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a4e7dc96aef2d9dbc6ed7bf3c381b4f6f"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6f">Style</a> { <br/>
  <a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa3332ca1b32bdcd211ad73e046e5d60cd">Style_None</a> = 0x00,
<br/>
  <a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c">Style_WithThousandsSep</a> = 0x01,
<br/>
  <a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa438bbd19cd9603004fd7795431b7f954">Style_NoTrailingZeroes</a> = 0x02
<br/>
}</td></tr>
<tr class="memdesc:a4e7dc96aef2d9dbc6ed7bf3c381b4f6f"><td class="mdescLeft"> </td><td class="mdescRight">Bit masks used with <a class="el" href="classwx_number_formatter.html#abf3e465bc68a79821b00387271386fd3" title="Returns string representation of an integer number.">ToString()</a>. <a href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6f">More...</a><br/></td></tr>
<tr class="separator:a4e7dc96aef2d9dbc6ed7bf3c381b4f6f"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:abf3e465bc68a79821b00387271386fd3"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classwx_string.html">wxString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#abf3e465bc68a79821b00387271386fd3">ToString</a> (long val, int flags=<a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c">Style_WithThousandsSep</a>)</td></tr>
<tr class="memdesc:abf3e465bc68a79821b00387271386fd3"><td class="mdescLeft"> </td><td class="mdescRight">Returns string representation of an integer number. <a href="#abf3e465bc68a79821b00387271386fd3"></a><br/></td></tr>
<tr class="separator:abf3e465bc68a79821b00387271386fd3"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a42c2c2129c5bf3693e6a3699bae8595f"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classwx_string.html">wxString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#a42c2c2129c5bf3693e6a3699bae8595f">ToString</a> (double val, int precision, int flags=<a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c">Style_WithThousandsSep</a>)</td></tr>
<tr class="memdesc:a42c2c2129c5bf3693e6a3699bae8595f"><td class="mdescLeft"> </td><td class="mdescRight">Returns string representation of a floating point number. <a href="#a42c2c2129c5bf3693e6a3699bae8595f"></a><br/></td></tr>
<tr class="separator:a42c2c2129c5bf3693e6a3699bae8595f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ae1e22af7b2df6978f19f6a618d25823d"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#ae1e22af7b2df6978f19f6a618d25823d">GetDecimalSeparator</a> ()</td></tr>
<tr class="memdesc:ae1e22af7b2df6978f19f6a618d25823d"><td class="mdescLeft"> </td><td class="mdescRight">Get the decimal separator for the current locale. <a href="#ae1e22af7b2df6978f19f6a618d25823d"></a><br/></td></tr>
<tr class="separator:ae1e22af7b2df6978f19f6a618d25823d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a057fac14867aa14f5e0d461b8e8c5a99"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#a057fac14867aa14f5e0d461b8e8c5a99">GetThousandsSeparatorIfUsed</a> (<a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> *sep)</td></tr>
<tr class="memdesc:a057fac14867aa14f5e0d461b8e8c5a99"><td class="mdescLeft"> </td><td class="mdescRight">Get the thousands separator if grouping of the digits is used by the current locale. <a href="#a057fac14867aa14f5e0d461b8e8c5a99"></a><br/></td></tr>
<tr class="separator:a057fac14867aa14f5e0d461b8e8c5a99"><td class="memSeparator" colspan="2"> </td></tr>
<tr><td colspan="2"><div class="groupHeader"></div></td></tr>
<tr class="memitem:aad539451a9ac91198141eead3be4e743"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#aad539451a9ac91198141eead3be4e743">FromString</a> (<a class="el" href="classwx_string.html">wxString</a> s, long *val)</td></tr>
<tr class="memdesc:aad539451a9ac91198141eead3be4e743"><td class="mdescLeft"> </td><td class="mdescRight">Parse a string representation of a number possibly including thousands separators. <a href="#aad539451a9ac91198141eead3be4e743"></a><br/></td></tr>
<tr class="separator:aad539451a9ac91198141eead3be4e743"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:abc24487021d98af50ca8465f63a262f1"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classwx_number_formatter.html#abc24487021d98af50ca8465f63a262f1">FromString</a> (<a class="el" href="classwx_string.html">wxString</a> s, double *val)</td></tr>
<tr class="memdesc:abc24487021d98af50ca8465f63a262f1"><td class="mdescLeft"> </td><td class="mdescRight">Parse a string representation of a number possibly including thousands separators. <a href="#abc24487021d98af50ca8465f63a262f1"></a><br/></td></tr>
<tr class="separator:abc24487021d98af50ca8465f63a262f1"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Member Enumeration Documentation</h2>
<a class="anchor" id="a4e7dc96aef2d9dbc6ed7bf3c381b4f6f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6f">wxNumberFormatter::Style</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Bit masks used with <a class="el" href="classwx_number_formatter.html#abf3e465bc68a79821b00387271386fd3" title="Returns string representation of an integer number.">ToString()</a>. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa3332ca1b32bdcd211ad73e046e5d60cd"></a>Style_None</em> </td><td>
<p>This flag can be used to indicate absence of any other flags below. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c"></a>Style_WithThousandsSep</em> </td><td>
<p>If this flag is given, thousands separators will be inserted in the number string representation as defined by the current locale. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa438bbd19cd9603004fd7795431b7f954"></a>Style_NoTrailingZeroes</em> </td><td>
<p>If this flag is given, trailing zeroes in a floating point number string representation will be omitted. </p>
<p>If the number is actually integer, the decimal separator will be omitted as well. To give an example, formatting the number <code>1.23</code> with precision 5 will normally yield "1.23000" but with this flag it would return "1.23". And formatting <code>123</code> with this flag will return just "123" for any precision.</p>
<p>This flag can't be used with <a class="el" href="classwx_number_formatter.html#abf3e465bc68a79821b00387271386fd3" title="Returns string representation of an integer number.">ToString()</a> overload taking the integer value. </p>
</td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="aad539451a9ac91198141eead3be4e743"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static bool wxNumberFormatter::FromString </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classwx_string.html">wxString</a> </td>
<td class="paramname"><em>s</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long * </td>
<td class="paramname"><em>val</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Parse a string representation of a number possibly including thousands separators. </p>
<p>These functions parse number representation in the current locale. On success they return <span class="literal">true</span> and store the result at the location pointed to by <em>val</em> (which can't be <span class="literal">NULL</span>), otherwise <span class="literal">false</span> is returned.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classwx_string.html#abb54083175bbc1e1164616b4aa64fcd8" title="Attempts to convert the string to a signed integer in base base.">wxString::ToLong()</a>, <a class="el" href="classwx_string.html#afca98ce954f669ec69696372e81d46ac" title="Attempts to convert the string to a floating point number.">wxString::ToDouble()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="abc24487021d98af50ca8465f63a262f1"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static bool wxNumberFormatter::FromString </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classwx_string.html">wxString</a> </td>
<td class="paramname"><em>s</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">double * </td>
<td class="paramname"><em>val</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Parse a string representation of a number possibly including thousands separators. </p>
<p>These functions parse number representation in the current locale. On success they return <span class="literal">true</span> and store the result at the location pointed to by <em>val</em> (which can't be <span class="literal">NULL</span>), otherwise <span class="literal">false</span> is returned.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classwx_string.html#abb54083175bbc1e1164616b4aa64fcd8" title="Attempts to convert the string to a signed integer in base base.">wxString::ToLong()</a>, <a class="el" href="classwx_string.html#afca98ce954f669ec69696372e81d46ac" title="Attempts to convert the string to a floating point number.">wxString::ToDouble()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ae1e22af7b2df6978f19f6a618d25823d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> wxNumberFormatter::GetDecimalSeparator </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the decimal separator for the current locale. </p>
<p>Decimal separators is always defined and we fall back to returning '.' in case of an error. </p>
</div>
</div>
<a class="anchor" id="a057fac14867aa14f5e0d461b8e8c5a99"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static bool wxNumberFormatter::GetThousandsSeparatorIfUsed </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__group__funcmacro__string.html#gad42f64d8c82f1ce4ae58773a89b2d6a7">wxChar</a> * </td>
<td class="paramname"><em>sep</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Get the thousands separator if grouping of the digits is used by the current locale. </p>
<p>The value returned in <em>sep</em> should be only used if the function returns <span class="literal">true</span>, otherwise no thousands separator should be used at all.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">sep</td><td>Points to the variable receiving the thousands separator character if it is used by the current locale. May be <span class="literal">NULL</span> if only the function return value is needed. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="abf3e465bc68a79821b00387271386fd3"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="classwx_string.html">wxString</a> wxNumberFormatter::ToString </td>
<td>(</td>
<td class="paramtype">long </td>
<td class="paramname"><em>val</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>flags</em> = <code><a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c">Style_WithThousandsSep</a></code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns string representation of an integer number. </p>
<p>By default, the string will use thousands separators if appropriate for the current locale. This can be avoided by passing Style_None as <em>flags</em> in which case the call to the function has exactly the same effect as <code><a class="el" href="classwx_string.html#addd9ccfa3ae2b7ab2d66bcbf034d0be0" title="This static function returns the string containing the result of calling Printf() with the passed par...">wxString::Format</a>("%ld", val)</code>.</p>
<p>Notice that calling <a class="el" href="classwx_number_formatter.html#abf3e465bc68a79821b00387271386fd3" title="Returns string representation of an integer number.">ToString()</a> with a value of type <code>int</code> and non-default flags results in ambiguity between this overload and the one below. To resolve it, you need to cast the value to <code>long</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">val</td><td>The variable to convert to a string. </td></tr>
<tr><td class="paramname">flags</td><td>Combination of values from the Style enumeration (except for Style_NoTrailingZeroes which can't be used with this overload). </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="a42c2c2129c5bf3693e6a3699bae8595f"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="classwx_string.html">wxString</a> wxNumberFormatter::ToString </td>
<td>(</td>
<td class="paramtype">double </td>
<td class="paramname"><em>val</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>precision</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>flags</em> = <code><a class="el" href="classwx_number_formatter.html#a4e7dc96aef2d9dbc6ed7bf3c381b4f6fa2d6813de8316d89a0f43803858ae823c">Style_WithThousandsSep</a></code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns string representation of a floating point number. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">val</td><td>The variable to convert to a string. </td></tr>
<tr><td class="paramname">precision</td><td>Number of decimals to write in formatted string. </td></tr>
<tr><td class="paramname">flags</td><td>Combination of values from the Style enumeration. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:51 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|