diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/mem__stream_8h-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/mem__stream_8h-source.html | 826 |
1 files changed, 826 insertions, 0 deletions
diff --git a/docs/doxygen/nel/mem__stream_8h-source.html b/docs/doxygen/nel/mem__stream_8h-source.html new file mode 100644 index 00000000..bd093688 --- /dev/null +++ b/docs/doxygen/nel/mem__stream_8h-source.html @@ -0,0 +1,826 @@ +<!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="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/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="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- 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="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>mem_stream.h</h1><a href="mem__stream_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_MEM_STREAM_H</font> +00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_MEM_STREAM_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 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="object__vector_8h.html">nel/misc/object_vector.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="fast__mem_8h.html">nel/misc/fast_mem.h</a>"</font> +00033 +00034 <font class="keyword">namespace </font>NLMISC +00035 { +00036 +<a name="l00038"></a><a class="code" href="structNLMISC_1_1EMemStream.html">00038</a> <font class="keyword">struct </font>EMemStream : <font class="keyword">public</font> NLMISC::EStream +00039 { +<a name="l00040"></a><a class="code" href="structNLMISC_1_1EMemStream.html#a0">00040</a> <a class="code" href="structNLMISC_1_1EMemStream.html#a0">EMemStream</a>( <font class="keyword">const</font> std::string& str ) : <a class="code" href="structNLMISC_1_1EStream.html#a0">EStream</a>( str ) {} +00041 }; +00042 +<a name="l00044"></a><a class="code" href="structNLMISC_1_1EStreamOverflow.html">00044</a> <font class="keyword">struct </font>EStreamOverflow : <font class="keyword">public</font> EMemStream +00045 { +<a name="l00046"></a><a class="code" href="structNLMISC_1_1EStreamOverflow.html#a0">00046</a> <a class="code" href="structNLMISC_1_1EStreamOverflow.html#a0">EStreamOverflow</a>() : <a class="code" href="structNLMISC_1_1EMemStream.html#a0">EMemStream</a>( "Stream Overflow Error" ) {} +00047 }; +00048 +00049 <font class="comment">/*</font> +00051 <font class="comment">typedef std::vector<uint8> CVector8;</font> +00052 <font class="comment"></font> +00054 <font class="comment">typedef CVector8::iterator It8;</font> +00055 <font class="comment">*/</font> +00056 +00057 +<a name="l00064"></a><a class="code" href="classNLMISC_1_1CMemStream.html">00064</a> <font class="keyword">class </font>CMemStream : <font class="keyword">public</font> NLMISC::IStream +00065 { +00066 <font class="keyword">public</font>: +00067 +<a name="l00069"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a0">00069</a> <a class="code" href="classNLMISC_1_1CMemStream.html#a0">CMemStream</a>( <font class="keywordtype">bool</font> inputStream=<font class="keyword">false</font>, <font class="keywordtype">bool</font> stringmode=<font class="keyword">false</font>, uint32 defaultcapacity=0 ) : +00070 NLMISC::<a class="code" href="classNLMISC_1_1IStream.html#a0">IStream</a>( inputStream ), <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a>( stringmode ) +00071 { +00072 <a class="code" href="classNLMISC_1_1CMemStream.html#n3">_DefaultCapacity</a> = std::max( defaultcapacity, (uint32)16 ); <font class="comment">// prevent from no allocation</font> +00073 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize (<a class="code" href="classNLMISC_1_1CMemStream.html#n3">_DefaultCapacity</a>); +00074 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00075 } +00076 +<a name="l00078"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a1">00078</a> <a class="code" href="classNLMISC_1_1CMemStream.html#a0">CMemStream</a>( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a0">CMemStream</a>& other ) : +00079 <a class="code" href="classNLMISC_1_1IStream.html#a0">IStream</a> (other) +00080 { +00081 <a class="code" href="classNLMISC_1_1CMemStream.html#a2">operator=</a>( other ); +00082 } +00083 +<a name="l00085"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a2">00085</a> <a class="code" href="classNLMISC_1_1CMemStream.html#a0">CMemStream</a>& <a class="code" href="classNLMISC_1_1CMemStream.html#a2">operator=</a>( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a0">CMemStream</a>& other ) +00086 { +00087 IStream::operator= (other); +00088 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a> = other._Buffer; +00089 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + other.lengthS(); +00090 <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a> = other._StringMode; +00091 <a class="code" href="classNLMISC_1_1CMemStream.html#n3">_DefaultCapacity</a> = other._DefaultCapacity; +00092 <font class="keywordflow">return</font> *<font class="keyword">this</font>; +00093 } +00094 +<a name="l00096"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a3">00096</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a3">setStringMode</a>( <font class="keywordtype">bool</font> stringmode ) { <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a> = stringmode; } +00097 +<a name="l00099"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a4">00099</a> <font class="keywordtype">bool</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a4">stringMode</a>()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a>; } +00100 +00102 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>(uint8 *buf, uint len); +00103 +00105 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a6">serialBit</a>(<font class="keywordtype">bool</font> &bit); +00106 +00118 <font class="keyword">virtual</font> <font class="keywordtype">bool</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a7">seek</a> (sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>, <a class="code" href="classNLMISC_1_1IStream.html#s3">TSeekOrigin</a> origin) <font class="keywordflow">throw</font>(EStream); +00119 +<a name="l00131"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a8">00131</a> <font class="keyword">virtual</font> sint32 <a class="code" href="classNLMISC_1_1CMemStream.html#a8">getPos</a> () <font class="keywordflow">throw</font>(EStream) +00132 { +00133 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> - <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00134 } +00135 +<a name="l00137"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a9">00137</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a9">clear</a>() +00138 { +00139 <a class="code" href="classNLMISC_1_1CMemStream.html#a17">resetPtrTable</a>(); +00140 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.clear(); +00141 <font class="keywordflow">if</font> (!<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00142 { +00143 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize (<a class="code" href="classNLMISC_1_1CMemStream.html#n3">_DefaultCapacity</a>); +00144 } +00145 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00146 } +00147 +<a name="l00152"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a10">00152</a> <font class="keyword">virtual</font> uint32 <a class="code" href="classNLMISC_1_1CMemStream.html#a10">length</a>()<font class="keyword"> const</font> +00153 <font class="keyword"> </font>{ +00154 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00155 { +00156 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>(); +00157 } +00158 <font class="keywordflow">else</font> +00159 { +00160 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>(); +00161 } +00162 } +00163 +<a name="l00167"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a11">00167</a> <font class="keyword">const</font> uint8 *<a class="code" href="classNLMISC_1_1CMemStream.html#a11">buffer</a>()<font class="keyword"> const</font> +00168 <font class="keyword"> </font>{ +00169 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00170 <font class="comment">/* if ( _Buffer.empty() )</font> +00171 <font class="comment"> {</font> +00172 <font class="comment"> return NULL;</font> +00173 <font class="comment"> }</font> +00174 <font class="comment"> else</font> +00175 <font class="comment"> {</font> +00176 <font class="comment"> return &(*_Buffer.begin());</font> +00177 <font class="comment"> }*/</font> +00178 } +00179 +00180 <font class="comment">/* </font> +00181 <font class="comment"> const CVector8& bufferAsVector() const</font> +00182 <font class="comment"> {</font> +00183 <font class="comment"> return _Buffer;</font> +00184 <font class="comment"> }</font> +00185 <font class="comment"></font> +00187 <font class="comment"> CVector8& bufferAsVector()</font> +00188 <font class="comment"> {</font> +00189 <font class="comment"> return _Buffer;</font> +00190 <font class="comment"> }</font> +00191 <font class="comment">*/</font> +00192 <font class="comment">// When you fill the buffer externaly (using bufferAsVector) you have to reset the BufPos calling this method</font> +<a name="l00193"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a12">00193</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a12">resetBufPos</a>() { <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); } +00194 +<a name="l00196"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a13">00196</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a13">fill</a>( <font class="keyword">const</font> uint8 *srcbuf, uint32 len ) +00197 { +00198 <font class="keywordflow">if</font> (len == 0) <font class="keywordflow">return</font>; +00199 +00200 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize( len ); +00201 CFastMem::memcpy( <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(), srcbuf, len ); +00202 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00203 { +00204 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00205 } +00206 <font class="keywordflow">else</font> +00207 { +00208 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size(); +00209 } +00210 } +00211 +00212 <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a14">resize</a> (uint32 size); +00213 +<a name="l00218"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a15">00218</a> uint8 *<a class="code" href="classNLMISC_1_1CMemStream.html#a15">bufferToFill</a>( uint32 msgsize ) +00219 { +00220 <font class="keywordflow">if</font> (msgsize == 0) <font class="keywordflow">return</font> NULL; +00221 +00222 <font class="comment">// Same as fill() but the memcpy is done by an external function</font> +00223 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize( msgsize ); +00224 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + msgsize; +00225 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00226 } +00227 +<a name="l00229"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a16">00229</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a16">invert</a>() +00230 { +00231 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00232 { +00233 <font class="comment">// In->Out: We want to write (serialize out) what we have read (serialized in)</font> +00234 <a class="code" href="classNLMISC_1_1CMemStream.html#a17">resetPtrTable</a>(); +00235 <a class="code" href="classNLMISC_1_1IStream.html#b8">setInOut</a>( <font class="keyword">false</font> ); +00236 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr()+<a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size(); +00237 } +00238 <font class="keywordflow">else</font> +00239 { +00240 <font class="comment">// Out->In: We want to read (serialize in) what we have written (serialized out)</font> +00241 <a class="code" href="classNLMISC_1_1CMemStream.html#a17">resetPtrTable</a>(); +00242 <a class="code" href="classNLMISC_1_1IStream.html#b8">setInOut</a>( <font class="keyword">true</font> ); +00243 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize (<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> - <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr()); +00244 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00245 } +00246 } +00247 +<a name="l00249"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a17">00249</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a17">resetPtrTable</a>() { IStream::resetPtrTable() ; } +00250 +00252 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font> +00253 <font class="preprocessor"></font> __forceinline +00254 <font class="preprocessor">#endif</font> +<a name="l00255"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a18">00255</a> <font class="preprocessor"></font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a18">increaseBufferIfNecessary</a>(uint32 len) +00256 { +00257 uint32 oldBufferSize = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size(); +00258 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> - <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + len > oldBufferSize) +00259 { +00260 <font class="comment">// need to increase the buffer size</font> +00261 uint32 pos = <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> - <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00262 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize(oldBufferSize*2 + len); +00263 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + pos; +00264 } +00265 } +00266 +00267 +<a name="l00268"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a19">00268</a> <font class="keyword">template</font> <<font class="keyword">class</font> T> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (T &val) +00269 { +00270 <font class="preprocessor">#ifdef NL_LITTLE_ENDIAN</font> +00271 <font class="preprocessor"></font> <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00272 { +00273 <font class="comment">// Check that we don't read more than there is to read</font> +00274 <font class="comment">// TODO OPTIM we can remove the check if we want to be faster (50ms->43ms for 1 million serial)</font> +00275 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()+<font class="keyword">sizeof</font>(T) > <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>() ) +00276 <font class="keywordflow">throw</font> EStreamOverflow(); +00277 <font class="comment">// Serialize in</font> +00278 val = *(T*)<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>; +00279 } +00280 <font class="keywordflow">else</font> +00281 { +00282 <a class="code" href="classNLMISC_1_1CMemStream.html#a18">increaseBufferIfNecessary</a> (<font class="keyword">sizeof</font>(T)); +00283 *(T*)<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = val; +00284 } +00285 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += <font class="keyword">sizeof</font> (T); +00286 <font class="preprocessor">#else // NL_LITTLE_ENDIAN</font> +00287 <font class="preprocessor"></font> IStream::serial( val ); +00288 <font class="preprocessor">#endif // NL_LITTLE_ENDIAN</font> +00289 <font class="preprocessor"></font> } +00290 +00291 <font class="keyword">template</font> <<font class="keyword">class</font> T> +<a name="l00292"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a20">00292</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a20">fastWrite</a>( T& <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> ) +00293 { +00294 <font class="comment">//nldebug( "MEMSTREAM: Writing %u-byte value in %p at pos %u", sizeof(value), this, _BufPos - _Buffer.getPtr() );</font> +00295 <a class="code" href="classNLMISC_1_1CMemStream.html#a18">increaseBufferIfNecessary</a> (<font class="keyword">sizeof</font>(T)); +00296 *(T*)<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>; +00297 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += <font class="keyword">sizeof</font> (T); +00298 } +00299 +00300 <font class="keyword">template</font> <<font class="keyword">class</font> T> +<a name="l00301"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a21">00301</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a21">fastRead</a>( T& <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> ) +00302 { +00303 <font class="comment">//nldebug( "MEMSTREAM: Reading %u-byte value in %p at pos %u", sizeof(value), this, _BufPos - _Buffer.getPtr() );</font> +00304 <font class="comment">// Check that we don't read more than there is to read</font> +00305 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()+<font class="keyword">sizeof</font>(value) > <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>() ) +00306 { +00307 <font class="keywordflow">throw</font> EStreamOverflow(); +00308 } +00309 <font class="comment">// Serialize in</font> +00310 <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> = *(T*)<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>; +00311 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += <font class="keyword">sizeof</font>(value); +00312 } +00313 +00314 +00316 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00317"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a22">00317</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T &obj) { obj.serial(*<font class="keyword">this</font>); } +00318 +00319 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00320"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a23">00320</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::vector<T> &cont) {IStream::serialCont(cont);} +00321 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00322"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a24">00322</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(<a class="code" href="classstd_1_1list.html">std::list<T></a> &cont) {IStream::serialCont(cont);} +00323 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00324"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a25">00324</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::deque<T> &cont) {IStream::serialCont(cont);} +00325 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00326"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a26">00326</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::set<T> &cont) {IStream::serialCont(cont);} +00327 <font class="keyword">template</font><<font class="keyword">class</font> T> +<a name="l00328"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a27">00328</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::multiset<T> &cont) {IStream::serialCont(cont);} +00329 <font class="keyword">template</font><<font class="keyword">class</font> K, <font class="keyword">class</font> T> +<a name="l00330"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a28">00330</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::map<K, T> &cont) {IStream::serialCont(cont);} +00331 <font class="keyword">template</font><<font class="keyword">class</font> K, <font class="keyword">class</font> T> +<a name="l00332"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a29">00332</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::multimap<K, T> &cont) {IStream::serialCont(cont);} +00333 +<a name="l00335"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a30">00335</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::vector<uint8> &cont) {IStream::serialCont(cont);} +<a name="l00337"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a31">00337</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::vector<sint8> &cont) {IStream::serialCont(cont);} +<a name="l00339"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a32">00339</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a23">serialCont</a>(std::vector<bool> &cont) {IStream::serialCont(cont);} +00340 +00341 +00342 +00343 <font class="keyword">template</font><<font class="keyword">class</font> T0,<font class="keyword">class</font> T1> +<a name="l00344"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a33">00344</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T0 &a, T1 &b) +00345 { <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(a); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(b);} +00346 <font class="keyword">template</font><<font class="keyword">class</font> T0,<font class="keyword">class</font> T1,<font class="keyword">class</font> T2> +<a name="l00347"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a34">00347</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T0 &a, T1 &b, T2 &c) +00348 { <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(a); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(b); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(c);} +00349 <font class="keyword">template</font><<font class="keyword">class</font> T0,<font class="keyword">class</font> T1,<font class="keyword">class</font> T2,<font class="keyword">class</font> T3> +<a name="l00350"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a35">00350</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T0 &a, T1 &b, T2 &c, T3 &d) +00351 { <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(a); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(b); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(c); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(d);} +00352 <font class="keyword">template</font><<font class="keyword">class</font> T0,<font class="keyword">class</font> T1,<font class="keyword">class</font> T2,<font class="keyword">class</font> T3,<font class="keyword">class</font> T4> +<a name="l00353"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a36">00353</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T0 &a, T1 &b, T2 &c, T3 &d, T4 &e) +00354 { <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(a); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(b); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(c); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(d); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(e);} +00355 <font class="keyword">template</font><<font class="keyword">class</font> T0,<font class="keyword">class</font> T1,<font class="keyword">class</font> T2,<font class="keyword">class</font> T3,<font class="keyword">class</font> T4,<font class="keyword">class</font> T5> +<a name="l00356"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a37">00356</a> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(T0 &a, T1 &b, T2 &c, T3 &d, T4 &e, T5 &f) +00357 { <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(a); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(b); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(c); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(d); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(e); <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(f);} +00358 +00363 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(uint8 &b) ; +00364 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(sint8 &b) ; +00365 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(uint16 &b) ; +00366 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(sint16 &b) ; +00367 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(uint32 &b) ; +00368 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(sint32 &b) ; +00369 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(uint64 &b) ; +00370 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(sint64 &b) ; +00371 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(<font class="keywordtype">float</font> &b) ; +00372 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(<font class="keywordtype">double</font> &b) ; +00373 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(<font class="keywordtype">bool</font> &b) ; +00374 <font class="preprocessor">#ifndef NL_OS_CYGWIN</font> +00375 <font class="preprocessor"></font> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(<font class="keywordtype">char</font> &b) ; +00376 <font class="preprocessor">#endif</font> +00377 <font class="preprocessor"></font> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(std::string &b) ; +00378 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(<a class="code" href="classucstring.html">ucstring</a> &b) ; +00380 +00381 +00383 +00384 +00386 uint <a class="code" href="classNLMISC_1_1CMemStream.html#z297_0">serialSeparatedBufferIn</a>( uint8 *buf, uint len ); +00387 +00389 <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#z297_1">serialSeparatedBufferOut</a>( uint8 *buf, uint len ); +00390 +00392 <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNLMISC_1_1CMemStream.html#z297_2">serialHex</a>(uint32 &b); +00393 +00395 +00396 <font class="keyword">protected</font>: +00397 +<a name="l00399"></a><a class="code" href="classNLMISC_1_1CMemStream.html#b0">00399</a> uint32 <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()<font class="keyword"> const</font> +00400 <font class="keyword"> </font>{ +00401 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>-<a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr(); +00402 } +00403 +<a name="l00405"></a><a class="code" href="classNLMISC_1_1CMemStream.html#b1">00405</a> uint32 <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>()<font class="keyword"> const</font> +00406 <font class="keyword"> </font>{ +00407 <font class="comment">// return _BufPos-_Buffer.getPtr();</font> +00408 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size(); +00409 } +00410 +<a name="l00411"></a><a class="code" href="classNLMISC_1_1CMemStream.html#n0">00411</a> CObjectVector<uint8, false> <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>; +<a name="l00412"></a><a class="code" href="classNLMISC_1_1CMemStream.html#n1">00412</a> uint8 *<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>; +00413 +00414 <font class="comment">//CVector8 _Buffer;</font> +00415 <font class="comment">//It8 _BufPos;</font> +<a name="l00416"></a><a class="code" href="classNLMISC_1_1CMemStream.html#n2">00416</a> <font class="keywordtype">bool</font> <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a>; +00417 +<a name="l00418"></a><a class="code" href="classNLMISC_1_1CMemStream.html#n3">00418</a> uint32 <a class="code" href="classNLMISC_1_1CMemStream.html#n3">_DefaultCapacity</a>; +00419 }; +00420 +00421 <font class="comment">// Input</font> +<a name="l00422"></a><a class="code" href="mem__stream_8h.html#a0">00422</a> <font class="preprocessor">#define readnumber(dest,thetype,digits,convfunc) \</font> +00423 <font class="preprocessor"> char number_as_cstring [digits+1]; \</font> +00424 <font class="preprocessor"> uint realdigits = serialSeparatedBufferIn( (uint8*)&number_as_cstring, digits ); \</font> +00425 <font class="preprocessor"> number_as_cstring[realdigits] = '\0'; \</font> +00426 <font class="preprocessor"> dest = (thetype)convfunc( number_as_cstring );</font> +00427 <font class="preprocessor"></font> +00428 <font class="comment">// Output</font> +<a name="l00429"></a><a class="code" href="mem__stream_8h.html#a1">00429</a> <font class="preprocessor">#define writenumber(src,format,digits) \</font> +00430 <font class="preprocessor"> char number_as_cstring [digits+1]; \</font> +00431 <font class="preprocessor"> sprintf( number_as_cstring, format, src ); \</font> +00432 <font class="preprocessor"> serialSeparatedBufferOut( (uint8*)&number_as_cstring, strlen(number_as_cstring) );</font> +00433 <font class="preprocessor"></font> +00434 <font class="comment">/*</font> +00435 <font class="comment"> * atoihex</font> +00436 <font class="comment"> */</font> +00437 <font class="keyword">inline</font> <font class="keywordtype">int</font> <a class="code" href="namespaceNLMISC.html#a271">atoihex</a>( <font class="keyword">const</font> <font class="keywordtype">char</font>* ident ) +00438 { +00439 <font class="keywordtype">int</font> number; +00440 sscanf( ident, <font class="stringliteral">"%x"</font>, &number ); +00441 <font class="keywordflow">return</font> number; +00442 } +00443 +00444 <font class="keyword">inline</font> uint32 <a class="code" href="namespaceNLMISC.html#a272">atoui</a>( <font class="keyword">const</font> <font class="keywordtype">char</font> *ident) +00445 { +00446 <font class="keywordflow">return</font> (uint32) strtoul (ident, NULL, 10); +00447 } +00448 +00449 <font class="keyword">const</font> <font class="keywordtype">char</font> <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> = <font class="charliteral">' '</font>; +00450 <font class="keyword">const</font> <font class="keywordtype">int</font> <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a> = 1; <font class="comment">// the code is easier to read with that</font> +00451 +00452 <font class="comment">//</font> +00453 <font class="comment">// inline serial functions</font> +00454 <font class="comment">//</font> +00455 +00456 +00457 <font class="comment">// ======================================================================================================</font> +<a name="l00458"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_0">00458</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(uint8 &b) +00459 { +00460 <font class="keywordflow">if</font> ( _StringMode ) +00461 { +00462 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00463 { +00464 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint8, 3, atoi ); <font class="comment">// 255</font> +00465 } +00466 <font class="keywordflow">else</font> +00467 { +00468 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (uint16)b,<font class="stringliteral">"%hu"</font>, 3 ); +00469 } +00470 } +00471 <font class="keywordflow">else</font> +00472 { +00473 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00474 } +00475 } +00476 +00477 <font class="comment">// ======================================================================================================</font> +<a name="l00478"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_1">00478</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(sint8 &b) +00479 { +00480 <font class="keywordflow">if</font> ( _StringMode ) +00481 { +00482 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00483 { +00484 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint8, 4, atoi ); <font class="comment">// -128</font> +00485 } +00486 <font class="keywordflow">else</font> +00487 { +00488 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (sint16)b, <font class="stringliteral">"%hd"</font>, 4 ); +00489 } +00490 } +00491 <font class="keywordflow">else</font> +00492 { +00493 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00494 } +00495 } +00496 +00497 <font class="comment">// ======================================================================================================</font> +<a name="l00498"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_2">00498</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(uint16 &b) +00499 { +00500 <font class="keywordflow">if</font> ( _StringMode ) +00501 { +00502 <font class="comment">// No byte swapping in text mode</font> +00503 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00504 { +00505 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint16, 5, atoi ); <font class="comment">// 65535</font> +00506 } +00507 <font class="keywordflow">else</font> +00508 { +00509 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%hu"</font>, 5 ); +00510 } +00511 } +00512 <font class="keywordflow">else</font> +00513 { +00514 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00515 } +00516 } +00517 +00518 <font class="comment">// ======================================================================================================</font> +<a name="l00519"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_3">00519</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(sint16 &b) +00520 { +00521 <font class="keywordflow">if</font> ( _StringMode ) +00522 { +00523 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00524 { +00525 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint16, 6, atoi ); <font class="comment">// -32768</font> +00526 } +00527 <font class="keywordflow">else</font> +00528 { +00529 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%hd"</font>, 6 ); +00530 } +00531 } +00532 <font class="keywordflow">else</font> +00533 { +00534 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00535 } +00536 } +00537 +00538 <font class="comment">// ======================================================================================================</font> +<a name="l00539"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_4">00539</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(uint32 &b) +00540 { +00541 <font class="keywordflow">if</font> ( _StringMode ) +00542 { +00543 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00544 { +00545 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint32, 10, <a class="code" href="namespaceNLMISC.html#a272">atoui</a> ); <font class="comment">// 4294967295</font> +00546 } +00547 <font class="keywordflow">else</font> +00548 { +00549 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%u"</font>, 10 ); +00550 } +00551 } +00552 <font class="keywordflow">else</font> +00553 { +00554 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00555 } +00556 } +00557 +00558 +00559 <font class="comment">// ======================================================================================================</font> +<a name="l00560"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_5">00560</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(sint32 &b) +00561 { +00562 <font class="keywordflow">if</font> ( _StringMode ) +00563 { +00564 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00565 { +00566 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint32, 11, atoi ); <font class="comment">// -2147483648</font> +00567 } +00568 <font class="keywordflow">else</font> +00569 { +00570 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%d"</font>, 11 ); +00571 } +00572 } +00573 <font class="keywordflow">else</font> +00574 { +00575 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00576 } +00577 } +00578 +00579 <font class="comment">// ======================================================================================================</font> +<a name="l00580"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_6">00580</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(uint64 &b) +00581 { +00582 <font class="keywordflow">if</font> ( _StringMode ) +00583 { +00584 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00585 { +00586 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint64, 20, atoiInt64 ); <font class="comment">// 18446744073709551615</font> +00587 } +00588 <font class="keywordflow">else</font> +00589 { +00590 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%"</font>NL_I64<font class="stringliteral">"u"</font>, 20 ); +00591 } +00592 } +00593 <font class="keywordflow">else</font> +00594 { +00595 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00596 } +00597 } +00598 +00599 <font class="comment">// ======================================================================================================</font> +<a name="l00600"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_7">00600</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(sint64 &b) +00601 { +00602 <font class="keywordflow">if</font> ( _StringMode ) +00603 { +00604 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00605 { +00606 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint64, 20, atoiInt64 ); <font class="comment">// -9223372036854775808</font> +00607 } +00608 <font class="keywordflow">else</font> +00609 { +00610 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%"</font>NL_I64<font class="stringliteral">"d"</font>, 20 ); +00611 } +00612 } +00613 <font class="keywordflow">else</font> +00614 { +00615 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00616 } +00617 } +00618 +00619 <font class="comment">// ======================================================================================================</font> +<a name="l00620"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_8">00620</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(<font class="keywordtype">float</font> &b) +00621 { +00622 <font class="keywordflow">if</font> ( _StringMode ) +00623 { +00624 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00625 { +00626 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, <font class="keywordtype">float</font>, 128, atof ); <font class="comment">// ?</font> +00627 } +00628 <font class="keywordflow">else</font> +00629 { +00630 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (<font class="keywordtype">double</font>)b, <font class="stringliteral">"%f"</font>, 128 ); +00631 } +00632 } +00633 <font class="keywordflow">else</font> +00634 { +00635 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00636 } +00637 } +00638 +00639 <font class="comment">// ======================================================================================================</font> +<a name="l00640"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_9">00640</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(<font class="keywordtype">double</font> &b) +00641 { +00642 <font class="keywordflow">if</font> ( _StringMode ) +00643 { +00644 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00645 { +00646 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, <font class="keywordtype">double</font>, 128, atof ); <font class="comment">//</font> +00647 } +00648 <font class="keywordflow">else</font> +00649 { +00650 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%f"</font>, 128 ); +00651 } +00652 } +00653 <font class="keywordflow">else</font> +00654 { +00655 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00656 } +00657 } +00658 +00659 <font class="comment">// ======================================================================================================</font> +<a name="l00660"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_10">00660</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(<font class="keywordtype">bool</font> &b) +00661 { +00662 <font class="keywordflow">if</font> ( _StringMode ) +00663 { +00664 <a class="code" href="classNLMISC_1_1CMemStream.html#a6">serialBit</a>(b); +00665 } +00666 <font class="keywordflow">else</font> +00667 { +00668 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00669 } +00670 } +00671 +00672 +00673 <font class="preprocessor">#ifndef NL_OS_CYGWIN</font> +00674 <font class="preprocessor"></font><font class="comment">// ======================================================================================================</font> +<a name="l00675"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_11">00675</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(<font class="keywordtype">char</font> &b) +00676 { +00677 <font class="keywordflow">if</font> ( _StringMode ) +00678 { +00679 <font class="keywordtype">char</font> buff [2]; +00680 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00681 { +00682 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)buff, 2 ); +00683 b = buff[0]; +00684 } +00685 <font class="keywordflow">else</font> +00686 { +00687 buff[0] = b; +00688 buff[1] = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00689 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)buff, 2 ); +00690 } +00691 } +00692 <font class="keywordflow">else</font> +00693 { +00694 <a class="code" href="classNLMISC_1_1CMemStream.html#a19">fastSerial</a> (b); +00695 } +00696 } +00697 <font class="preprocessor">#endif</font> +00698 <font class="preprocessor"></font> +00699 <font class="comment">// ======================================================================================================</font> +<a name="l00700"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_12">00700</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(std::string &b) +00701 { +00702 <font class="keywordflow">if</font> ( _StringMode ) +00703 { +00704 sint32 len=0; +00705 <font class="comment">// Read/Write the length.</font> +00706 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00707 { +00708 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(len); +00709 <a class="code" href="debug_8h.html#a6">nlassert</a>( len<1000000 ); <font class="comment">// limiting string size</font> +00710 b.resize(len); +00711 } +00712 <font class="keywordflow">else</font> +00713 { +00714 len= b.size(); +00715 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(len); +00716 } +00717 +00718 <font class="comment">// Read/Write the string.</font> +00719 <font class="keywordflow">for</font>(sint i=0;i<len;i++) +00720 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&(b[i]), <font class="keyword">sizeof</font>(b[i]) ); +00721 +00722 <font class="keywordtype">char</font> sep = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00723 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&sep, 1 ); +00724 } +00725 <font class="keywordflow">else</font> +00726 { +00727 IStream::serial( b ); +00728 } +00729 } +00730 +00731 +00732 <font class="comment">// ======================================================================================================</font> +<a name="l00733"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z296_13">00733</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serial(<a class="code" href="classucstring.html">ucstring</a> &b) +00734 { +00735 <font class="keywordflow">if</font> ( _StringMode ) +00736 { +00737 sint32 len=0; +00738 <font class="comment">// Read/Write the length.</font> +00739 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00740 { +00741 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(len); +00742 b.resize(len); +00743 } +00744 <font class="keywordflow">else</font> +00745 { +00746 len= b.size(); +00747 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>(len); +00748 } +00749 <font class="comment">// Read/Write the string.</font> +00750 <font class="keywordflow">for</font>(sint i=0;i<len;i++) +00751 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&b[i], <font class="keyword">sizeof</font>( <font class="keyword">sizeof</font>(b[i]) ) ); +00752 +00753 <font class="keywordtype">char</font> sep = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00754 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&sep, 1 ); +00755 } +00756 <font class="keywordflow">else</font> +00757 { +00758 IStream::serial( b ); +00759 } +00760 } +00761 +00762 +00763 <font class="comment">// Specialisation of serialCont() for vector<bool></font> +00764 <font class="comment">/*inline void CMemStream::serialCont(std::vector<bool> &cont)</font> +00765 <font class="comment">{</font> +00766 <font class="comment"> sint32 len=0;</font> +00767 <font class="comment"> if(isReading())</font> +00768 <font class="comment"> {</font> +00769 <font class="comment"> serial(len);</font> +00770 <font class="comment"> // special version for vector: adjut good size.</font> +00771 <font class="comment"> contReset(cont);</font> +00772 <font class="comment"> cont.reserve(len);</font> +00773 <font class="comment"></font> +00774 <font class="comment"> for(sint i=0;i<len;i++)</font> +00775 <font class="comment"> {</font> +00776 <font class="comment"> bool v;</font> +00777 <font class="comment"> serial(v);</font> +00778 <font class="comment"> cont.insert(cont.end(), v);</font> +00779 <font class="comment"> }</font> +00780 <font class="comment"> }</font> +00781 <font class="comment"> else</font> +00782 <font class="comment"> {</font> +00783 <font class="comment"> len= cont.size();</font> +00784 <font class="comment"> serial(len);</font> +00785 <font class="comment"></font> +00786 <font class="comment"> std::vector<bool>::iterator it= cont.begin();</font> +00787 <font class="comment"> for(sint i=0;i<len;i++, it++)</font> +00788 <font class="comment"> {</font> +00789 <font class="comment"> bool b = *it;</font> +00790 <font class="comment"> serial( b );</font> +00791 <font class="comment"> }</font> +00792 <font class="comment"> }</font> +00793 <font class="comment">}*/</font> +00794 +00795 +00796 <font class="comment">/*</font> +00797 <font class="comment"> * Serialisation in hexadecimal</font> +00798 <font class="comment"> */</font> +<a name="l00799"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z297_2">00799</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CMemStream::serialHex(uint32 &b) +00800 { +00801 <font class="keywordflow">if</font> ( _StringMode ) +00802 { +00803 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00804 { +00805 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint32, 10, <a class="code" href="namespaceNLMISC.html#a271">atoihex</a> ); <font class="comment">// 4294967295</font> +00806 } +00807 <font class="keywordflow">else</font> +00808 { +00809 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%x"</font>, 10 ); +00810 } +00811 } +00812 <font class="keywordflow">else</font> +00813 { +00814 IStream::serial( b ); +00815 } +00816 } +00817 +00818 +00819 +00820 +00821 +00822 +00823 +00824 +00825 } +00826 +00827 <font class="preprocessor">#endif // NL_MEM_STREAM_H</font> +00828 <font class="preprocessor"></font> +00829 <font class="comment">/* End of mem_stream.h */</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |