source: NonGTP/FCollada/Documentation/_f_u_string_builder_8hpp-source.html @ 964

Revision 964, 33.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>FCollada: FUtils/FUStringBuilder.hpp Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.4.6-NO -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="modules.html"><span>Modules</span></a></li>
12    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
13    <li><a href="classes.html"><span>Classes</span></a></li>
14    <li id="current"><a href="files.html"><span>Files</span></a></li>
15    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16  </ul></div>
17<div class="tabs">
18  <ul>
19    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
20    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
21  </ul></div>
22<h1>FUtils/FUStringBuilder.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
23<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc.</span>
24<a name="l00003"></a>00003 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
25<a name="l00004"></a>00004 <span class="comment">*/</span>
26<a name="l00005"></a>00005 <span class="comment">/*</span>
27<a name="l00006"></a>00006 <span class="comment">    Based on the FS Import classes:</span>
28<a name="l00007"></a>00007 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc</span>
29<a name="l00008"></a>00008 <span class="comment">    Copyright (C) 2005-2006 Autodesk Media Entertainment</span>
30<a name="l00009"></a>00009 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
31<a name="l00010"></a>00010 <span class="comment">*/</span>
32<a name="l00011"></a>00011
33<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;limits&gt;</span>
34<a name="l00013"></a>00013
35<a name="l00014"></a>00014 <span class="preprocessor">#ifdef WIN32</span>
36<a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#include &lt;float.h&gt;</span>
37<a name="l00016"></a>00016 <span class="preprocessor">#endif</span>
38<a name="l00017"></a>00017 <span class="preprocessor"></span>
39<a name="l00018"></a>00018 <span class="preprocessor">#ifndef SAFE_DELETE_ARRAY</span>
40<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define SAFE_DELETE_ARRAY(ptr) if (ptr != NULL) { delete [] ptr; ptr = NULL; }</span>
41<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
42<a name="l00021"></a>00021 <span class="preprocessor"></span>
43<a name="l00022"></a>00022 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
44<a name="l00023"></a><a class="code" href="class_f_u_string_builder_t.html#bc9ed6068dd9506d5d73350fda28c2bb">00023</a> <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT&lt;Char,SPrintF&gt;::FUStringBuilderT</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>&amp; sz)
45<a name="l00024"></a>00024 {
46<a name="l00025"></a>00025     this-&gt;buffer = NULL;
47<a name="l00026"></a>00026     this-&gt;size = 0;
48<a name="l00027"></a>00027     this-&gt;reserved = 0;
49<a name="l00028"></a>00028     
50<a name="l00029"></a>00029     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(sz.size() + 32);
51<a name="l00030"></a>00030     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz.c_str());
52<a name="l00031"></a>00031 }
53<a name="l00032"></a>00032
54<a name="l00033"></a>00033 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
55<a name="l00034"></a><a class="code" href="class_f_u_string_builder_t.html#51c608d04779567394f407ede3215375">00034</a> <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT&lt;Char,SPrintF&gt;::FUStringBuilderT</a>(<span class="keyword">const</span> Char* sz)
56<a name="l00035"></a>00035 {
57<a name="l00036"></a>00036     this-&gt;buffer = NULL;
58<a name="l00037"></a>00037     this-&gt;size = 0;
59<a name="l00038"></a>00038     this-&gt;reserved = 0;
60<a name="l00039"></a>00039
61<a name="l00040"></a>00040     SPrintF s;
62<a name="l00041"></a>00041     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(s.StrLen(sz) + 32);
63<a name="l00042"></a>00042     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
64<a name="l00043"></a>00043 }
65<a name="l00044"></a>00044
66<a name="l00045"></a>00045 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
67<a name="l00046"></a><a class="code" href="class_f_u_string_builder_t.html#6a1bcdc8154bcb2458bdbda23965fdd3">00046</a> <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT&lt;Char,SPrintF&gt;::FUStringBuilderT</a>(Char ch, size_t count)
68<a name="l00047"></a>00047 {
69<a name="l00048"></a>00048     this-&gt;buffer = NULL;
70<a name="l00049"></a>00049     this-&gt;size = 0;
71<a name="l00050"></a>00050     this-&gt;reserved = 0;
72<a name="l00051"></a>00051
73<a name="l00052"></a>00052     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(count + 32);
74<a name="l00053"></a>00053 <span class="keywordflow">for</span> (size_t i = 0; i &lt; count; ++i) buffer[size++] = ch;
75<a name="l00054"></a>00054 }
76<a name="l00055"></a>00055
77<a name="l00056"></a>00056 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
78<a name="l00057"></a><a class="code" href="class_f_u_string_builder_t.html#31a1037f438b71b8c40acebd781b6af2">00057</a> <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT&lt;Char,SPrintF&gt;::FUStringBuilderT</a>(size_t reservation)
79<a name="l00058"></a>00058 {
80<a name="l00059"></a>00059     this-&gt;buffer = NULL;
81<a name="l00060"></a>00060     this-&gt;size = 0;
82<a name="l00061"></a>00061     this-&gt;reserved = 0;
83<a name="l00062"></a>00062
84<a name="l00063"></a>00063     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(reservation);
85<a name="l00064"></a>00064 }
86<a name="l00065"></a>00065
87<a name="l00066"></a>00066 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
88<a name="l00067"></a><a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">00067</a> <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT&lt;Char,SPrintF&gt;::FUStringBuilderT</a>()
89<a name="l00068"></a>00068 {
90<a name="l00069"></a>00069     this-&gt;buffer = NULL;
91<a name="l00070"></a>00070     this-&gt;size = 0;
92<a name="l00071"></a>00071     this-&gt;reserved = 0;
93<a name="l00072"></a>00072
94<a name="l00073"></a>00073 <span class="preprocessor">#ifndef _DEBUG</span>
95<a name="l00074"></a>00074 <span class="preprocessor"></span>    <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(32);
96<a name="l00075"></a>00075 <span class="preprocessor">#endif</span>
97<a name="l00076"></a>00076 <span class="preprocessor"></span>}
98<a name="l00077"></a>00077
99<a name="l00078"></a>00078 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
100<a name="l00079"></a><a class="code" href="class_f_u_string_builder_t.html#73d27bbd97e1d5733feb915049d72fc7">00079</a> <a class="code" href="class_f_u_string_builder_t.html#73d27bbd97e1d5733feb915049d72fc7">FUStringBuilderT&lt;Char,SPrintF&gt;::~FUStringBuilderT</a>()
101<a name="l00080"></a>00080 {
102<a name="l00081"></a>00081     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(0);
103<a name="l00082"></a>00082 }
104<a name="l00083"></a>00083
105<a name="l00084"></a>00084 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
106<a name="l00085"></a>00085 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT&lt;Char,SPrintF&gt;::enlarge</a>(size_t minimum)
107<a name="l00086"></a>00086 {
108<a name="l00087"></a>00087     <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(<a class="code" href="_f_utils_8h.html#ffe776513b24d84b39af8ab0930fef7f">max</a>(reserved + minimum + 32, 2 * reserved + 32));
109<a name="l00088"></a>00088 }
110<a name="l00089"></a>00089
111<a name="l00090"></a>00090 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
112<a name="l00091"></a><a class="code" href="class_f_u_string_builder_t.html#c6c4a1e21c124eedbb39047ca94b4a2b">00091</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#c6c4a1e21c124eedbb39047ca94b4a2b">FUStringBuilderT&lt;Char,SPrintF&gt;::clear</a>()
113<a name="l00092"></a>00092 {
114<a name="l00093"></a>00093     size = 0;
115<a name="l00094"></a>00094 }
116<a name="l00095"></a>00095
117<a name="l00096"></a>00096 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
118<a name="l00097"></a><a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">00097</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">FUStringBuilderT&lt;Char,SPrintF&gt;::reserve</a>(size_t _length)
119<a name="l00098"></a>00098 {
120<a name="l00099"></a>00099     <a class="code" href="_f_u_assert_8h.html#72b8444eb608787f1db6bf1d53e0310f">FUAssert</a>(size &lt;= reserved, );
121<a name="l00100"></a>00100 <span class="keywordflow">if</span> (_length &gt; reserved)
122<a name="l00101"></a>00101     {
123<a name="l00102"></a>00102 Char* b = <span class="keyword">new</span> Char[_length];
124<a name="l00103"></a>00103         memcpy(b, buffer, size * <span class="keyword">sizeof</span>(Char));
125<a name="l00104"></a>00104         <a class="code" href="_f_utils_8h.html#7541454697b30d05714aa6b2150500b1">SAFE_DELETE_ARRAY</a>(buffer);
126<a name="l00105"></a>00105         buffer = b;
127<a name="l00106"></a>00106         reserved = _length;
128<a name="l00107"></a>00107     }
129<a name="l00108"></a>00108 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (_length == 0)
130<a name="l00109"></a>00109     {
131<a name="l00110"></a>00110         <a class="code" href="_f_utils_8h.html#7541454697b30d05714aa6b2150500b1">SAFE_DELETE_ARRAY</a>(buffer);
132<a name="l00111"></a>00111         size = reserved = 0;
133<a name="l00112"></a>00112     }
134<a name="l00113"></a>00113 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (_length &lt; reserved)
135<a name="l00114"></a>00114     {
136<a name="l00115"></a>00115         size_t realSize = <a class="code" href="_f_utils_8h.html#c6afabdc09a49a433ee19d8a9486056d">min</a>(size, _length);
137<a name="l00116"></a>00116 Char* b = <span class="keyword">new</span> Char[_length];
138<a name="l00117"></a>00117         memcpy(b, buffer, realSize * <span class="keyword">sizeof</span>(Char));
139<a name="l00118"></a>00118         <a class="code" href="_f_utils_8h.html#7541454697b30d05714aa6b2150500b1">SAFE_DELETE_ARRAY</a>(buffer);
140<a name="l00119"></a>00119         buffer = b;
141<a name="l00120"></a>00120         reserved = _length;
142<a name="l00121"></a>00121         size = realSize;
143<a name="l00122"></a>00122     }
144<a name="l00123"></a>00123 }
145<a name="l00124"></a>00124
146<a name="l00125"></a>00125 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
147<a name="l00126"></a><a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">00126</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(Char c)
148<a name="l00127"></a>00127 {
149<a name="l00128"></a>00128 <span class="keywordflow">if</span> (size + 1 &gt;= reserved) enlarge(2);
150<a name="l00129"></a>00129
151<a name="l00130"></a>00130     buffer[size++] = c;
152<a name="l00131"></a>00131 }
153<a name="l00132"></a>00132
154<a name="l00133"></a>00133 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
155<a name="l00134"></a><a class="code" href="class_f_u_string_builder_t.html#a15263dcfa36987a03aa88a3f203bbf0">00134</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>&amp; sz) { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz.c_str()); }
156<a name="l00135"></a>00135 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
157<a name="l00136"></a><a class="code" href="class_f_u_string_builder_t.html#a220f12cd75139c3be2ee87866593467">00136</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(<span class="keyword">const</span> Char* sz)
158<a name="l00137"></a>00137 {
159<a name="l00138"></a>00138     <span class="comment">// This is optimized for SMALL strings.</span>
160<a name="l00139"></a>00139 <span class="keywordflow">for</span> (; *sz != 0; ++sz)
161<a name="l00140"></a>00140     {
162<a name="l00141"></a>00141 <span class="keywordflow">if</span> (size &gt;= reserved) enlarge(64);
163<a name="l00142"></a>00142         buffer[size++] = *sz;
164<a name="l00143"></a>00143     }
165<a name="l00144"></a>00144 }
166<a name="l00145"></a>00145 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
167<a name="l00146"></a><a class="code" href="class_f_u_string_builder_t.html#9166ca44f8f66ef444319f93739de712">00146</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT</a>&amp; b)
168<a name="l00147"></a>00147 {
169<a name="l00148"></a>00148 <span class="keywordflow">if</span> (size + b.<a class="code" href="class_f_u_string_builder_t.html#ecaff73516679583b86f27956038d204">size</a> &gt;= reserved) enlarge(64 + size + b.<a class="code" href="class_f_u_string_builder_t.html#ecaff73516679583b86f27956038d204">size</a> - reserved);
170<a name="l00149"></a>00149 memcpy(buffer + size, b.<a class="code" href="class_f_u_string_builder_t.html#adb3c62ec08c6933ec770680606d387f">buffer</a>, b.<a class="code" href="class_f_u_string_builder_t.html#ecaff73516679583b86f27956038d204">size</a> * <span class="keyword">sizeof</span>(Char));
171<a name="l00150"></a>00150     size += b.<a class="code" href="class_f_u_string_builder_t.html#ecaff73516679583b86f27956038d204">size</a>;
172<a name="l00151"></a>00151 }
173<a name="l00152"></a>00152
174<a name="l00153"></a>00153 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
175<a name="l00154"></a><a class="code" href="class_f_u_string_builder_t.html#8329f5623c8fbb037a515dcacb47b648">00154</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(uint32 i)
176<a name="l00155"></a>00155 {
177<a name="l00156"></a>00156     Char sz[128];
178<a name="l00157"></a>00157     SPrintF writer; writer.PrintUInt32(sz, 128, i);
179<a name="l00158"></a>00158     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
180<a name="l00159"></a>00159 }
181<a name="l00160"></a>00160
182<a name="l00161"></a>00161 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
183<a name="l00162"></a><a class="code" href="class_f_u_string_builder_t.html#b6842afc64d5050e83faa3c8d108772c">00162</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(uint64 i)
184<a name="l00163"></a>00163 {
185<a name="l00164"></a>00164     Char sz[128];
186<a name="l00165"></a>00165     SPrintF writer; writer.PrintUInt64(sz, 128, i);
187<a name="l00166"></a>00166     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
188<a name="l00167"></a>00167 }
189<a name="l00168"></a>00168
190<a name="l00169"></a>00169 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
191<a name="l00170"></a><a class="code" href="class_f_u_string_builder_t.html#343f33ad51e7d39deefd45c5b5fe200a">00170</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(int32 i)
192<a name="l00171"></a>00171 {
193<a name="l00172"></a>00172     Char sz[128];
194<a name="l00173"></a>00173     SPrintF writer; writer.PrintInt32(sz, 128, i);
195<a name="l00174"></a>00174     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
196<a name="l00175"></a>00175 }
197<a name="l00176"></a>00176
198<a name="l00177"></a>00177 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
199<a name="l00178"></a><a class="code" href="class_f_u_string_builder_t.html#d0400b32174541faa906cb6ab9eead41">00178</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(<span class="keywordtype">float</span> f)
200<a name="l00179"></a>00179 {
201<a name="l00180"></a>00180 <span class="keywordflow">if</span> (f != std::numeric_limits&lt;float&gt;::infinity() &amp;&amp; f != -std::numeric_limits&lt;float&gt;::infinity() &amp;&amp; f != std::numeric_limits&lt;float&gt;::quiet_NaN() &amp;&amp; f != std::numeric_limits&lt;float&gt;::signaling_NaN())
202<a name="l00181"></a>00181     {
203<a name="l00182"></a>00182 <span class="keywordflow">if</span> (<a class="code" href="_f_m_array_8h.html#10854668923860f01d22d6f543c34cb2">IsEquivalent</a>(f, 0.0f, std::numeric_limits&lt;float&gt;::epsilon())) <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'0'</span>);
204<a name="l00183"></a>00183         <span class="keywordflow">else</span>
205<a name="l00184"></a>00184         {
206<a name="l00185"></a>00185             Char sz[128];
207<a name="l00186"></a>00186             SPrintF writer; writer.PrintFloat(sz, 128, f);
208<a name="l00187"></a>00187             <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
209<a name="l00188"></a>00188         }
210<a name="l00189"></a>00189     }
211<a name="l00190"></a>00190 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (f == std::numeric_limits&lt;float&gt;::infinity())
212<a name="l00191"></a>00191     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'I'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'F'</span>); }
213<a name="l00192"></a>00192 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (f == -std::numeric_limits&lt;float&gt;::infinity())
214<a name="l00193"></a>00193     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'-'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'I'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'F'</span>); }
215<a name="l00194"></a>00194     <span class="keywordflow">else</span>
216<a name="l00195"></a>00195     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'a'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); }
217<a name="l00196"></a>00196 }
218<a name="l00197"></a>00197
219<a name="l00198"></a>00198 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
220<a name="l00199"></a><a class="code" href="class_f_u_string_builder_t.html#0415d202a0e46500345331edcb0cb370">00199</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">FUStringBuilderT&lt;Char,SPrintF&gt;::append</a>(<span class="keywordtype">double</span> f)
221<a name="l00200"></a>00200 {
222<a name="l00201"></a>00201 <span class="keywordflow">if</span> (f != std::numeric_limits&lt;double&gt;::infinity() &amp;&amp; f != -std::numeric_limits&lt;double&gt;::infinity() &amp;&amp; f != std::numeric_limits&lt;double&gt;::quiet_NaN() &amp;&amp; f != std::numeric_limits&lt;double&gt;::signaling_NaN())
223<a name="l00202"></a>00202     {
224<a name="l00203"></a>00203 <span class="keywordflow">if</span> (<a class="code" href="_f_m_array_8h.html#10854668923860f01d22d6f543c34cb2">IsEquivalent</a>(f, 0.0, std::numeric_limits&lt;double&gt;::epsilon())) <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'0'</span>);
225<a name="l00204"></a>00204         <span class="keywordflow">else</span>
226<a name="l00205"></a>00205         {
227<a name="l00206"></a>00206             Char sz[128];
228<a name="l00207"></a>00207             SPrintF writer; writer.PrintFloat(sz, 128, f);
229<a name="l00208"></a>00208             <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
230<a name="l00209"></a>00209         }
231<a name="l00210"></a>00210     }
232<a name="l00211"></a>00211 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (f == std::numeric_limits&lt;double&gt;::infinity())
233<a name="l00212"></a>00212     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'I'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'F'</span>); }
234<a name="l00213"></a>00213 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (f == -std::numeric_limits&lt;double&gt;::infinity())
235<a name="l00214"></a>00214     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'-'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'I'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'F'</span>); }
236<a name="l00215"></a>00215     <span class="keywordflow">else</span>
237<a name="l00216"></a>00216     { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'a'</span>); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="charliteral">'N'</span>); }
238<a name="l00217"></a>00217 }
239<a name="l00218"></a>00218
240<a name="l00219"></a>00219 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
241<a name="l00220"></a><a class="code" href="class_f_u_string_builder_t.html#d47eb054aec1d0c046fb05697c60bf66">00220</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#d47eb054aec1d0c046fb05697c60bf66">FUStringBuilderT&lt;Char,SPrintF&gt;::appendLine</a>(<span class="keyword">const</span> Char* sz)
242<a name="l00221"></a>00221 {
243<a name="l00222"></a>00222     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(sz);
244<a name="l00223"></a>00223     <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="stringliteral">"\n"</span>);
245<a name="l00224"></a>00224 }
246<a name="l00225"></a>00225
247<a name="l00226"></a>00226 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
248<a name="l00227"></a><a class="code" href="class_f_u_string_builder_t.html#b67d89559eab0194d4506d553213a085">00227</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#b67d89559eab0194d4506d553213a085">FUStringBuilderT&lt;Char,SPrintF&gt;::remove</a>(int32 start)
249<a name="l00228"></a>00228 {
250<a name="l00229"></a>00229 <span class="keywordflow">if</span> ((int32)size &gt; start &amp;&amp; start &gt;= 0) size = start;
251<a name="l00230"></a>00230 }
252<a name="l00231"></a>00231
253<a name="l00232"></a>00232 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
254<a name="l00233"></a><a class="code" href="class_f_u_string_builder_t.html#99858563d244072fa7029560c639a7e0">00233</a> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#b67d89559eab0194d4506d553213a085">FUStringBuilderT&lt;Char,SPrintF&gt;::remove</a>(int32 start, int32 end)
255<a name="l00234"></a>00234 {
256<a name="l00235"></a>00235     int32 diff = end - start;
257<a name="l00236"></a>00236 <span class="keywordflow">if</span> ((int32)size &gt;= end &amp;&amp; start &gt;= 0 &amp;&amp; diff &gt; 0)
258<a name="l00237"></a>00237     {
259<a name="l00238"></a>00238 <span class="keyword">const</span> Char* stop = buffer + size - diff;
260<a name="l00239"></a>00239 <span class="keywordflow">for</span> (Char* p = buffer + start; p != stop; ++p)
261<a name="l00240"></a>00240         {
262<a name="l00241"></a>00241             *p = *(p + diff);
263<a name="l00242"></a>00242         }
264<a name="l00243"></a>00243         size -= diff;
265<a name="l00244"></a>00244     }
266<a name="l00245"></a>00245 }
267<a name="l00246"></a>00246
268<a name="l00247"></a>00247 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
269<a name="l00248"></a><a class="code" href="class_f_u_string_builder_t.html#84c7caa79c4639aeaf05831aa1534c65">00248</a> <span class="keyword">typename</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT&lt;Char,SPrintF&gt;::String</a> <a class="code" href="class_f_u_string_builder_t.html#84c7caa79c4639aeaf05831aa1534c65">FUStringBuilderT&lt;Char,SPrintF&gt;::ToString</a>()
270<a name="l00249"></a>00249 {
271<a name="l00250"></a>00250 <span class="keywordflow">return</span> <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>((<span class="keyword">const</span> Char*)*<span class="keyword">this</span>);
272<a name="l00251"></a>00251 }
273<a name="l00252"></a>00252
274<a name="l00253"></a>00253 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
275<a name="l00254"></a><a class="code" href="class_f_u_string_builder_t.html#1fa2543a75ae974e86aaef3ebf726e0c">00254</a> <span class="keyword">const</span> Char* <a class="code" href="class_f_u_string_builder_t.html#1fa2543a75ae974e86aaef3ebf726e0c">FUStringBuilderT&lt;Char,SPrintF&gt;::ToCharPtr</a>()
276<a name="l00255"></a>00255 {
277<a name="l00256"></a>00256 <span class="keywordflow">if</span> (size + 1 &gt; reserved) enlarge(1);
278<a name="l00257"></a>00257     buffer[size] = 0;
279<a name="l00258"></a>00258 <span class="keywordflow">return</span> buffer;
280<a name="l00259"></a>00259 }
281<a name="l00260"></a>00260
282<a name="l00261"></a>00261 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
283<a name="l00262"></a><a class="code" href="class_f_u_string_builder_t.html#468e24745f22f07b2ff3aaebedb92158">00262</a> int32 <a class="code" href="class_f_u_string_builder_t.html#468e24745f22f07b2ff3aaebedb92158">FUStringBuilderT&lt;Char,SPrintF&gt;::index</a>(Char c)
284<a name="l00263"></a>00263 {
285<a name="l00264"></a>00264 <span class="keywordflow">if</span> (buffer != NULL &amp;&amp; size &gt; 0)
286<a name="l00265"></a>00265     {
287<a name="l00266"></a>00266 <span class="keyword">const</span> Char* end = buffer + size + 1;
288<a name="l00267"></a>00267 <span class="keywordflow">for</span> (<span class="keyword">const</span> Char* p = buffer; p != end; ++p)
289<a name="l00268"></a>00268         {
290<a name="l00269"></a>00269 <span class="keywordflow">if</span> (*p == c) <span class="keywordflow">return</span> (int32)(p - buffer);
291<a name="l00270"></a>00270         }
292<a name="l00271"></a>00271     }
293<a name="l00272"></a>00272 <span class="keywordflow">return</span> -1;
294<a name="l00273"></a>00273 }
295<a name="l00274"></a>00274
296<a name="l00275"></a>00275 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Char, <span class="keyword">class</span> SPr<span class="keywordtype">int</span>F&gt;
297<a name="l00276"></a><a class="code" href="class_f_u_string_builder_t.html#c9c5a141f6775db8e5dbd5a228d4d154">00276</a> int32 <a class="code" href="class_f_u_string_builder_t.html#c9c5a141f6775db8e5dbd5a228d4d154">FUStringBuilderT&lt;Char,SPrintF&gt;::rindex</a>(Char c)
298<a name="l00277"></a>00277 {
299<a name="l00278"></a>00278 <span class="keywordflow">if</span> (buffer != NULL &amp;&amp; size &gt; 0)
300<a name="l00279"></a>00279     {
301<a name="l00280"></a>00280 <span class="keywordflow">for</span> (<span class="keyword">const</span> Char* p = buffer + size - 1; p != buffer; --p)
302<a name="l00281"></a>00281         {
303<a name="l00282"></a>00282 <span class="keywordflow">if</span> (*p == c) <span class="keywordflow">return</span> (int32)(p - buffer);
304<a name="l00283"></a>00283         }
305<a name="l00284"></a>00284     }
306<a name="l00285"></a>00285 <span class="keywordflow">return</span> -1;
307<a name="l00286"></a>00286 }
308</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
309<a href="http://www.doxygen.org/index.html">
310<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
311</body>
312</html>
Note: See TracBrowser for help on using the repository browser.