aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/common_8h-source.html
blob: 6c9aef475828444b1ccd9db60efe41381ca6006b (plain)
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>common.h</h1><a href="common_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#ifndef NL_COMMON_H</font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_COMMON_H</font>
00028 <font class="preprocessor"></font>
00029 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
00030 
00031 <font class="preprocessor">#include &lt;ctype.h&gt;</font>
00032 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
00033 <font class="preprocessor">#include &lt;stdarg.h&gt;</font>
00034 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00035 <font class="preprocessor">#include &lt;math.h&gt;</font>
00036 <font class="preprocessor">#include &lt;algorithm&gt;</font>
00037 <font class="preprocessor">#include &lt;string&gt;</font>
00038 <font class="preprocessor">#include &lt;vector&gt;</font>
00039 <font class="preprocessor">#include &lt;sstream&gt;</font>
00040 
00041 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00042 <font class="preprocessor"></font><font class="preprocessor">#       include &lt;process.h&gt;</font>
00043 <font class="preprocessor">#else</font>
00044 <font class="preprocessor"></font><font class="preprocessor">#       include &lt;math.h&gt;</font>
00045 <font class="preprocessor">#       include &lt;<a class="code" href="unistd_8h.html">unistd.h</a>&gt;</font>
00046 <font class="preprocessor">#       include &lt;sys/types.h&gt;</font>
00047 <font class="preprocessor">#endif</font>
00048 <font class="preprocessor"></font>
00050 <font class="keyword">namespace       </font>NLMISC
00051 {
00052 
00053 <font class="comment">// Windows posix function remapping</font>
00054 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00055 <font class="preprocessor"></font><font class="preprocessor">#define vsnprintf _vsnprintf</font>
00056 <font class="preprocessor"></font><font class="preprocessor">#endif // NL_OS_WINDOWS</font>
00057 <font class="preprocessor"></font>
00058 
00059 
00066 <font class="keyword">const</font> <font class="keywordtype">int</font> <a class="code" href="namespaceNLMISC.html#a6">MaxCStringSize</a> = 1024*2;
00067 
00068 
00071 <font class="keyword">const</font> <font class="keywordtype">double</font> <a class="code" href="namespaceNLMISC.html#a7">Pi</a> = 3.1415926535897932384626433832795;
00072 
00073 
<a name="l00094"></a><a class="code" href="common_8h.html#a0">00094</a> <font class="preprocessor">#define NLMISC_CONVERT_VARGS(_dest,_format,_size) \</font>
00095 <font class="preprocessor">char _cstring[_size]; \</font>
00096 <font class="preprocessor">va_list _args; \</font>
00097 <font class="preprocessor">va_start (_args, _format); \</font>
00098 <font class="preprocessor">int _res = vsnprintf (_cstring, _size-1, _format, _args); \</font>
00099 <font class="preprocessor">if (_res == -1 || _res == _size-1) \</font>
00100 <font class="preprocessor">{ \</font>
00101 <font class="preprocessor">        _cstring[_size-1] = '\0'; \</font>
00102 <font class="preprocessor">} \</font>
00103 <font class="preprocessor">va_end (_args); \</font>
00104 <font class="preprocessor">_dest = _cstring</font>
00105 <font class="preprocessor"></font>
00106 
00107 
00115 sint <a class="code" href="namespaceNLMISC.html#a211">smprintf</a>( <font class="keywordtype">char</font> *buffer, size_t count, <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>, ... );
00116 
00117 
00120 <font class="keyword">inline</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNLMISC.html#a212">frand</a>(<font class="keywordtype">float</font> mod)
00121 {
00122         <font class="keywordtype">double</font>  <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = (double) rand();
00123         <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>/= (double) RAND_MAX;
00124         <font class="keywordflow">return</font> (float)(<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> * mod);
00125 }
00126 
00127 
00130 <font class="keyword">inline</font> sint <a class="code" href="namespaceNLMISC.html#a213">fsgn</a>(<font class="keywordtype">double</font> f)
00131 {
00132         <font class="keywordflow">if</font>(f&lt;0)
00133                 <font class="keywordflow">return</font> -1;
00134         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(f&gt;0)
00135                 <font class="keywordflow">return</font> 1;
00136         <font class="keywordflow">else</font>
00137                 <font class="keywordflow">return</font> 0;
00138 }
00139 
00140 
00143 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(<font class="keyword">const</font> T &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00144 {
00145         <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00146 }
00147 
00148 
00151 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T, <font class="keyword">class</font> U, <font class="keyword">class</font> V&gt;     <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(T &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, <font class="keyword">const</font> U &amp;<a class="code" href="bit__set_8cpp.html#a0">min</a>, <font class="keyword">const</font> V &amp;max)
00152 {
00153         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> &lt; <a class="code" href="bit__set_8cpp.html#a0">min</a>) ? <a class="code" href="bit__set_8cpp.html#a0">min</a> : <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00154         <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> &gt; max) ? max : <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00155 }
00156 
00157 
00160 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a216">minof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c)
00161         {<font class="keywordflow">return</font> <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(std::min(a,b),c);}
00162 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a216">minof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c,  <font class="keyword">const</font> T&amp; d)
00163         {<font class="keywordflow">return</font> <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="namespaceNLMISC.html#a216">minof</a>(a,b,c),d);}
00164 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a216">minof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c,  <font class="keyword">const</font> T&amp; d,  <font class="keyword">const</font> T&amp; e)
00165         {<font class="keywordflow">return</font> <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="namespaceNLMISC.html#a216">minof</a>(a,b,c,d),e);}
00166 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a219">maxof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c)
00167         {<font class="keywordflow">return</font> std::max(std::max(a,b),c);}
00168 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a219">maxof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c,  <font class="keyword">const</font> T&amp; d)
00169         {<font class="keywordflow">return</font> std::max(<a class="code" href="namespaceNLMISC.html#a219">maxof</a>(a,b,c),d);}
00170 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> T <a class="code" href="namespaceNLMISC.html#a219">maxof</a>(<font class="keyword">const</font> T&amp; a,  <font class="keyword">const</font> T&amp; b,  <font class="keyword">const</font> T&amp; c,  <font class="keyword">const</font> T&amp; d,  <font class="keyword">const</font> T&amp; e)
00171         {<font class="keywordflow">return</font> std::max(<a class="code" href="namespaceNLMISC.html#a219">maxof</a>(a,b,c,d),e);}
00172 
00177 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt;       <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a222">contReset</a> (T&amp; a)
00178 {
00179         a.~T();
00180 <font class="preprocessor">#undef new</font>
00181 <font class="preprocessor"></font>        <font class="keyword">new</font> (&amp;a) T;
00182 <font class="preprocessor">#define new NL_NEW</font>
00183 <font class="preprocessor"></font>}
00184 
00190 uint                    <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00191 
00197 uint                    <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00198 
00201 <font class="keywordtype">bool</font>                    <a class="code" href="namespaceNLMISC.html#a225">isPowerOf2</a> (sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00202 
00203 
00206 <font class="keyword">inline</font> <font class="keywordtype">float</font>    <a class="code" href="namespaceNLMISC.html#a226">degToRad</a>( <font class="keywordtype">float</font> deg )
00207 {
00208         <font class="keywordflow">return</font> deg * (float)<a class="code" href="namespaceNLMISC.html#a7">Pi</a> / 180.0f;
00209 }
00210 
00211 
00214 <font class="keyword">inline</font> <font class="keywordtype">float</font>    <a class="code" href="namespaceNLMISC.html#a227">radToDeg</a>( <font class="keywordtype">float</font> rad )
00215 {
00216         <font class="keywordflow">return</font> rad * 180.0f / (float)<a class="code" href="namespaceNLMISC.html#a7">Pi</a>;
00217 }
00218 
00219 
00222 <font class="keyword">inline</font> <font class="keywordtype">double</font>   <a class="code" href="namespaceNLMISC.html#a228">isValidDouble</a> (<font class="keywordtype">double</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00223 {
00224 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00225 <font class="preprocessor"></font>        <font class="keywordflow">return</font> _finite(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) &amp;&amp; !_isnan(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00226 <font class="preprocessor">#else</font>
00227 <font class="preprocessor"></font>        <font class="keywordflow">return</font> !isnan(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) &amp;&amp; !isinf(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00228 <font class="preprocessor">#endif</font>
00229 <font class="preprocessor"></font>}
00230 
00231 
00235 std::string             &amp;<a class="code" href="namespaceNLMISC.html#a229">strlwr</a> ( std::string &amp;str );
00236 std::string             <a class="code" href="namespaceNLMISC.html#a229">strlwr</a> ( <font class="keyword">const</font> std::string &amp;str );
00237 
00241 <font class="keywordtype">char</font>                    *<a class="code" href="namespaceNLMISC.html#a229">strlwr</a> ( <font class="keywordtype">char</font> *str );
00242 
00246 std::string             &amp;<a class="code" href="namespaceNLMISC.html#a232">strupr</a> ( std::string &amp;str );
00247 
00251 <font class="keywordtype">char</font>                    *<a class="code" href="namespaceNLMISC.html#a232">strupr</a> ( <font class="keywordtype">char</font> *str );
00252 
00256 sint                    <a class="code" href="namespaceNLMISC.html#a234">nlstricmp</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *lhs, <font class="keyword">const</font> <font class="keywordtype">char</font> *rhs);
00257 
00260 sint                    <a class="code" href="namespaceNLMISC.html#a234">nlstricmp</a>(<font class="keyword">const</font> std::string &amp;lhs, <font class="keyword">const</font> std::string &amp;rhs);
00261 
00262 
00263 
<a name="l00268"></a><a class="code" href="classNLMISC_1_1Exception.html">00268</a> <font class="keyword">class </font>Exception : <font class="keyword">public</font> std::exception
00269 {
00270 <font class="keyword">protected</font>:
<a name="l00271"></a><a class="code" href="classNLMISC_1_1Exception.html#n0">00271</a>         std::string     <a class="code" href="classNLMISC_1_1Exception.html#n0">_Reason</a>;
00272 <font class="keyword">public</font>:
00273         <a class="code" href="classNLMISC_1_1Exception.html#a0">Exception</a>();
00274         <a class="code" href="classNLMISC_1_1Exception.html#a0">Exception</a>(<font class="keyword">const</font> std::string &amp;reason);
00275         <a class="code" href="classNLMISC_1_1Exception.html#a0">Exception</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>, ...);
<a name="l00276"></a><a class="code" href="classNLMISC_1_1Exception.html#a3">00276</a>         <font class="keyword">virtual</font> <a class="code" href="classNLMISC_1_1Exception.html#a3">~Exception</a>() <font class="keywordflow">throw</font>() {};
00277         <font class="keyword">virtual</font> <font class="keyword">const</font> <font class="keywordtype">char</font>      *<a class="code" href="classNLMISC_1_1Exception.html#a4">what</a>() <font class="keyword">const</font> <font class="keywordflow">throw</font>();
00278 };
00279 
00280 
00285 <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a236">nlSleep</a>( uint32 ms );
00286 
00287 
00289 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00290 <font class="preprocessor"></font><font class="preprocessor">#       define getpid _getpid</font>
00291 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00292 <font class="preprocessor"></font>
00294 uint <a class="code" href="namespaceNLMISC.html#a237">getThreadId</a>();
00295 
00297 std::string <a class="code" href="namespaceNLMISC.html#a238">stringFromVector</a>( <font class="keyword">const</font> std::vector&lt;uint8&gt;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, <font class="keywordtype">bool</font> limited = <font class="keyword">true</font> );
00298 
00299 
00301 sint64 <a class="code" href="namespaceNLMISC.html#a239">atoiInt64</a> (<font class="keyword">const</font> <font class="keywordtype">char</font> *ident, sint64 base = 10);
00302 
00304 <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a240">itoaInt64</a> (sint64 number, <font class="keywordtype">char</font> *str, sint64 base = 10);
00305 
00306 
00308 std::string <a class="code" href="namespaceNLMISC.html#a241">bytesToHumanReadable</a> (uint32 bytes);
00309 
00310 
00313 <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a242">launchProgram</a> (<font class="keyword">const</font> std::string &amp;programName, <font class="keyword">const</font> std::string &amp;arguments);
00314 
00315 
00316 
00317 
00318 
00323 <font class="keyword">template</font>&lt;<font class="keyword">class</font> T&gt; std::string <a class="code" href="namespaceNLMISC.html#a243">toString</a> (<font class="keyword">const</font> T &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>)
00324 {
00325         std::stringstream ss;
00326         ss &lt;&lt; <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
00327         <font class="keywordflow">return</font> ss.str();
00328 }
00329 
00330 
00335 <font class="keyword">inline</font> std::string <a class="code" href="namespaceNLMISC.html#a243">toString</a> (<font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>, ...)
00336 {
00337         std::string Result;
00338         <a class="code" href="common_8h.html#a0">NLMISC_CONVERT_VARGS</a> (Result, <a class="code" href="driver__opengl__extension__def_8h.html#a398">format</a>, NLMISC::MaxCStringSize);
00339         <font class="keywordflow">return</font> Result;
00340 }
00341 
00342 
00343 <font class="comment">/* All the code above is used to add our types (uint8, ...) in the stringstream (used by the toString() function).</font>
00344 <font class="comment"> * So we can use stringstream operator &lt;&lt; and &gt;&gt; with all NeL simple types (except for ucchar and ucstring)</font>
00345 <font class="comment"> */</font>
00346 
00347 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00348 <font class="preprocessor"></font>
00349 <font class="preprocessor">#if _MSC_VER &lt; 1300     // visual or older (on visual .NET, we don't need to do that)</font>
00350 <font class="preprocessor"></font>
00351 <font class="preprocessor">#define NLMISC_ADD_BASIC_ISTREAM_OPERATOR(__type,__casttype) \</font>
00352 <font class="preprocessor">template &lt;class _CharT, class _Traits&gt; \</font>
00353 <font class="preprocessor">std::basic_istream&lt;_CharT, _Traits&gt;&amp; __cdecl \</font>
00354 <font class="preprocessor">operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp; __is, __type&amp; __z) \</font>
00355 <font class="preprocessor">{ \</font>
00356 <font class="preprocessor">        __casttype __z2 = (__casttype) __z; \</font>
00357 <font class="preprocessor">        __is.operator&gt;&gt;(__z2); \</font>
00358 <font class="preprocessor">        __z = (__type) __z2; \</font>
00359 <font class="preprocessor">        return __is; \</font>
00360 <font class="preprocessor">} \</font>
00361 <font class="preprocessor"> \</font>
00362 <font class="preprocessor">template &lt;class _CharT, class _Traits&gt; \</font>
00363 <font class="preprocessor">std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __cdecl \</font>
00364 <font class="preprocessor">operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __os, const __type&amp; __z) \</font>
00365 <font class="preprocessor">{ \</font>
00366 <font class="preprocessor">        std::basic_ostringstream&lt;_CharT, _Traits, std::allocator&lt;_CharT&gt; &gt; __tmp; \</font>
00367 <font class="preprocessor">        __tmp &lt;&lt; (__casttype) __z; \</font>
00368 <font class="preprocessor">        return __os &lt;&lt; __tmp.str(); \</font>
00369 <font class="preprocessor">}</font>
00370 <font class="preprocessor"></font>
00371 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(uint8, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>);
00372 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(sint8, <font class="keywordtype">signed</font> <font class="keywordtype">int</font>);
00373 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(uint16, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>);
00374 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(sint16, <font class="keywordtype">signed</font> <font class="keywordtype">int</font>);
00375 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(uint32, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>);
00376 NLMISC_ADD_BASIC_ISTREAM_OPERATOR(sint32, <font class="keywordtype">signed</font> <font class="keywordtype">int</font>);
00377 
00378 <font class="preprocessor">#endif // _MSC_VER &lt; 1300</font>
00379 <font class="preprocessor"></font>
00380 
00381 <font class="keyword">template</font> &lt;<font class="keyword">class</font> _CharT, <font class="keyword">class</font> _Traits&gt;
00382 std::basic_istream&lt;_CharT, _Traits&gt;&amp; __cdecl
00383 operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp; __is, uint64&amp; __z)
00384 {
00385         __z = 0;
00386         <font class="keywordtype">bool</font> neg = <font class="keyword">false</font>;
00387         <font class="keywordtype">char</font> c;
00388         <font class="keywordflow">do</font>
00389         {
00390                 __is &gt;&gt; c;
00391         }
00392         <font class="keywordflow">while</font> (isspace(c));
00393 
00394         <font class="keywordflow">if</font> (c == <font class="charliteral">'-'</font>)
00395         {
00396                 neg = <font class="keyword">true</font>;
00397                 __is &gt;&gt; c;
00398         }
00399 
00400         <font class="keywordflow">while</font> (isdigit(c))
00401         {
00402                 __z *= 10;
00403                 __z += c-<font class="charliteral">'0'</font>;
00404                 __is &gt;&gt; c;
00405                 <font class="keywordflow">if</font> (__is.fail())
00406                         <font class="keywordflow">break</font>;
00407         }
00408 
00409         <font class="keywordflow">if</font> (neg) __z = 0;
00410 
00411         <font class="keywordflow">return</font> __is;
00412 }
00413 
00414 <font class="keyword">template</font> &lt;<font class="keyword">class</font> _CharT, <font class="keyword">class</font> _Traits&gt;
00415 std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __cdecl
00416 operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __os, <font class="keyword">const</font> uint64&amp; __z)
00417 {
00418         std::basic_ostringstream&lt;_CharT, _Traits, std::allocator&lt;_CharT&gt; &gt; __res;
00419 
00420         <font class="keywordflow">if</font> (__z == 0)
00421         {
00422                 __res &lt;&lt; <font class="charliteral">'0'</font>;
00423         }
00424         <font class="keywordflow">else</font>
00425         {
00426                 std::basic_ostringstream&lt;_CharT, _Traits, std::allocator&lt;_CharT&gt; &gt; __tmp;
00427                 uint64  __z2 = __z;
00428                 <font class="keywordflow">while</font> (__z2 != 0)
00429                 {
00430                         __tmp &lt;&lt; (char)((__z2%10)+<font class="charliteral">'0'</font>);
00431                         __z2 /= 10;
00432                 }
00433 
00434                 uint __s = __tmp.str().size();
00435                 <font class="keywordflow">for</font> (uint i = 0; i &lt; __s; i++)
00436                         __res &lt;&lt; __tmp.str()[__s - 1 - i];
00437         }
00438         <font class="keywordflow">return</font> __os &lt;&lt; __res.str();
00439 }
00440 
00441 <font class="keyword">template</font> &lt;<font class="keyword">class</font> _CharT, <font class="keyword">class</font> _Traits&gt;
00442 std::basic_istream&lt;_CharT, _Traits&gt;&amp; __cdecl
00443 operator&gt;&gt;(std::basic_istream&lt;_CharT, _Traits&gt;&amp; __is, sint64&amp; __z)
00444 {
00445         __z = 0;
00446         <font class="keywordtype">bool</font> neg = <font class="keyword">false</font>;
00447         <font class="keywordtype">char</font> c;
00448         <font class="keywordflow">do</font>
00449         {
00450                 __is &gt;&gt; c;
00451         }
00452         <font class="keywordflow">while</font> (isspace(c));
00453 
00454         <font class="keywordflow">if</font> (c == <font class="charliteral">'-'</font>)
00455         {
00456                 neg = <font class="keyword">true</font>;
00457                 __is &gt;&gt; c;
00458         }
00459 
00460         <font class="keywordflow">while</font> (isdigit(c))
00461         {
00462                 __z *= 10;
00463                 __z += c-<font class="charliteral">'0'</font>;
00464                 __is &gt;&gt; c;
00465                 <font class="keywordflow">if</font> (__is.fail())
00466                         <font class="keywordflow">break</font>;
00467         }
00468 
00469         <font class="keywordflow">if</font> (neg) __z = -__z;
00470 
00471         <font class="keywordflow">return</font> __is;
00472 }
00473 
00474 <font class="keyword">template</font> &lt;<font class="keyword">class</font> _CharT, <font class="keyword">class</font> _Traits&gt;
00475 std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __cdecl
00476 operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp; __os, <font class="keyword">const</font> sint64&amp; __z)
00477 {
00478         std::basic_ostringstream&lt;_CharT, _Traits, std::allocator&lt;_CharT&gt; &gt; __res;
00479 
00480         <font class="keywordflow">if</font> (__z == 0)
00481         {
00482                 __res &lt;&lt; <font class="charliteral">'0'</font>;
00483         }
00484         <font class="keywordflow">else</font> 
00485         {
00486                 sint64  __z2 = __z;
00487 
00488                 <font class="keywordflow">if</font> (__z2 &lt; 0)
00489                 {
00490                         __res &lt;&lt; <font class="charliteral">'-'</font>;
00491                 }
00492 
00493                 std::basic_ostringstream&lt;_CharT, _Traits, std::allocator&lt;_CharT&gt; &gt; __tmp;
00494                 <font class="keywordflow">while</font> (__z2 != 0)
00495                 {
00496                         <font class="keywordflow">if</font> (__z2 &lt; 0)
00497                         {
00498                                 __tmp &lt;&lt; (char)((-(__z2%10))+<font class="charliteral">'0'</font>);
00499                         }
00500                         <font class="keywordflow">else</font>
00501                         {
00502                                 __tmp &lt;&lt; (char)((__z2%10)+<font class="charliteral">'0'</font>);
00503                         }
00504                         __z2 /= 10;
00505                 }
00506 
00507                 uint __s = __tmp.str().size();
00508                 <font class="keywordflow">for</font> (uint i = 0; i &lt; __s; i++)
00509                         __res &lt;&lt; __tmp.str()[__s - 1 - i];
00510         }
00511         <font class="keywordflow">return</font> __os &lt;&lt; __res.str();
00512 }
00513 
00514 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
00515 <font class="preprocessor"></font>
00516 
00517 
00518 
00519 }       <font class="comment">// NLMISC</font>
00520 
00521 <font class="preprocessor">#endif  // NL_COMMON_H</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>