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

Revision 964, 20.2 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.h 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.h</h1><a href="_f_u_string_builder_8h.html">Go to the documentation of this file.</a><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="l00018"></a>00018 <span class="preprocessor">#ifndef _FCU_STRING_BUILDER_</span>
34<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define _FCU_STRING_BUILDER_</span>
35<a name="l00020"></a>00020 <span class="preprocessor"></span>
36<a name="l00031"></a>00031 <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;
37<a name="l00032"></a><a class="code" href="class_f_u_string_builder_t.html">00032</a> <span class="keyword">class </span><a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT</a>
38<a name="l00033"></a>00033 {
39<a name="l00034"></a>00034 <span class="keyword">private</span>:
40<a name="l00035"></a>00035     Char* buffer;
41<a name="l00036"></a>00036     size_t reserved;
42<a name="l00037"></a>00037     size_t size;
43<a name="l00038"></a>00038
44<a name="l00039"></a>00039 <span class="keyword">public</span>:
45<a name="l00041"></a><a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">00041</a>     <span class="keyword">typedef</span> std::basic_string&lt;Char&gt; <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>;
46<a name="l00042"></a>00042
47<a name="l00045"></a>00045 <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>&amp; sz);
48<a name="l00046"></a>00046
49<a name="l00050"></a>00050 <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT</a>(<span class="keyword">const</span> Char* sz);
50<a name="l00051"></a>00051
51<a name="l00055"></a>00055     <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT</a>(Char ch, size_t count);
52<a name="l00056"></a>00056
53<a name="l00060"></a>00060     <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT</a>(size_t reserved);
54<a name="l00061"></a>00061
55<a name="l00063"></a>00063     <a class="code" href="class_f_u_string_builder_t.html#3b92a51f395836f5558f14000060579e">FUStringBuilderT</a>();
56<a name="l00064"></a>00064
57<a name="l00067"></a>00067     <a class="code" href="class_f_u_string_builder_t.html#73d27bbd97e1d5733feb915049d72fc7">~FUStringBuilderT</a>();
58<a name="l00068"></a>00068
59<a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#64127a6ba4365638a73ee33807763baf">reserve</a>(size_t <a class="code" href="class_f_u_string_builder_t.html#6b831ec54bab38e20e1a57e771453533">length</a>);
60<a name="l00076"></a>00076
61<a name="l00079"></a><a class="code" href="class_f_u_string_builder_t.html#6b831ec54bab38e20e1a57e771453533">00079</a>     <span class="keyword">inline</span> size_t <a class="code" href="class_f_u_string_builder_t.html#6b831ec54bab38e20e1a57e771453533">length</a>() { <span class="keywordflow">return</span> size; }
62<a name="l00080"></a>00080
63<a name="l00083"></a>00083 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#c6c4a1e21c124eedbb39047ca94b4a2b">clear</a>();
64<a name="l00084"></a>00084
65<a name="l00089"></a><a class="code" href="class_f_u_string_builder_t.html#0c720250e8927ee479fbd824180424ad">00089</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_f_u_string_builder_t.html#0c720250e8927ee479fbd824180424ad">empty</a>() { <span class="keywordflow">return</span> size == 0; }
66<a name="l00090"></a>00090
67<a name="l00093"></a>00093 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(Char c);
68<a name="l00094"></a>00094
69<a name="l00097"></a>00097 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a>&amp; sz);
70<a name="l00098"></a>00098
71<a name="l00102"></a>00102 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keyword">const</span> Char* sz);
72<a name="l00103"></a>00103
73<a name="l00106"></a>00106 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keyword">const</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT</a>&amp; b);
74<a name="l00107"></a>00107
75<a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(int32 i);
76<a name="l00112"></a>00112 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(uint32 i);
77<a name="l00113"></a>00113 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(uint64 i);
78<a name="l00115"></a><a class="code" href="class_f_u_string_builder_t.html#c5c2486278e01c771f38dc327524d8ff">00115</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keywordtype">int</span> i) { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>((int32) i); }
79<a name="l00116"></a>00116 <span class="preprocessor">#ifdef _W64</span>
80<a name="l00117"></a>00117 <span class="preprocessor"></span>    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(_W64 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i) { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>((uint32) i); }
81<a name="l00118"></a>00118 <span class="preprocessor">#else</span>
82<a name="l00119"></a><a class="code" href="class_f_u_string_builder_t.html#fda44e8a511ea05d7df4462b26536bde">00119</a> <span class="preprocessor"></span>    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i) { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>((uint32) i); }
83<a name="l00120"></a>00120 <span class="preprocessor">#endif </span>
84<a name="l00121"></a>00121 <span class="preprocessor"></span>
85<a name="l00128"></a>00128 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keywordtype">float</span> f);
86<a name="l00129"></a>00129 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(<span class="keywordtype">double</span> f);
87<a name="l00135"></a><a class="code" href="class_f_u_string_builder_t.html#ffacf60781399efab674503dba424dae">00135</a>     <span class="keyword">template</span>&lt;<span class="keyword">typename</span> TYPE&gt; <span class="keyword">inline</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT</a>&amp; <a class="code" href="class_f_u_string_builder_t.html#ffacf60781399efab674503dba424dae">operator+=</a>(<span class="keyword">const</span> TYPE&amp; val) { <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(val); <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
88<a name="l00136"></a>00136
89<a name="l00141"></a>00141 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#d47eb054aec1d0c046fb05697c60bf66">appendLine</a>(<span class="keyword">const</span> Char* sz);
90<a name="l00142"></a>00142
91<a name="l00147"></a>00147 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#b67d89559eab0194d4506d553213a085">remove</a>(int32 start);
92<a name="l00148"></a>00148
93<a name="l00155"></a>00155 <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#b67d89559eab0194d4506d553213a085">remove</a>(int32 start, int32 end);
94<a name="l00156"></a>00156
95<a name="l00158"></a><a class="code" href="class_f_u_string_builder_t.html#1089af53ab87c88d10349bbc3456db7f">00158</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#1089af53ab87c88d10349bbc3456db7f">pop_back</a>() { <span class="keywordflow">if</span> (size &gt; 0) --size; }
96<a name="l00159"></a>00159
97<a name="l00163"></a><a class="code" href="class_f_u_string_builder_t.html#552095c3500bbcbee1c474f91af1b537">00163</a>     <span class="keyword">template</span>&lt;<span class="keyword">typename</span> TYPE&gt; <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_f_u_string_builder_t.html#552095c3500bbcbee1c474f91af1b537">set</a>(<span class="keyword">const</span> TYPE&amp; val) { <a class="code" href="class_f_u_string_builder_t.html#c6c4a1e21c124eedbb39047ca94b4a2b">clear</a>(); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(val); }
98<a name="l00164"></a><a class="code" href="class_f_u_string_builder_t.html#b09f2370f4993d6acd8fc84a4ae6568c">00164</a>     <span class="keyword">template</span>&lt;<span class="keyword">typename</span> TYPE&gt; <span class="keyword">inline</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT</a>&amp; <a class="code" href="class_f_u_string_builder_t.html#b09f2370f4993d6acd8fc84a4ae6568c">operator=</a>(<span class="keyword">const</span> TYPE&amp; val) { <a class="code" href="class_f_u_string_builder_t.html#c6c4a1e21c124eedbb39047ca94b4a2b">clear</a>(); <a class="code" href="class_f_u_string_builder_t.html#50253c8fbc7591fd3e603d5583200ccb">append</a>(val); <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
99<a name="l00168"></a>00168 <a class="code" href="class_f_u_string_builder_t.html#56f872f5493b078f39ef885fa64a0291">String</a> <a class="code" href="class_f_u_string_builder_t.html#84c7caa79c4639aeaf05831aa1534c65">ToString</a>();
100<a name="l00169"></a><a class="code" href="class_f_u_string_builder_t.html#b477ca7ae65f867c5c0607a30134ab5a">00169</a>     <a class="code" href="class_f_u_string_builder_t.html#b477ca7ae65f867c5c0607a30134ab5a">operator String</a>() { <span class="keywordflow">return</span> <a class="code" href="class_f_u_string_builder_t.html#84c7caa79c4639aeaf05831aa1534c65">ToString</a>(); }
101<a name="l00175"></a>00175 <span class="keyword">const</span> Char* <a class="code" href="class_f_u_string_builder_t.html#1fa2543a75ae974e86aaef3ebf726e0c">ToCharPtr</a>();
102<a name="l00176"></a><a class="code" href="class_f_u_string_builder_t.html#485b36648e632cff2f495374d25c7d25">00176</a>     <a class="code" href="class_f_u_string_builder_t.html#485b36648e632cff2f495374d25c7d25">operator const Char*</a>() { <span class="keywordflow">return</span> <a class="code" href="class_f_u_string_builder_t.html#1fa2543a75ae974e86aaef3ebf726e0c">ToCharPtr</a>(); }
103<a name="l00183"></a>00183     int32 <a class="code" href="class_f_u_string_builder_t.html#468e24745f22f07b2ff3aaebedb92158">index</a>(Char c);
104<a name="l00184"></a>00184
105<a name="l00190"></a>00190     int32 <a class="code" href="class_f_u_string_builder_t.html#c9c5a141f6775db8e5dbd5a228d4d154">rindex</a>(Char c);
106<a name="l00191"></a>00191
107<a name="l00192"></a>00192 <span class="keyword">private</span>:
108<a name="l00193"></a>00193 <span class="keywordtype">void</span> enlarge(size_t minimum);
109<a name="l00194"></a>00194 };
110<a name="l00195"></a>00195
111<a name="l00200"></a><a class="code" href="class_sprint_f.html">00200</a> <span class="keyword">class </span><a class="code" href="class_sprint_f.html">SprintF</a>
112<a name="l00201"></a>00201 {
113<a name="l00202"></a>00202 <span class="keyword">public</span>:
114<a name="l00207"></a><a class="code" href="class_sprint_f.html#f7e05374b4ff509f7a350aa728aa57d1">00207</a>     <span class="keywordtype">void</span> <a class="code" href="class_sprint_f.html#f7e05374b4ff509f7a350aa728aa57d1">PrintInt32</a>(<span class="keywordtype">char</span>* output, uint32 length, int32 i) { snprintf(output, length, <span class="stringliteral">"%i"</span>, i); }
115<a name="l00208"></a>00208
116<a name="l00213"></a><a class="code" href="class_sprint_f.html#2b620bbb5f367717d87f2c3a3b78ecb6">00213</a>     <span class="keywordtype">void</span> <a class="code" href="class_sprint_f.html#2b620bbb5f367717d87f2c3a3b78ecb6">PrintUInt32</a>(<span class="keywordtype">char</span>* output, uint32 length, uint32 i) { snprintf(output, length, <span class="stringliteral">"%u"</span>, i); }
117<a name="l00214"></a><a class="code" href="class_sprint_f.html#1887ed57bf0cd1f8072f28f3aba30133">00214</a>     <span class="keywordtype">void</span> <a class="code" href="class_sprint_f.html#1887ed57bf0cd1f8072f28f3aba30133">PrintUInt64</a>(<span class="keywordtype">char</span>* output, uint32 length, uint64 i) { snprintf(output, length, <span class="stringliteral">"%u"</span>, i); }
118<a name="l00220"></a><a class="code" href="class_sprint_f.html#e92f15ccaff204641f4bc34aa2827a61">00220</a>     <span class="keywordtype">void</span> <a class="code" href="class_sprint_f.html#e92f15ccaff204641f4bc34aa2827a61">PrintFloat</a>(<span class="keywordtype">char</span>* output, uint32 length, <span class="keywordtype">double</span> f) { snprintf(output, length, <span class="stringliteral">"%f"</span>, f); }
119<a name="l00221"></a>00221
120<a name="l00225"></a><a class="code" href="class_sprint_f.html#03ca2d1e8a136d608a9c543380ce08d4">00225</a>     size_t <a class="code" href="class_sprint_f.html#03ca2d1e8a136d608a9c543380ce08d4">StrLen</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* in) { <span class="keywordflow">return</span> strlen(in); }
121<a name="l00226"></a>00226 };
122<a name="l00227"></a>00227
123<a name="l00232"></a><a class="code" href="class_s_fprint_f.html">00232</a> <span class="keyword">class </span><a class="code" href="class_s_fprint_f.html">SFprintF</a>
124<a name="l00233"></a>00233 {
125<a name="l00234"></a>00234 <span class="keyword">public</span>:
126<a name="l00239"></a><a class="code" href="class_s_fprint_f.html#00754b6a56d19fa3328064e831409242">00239</a>     <span class="keywordtype">void</span> <a class="code" href="class_s_fprint_f.html#00754b6a56d19fa3328064e831409242">PrintInt32</a>(fchar* output, uint32 length, int32 i) { fsnprintf(output, length, FC(<span class="stringliteral">"%i"</span>), i); }
127<a name="l00240"></a>00240
128<a name="l00245"></a><a class="code" href="class_s_fprint_f.html#aff4403847c01494c22fe22bce34d16b">00245</a>     <span class="keywordtype">void</span> <a class="code" href="class_s_fprint_f.html#aff4403847c01494c22fe22bce34d16b">PrintUInt32</a>(fchar* output, uint32 length, uint32 i) { fsnprintf(output, length, FC(<span class="stringliteral">"%u"</span>), i); }
129<a name="l00246"></a>00246
130<a name="l00251"></a><a class="code" href="class_s_fprint_f.html#5c9dde3dd946889f6d5e254305001055">00251</a>     <span class="keywordtype">void</span> <a class="code" href="class_s_fprint_f.html#5c9dde3dd946889f6d5e254305001055">PrintUInt64</a>(fchar* output, uint32 length, uint64 i) { fsnprintf(output, length, FC(<span class="stringliteral">"%u"</span>), i); }
131<a name="l00252"></a>00252
132<a name="l00257"></a><a class="code" href="class_s_fprint_f.html#541661bc6d313414a578a7bd7703cb9d">00257</a>     <span class="keywordtype">void</span> <a class="code" href="class_s_fprint_f.html#541661bc6d313414a578a7bd7703cb9d">PrintFloat</a>(fchar* output, uint32 length, <span class="keywordtype">double</span> f) { fsnprintf(output, length, FC(<span class="stringliteral">"%f"</span>), f); }
133<a name="l00258"></a>00258
134<a name="l00262"></a><a class="code" href="class_s_fprint_f.html#baf2df4140c2aa3112f3790383e8056f">00262</a>     size_t <a class="code" href="class_s_fprint_f.html#baf2df4140c2aa3112f3790383e8056f">StrLen</a>(<span class="keyword">const</span> fchar* in) { <span class="keywordflow">return</span> fstrlen(in); }
135<a name="l00263"></a>00263 };
136<a name="l00264"></a>00264
137<a name="l00265"></a><a class="code" href="_f_u_string_builder_8h.html#ef9e734749f693349166d1590ae48c2f">00265</a> <span class="keyword">typedef</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT&lt;fchar, SFprintF&gt;</a> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilder</a>;
138<a name="l00266"></a><a class="code" href="_f_u_string_builder_8h.html#c5173915e0735b6a47328aeed38770d7">00266</a> <span class="keyword">typedef</span> <a class="code" href="class_f_u_string_builder_t.html">FUStringBuilderT&lt;char, SprintF&gt;</a> <a class="code" href="class_f_u_string_builder_t.html">FUSStringBuilder</a>; 
139<a name="l00271"></a>00271 FCOLLADA_EXPORT <span class="keyword">extern</span> FUStringBuilder <a class="code" href="_f_u_string_builder_8h.html#3d808ba9856cb5cc68f03d21bb0cc508">globalBuilder</a>;
140<a name="l00272"></a>00272
141<a name="l00276"></a>00276 FCOLLADA_EXPORT <span class="keyword">extern</span> FUSStringBuilder <a class="code" href="_f_u_string_builder_8h.html#f59ffe58166fe5771701c630749dde26">globalSBuilder</a>;
142<a name="l00277"></a>00277
143<a name="l00278"></a>00278 <span class="preprocessor">#include "FUtils/FUStringBuilder.hpp"</span>
144<a name="l00279"></a>00279
145<a name="l00280"></a>00280 <span class="preprocessor">#endif // _FCU_STRING_BUILDER_</span>
146<a name="l00281"></a>00281 <span class="preprocessor"></span>
147</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
148<a href="http://www.doxygen.org/index.html">
149<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
150</body>
151</html>
Note: See TracBrowser for help on using the repository browser.