aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/mem__stream_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/mem__stream_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/mem__stream_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/mem__stream_8cpp-source.html826
1 files changed, 826 insertions, 0 deletions
diff --git a/docs/doxygen/nel/mem__stream_8cpp-source.html b/docs/doxygen/nel/mem__stream_8cpp-source.html
new file mode 100644
index 00000000..4ca370a8
--- /dev/null
+++ b/docs/doxygen/nel/mem__stream_8cpp-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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><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="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>
+&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="http://www.nevrax.org/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:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>mem_stream.cpp</h1><a href="mem__stream_8cpp.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">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="mem__stream_8h.html">nel/misc/mem_stream.h</a>"</font>
+00029
+00030 <font class="keyword">namespace </font>NLMISC
+00031 {
+00032
+00033
+00034 <font class="comment">/*</font>
+00035 <font class="comment"> * Initialization constructor</font>
+00036 <font class="comment"> */</font>
+00037 <font class="comment">/*CMemStream::CMemStream( bool inputStream, bool stringmode, uint32 defaultcapacity ) :</font>
+00038 <font class="comment"> NLMISC::IStream( inputStream ), _StringMode( stringmode )</font>
+00039 <font class="comment">{</font>
+00040 <font class="comment"> _Buffer.resize (std::max( defaultcapacity, (uint32)4 )); // prevent from no allocation</font>
+00041 <font class="comment"> _BufPos = _Buffer.getPtr();</font>
+00042 <font class="comment">// _Buffer.reserve( std::max( defaultcapacity, (uint32)4 ) ); // prevent from no allocation</font>
+00043 <font class="comment">// _BufPos = _Buffer.begin();</font>
+00044 <font class="comment">}</font>
+00045 <font class="comment">*/</font>
+00046
+00047 <font class="comment">/*</font>
+00048 <font class="comment"> * Copy constructor</font>
+00049 <font class="comment"> */</font>
+00050 <font class="comment">/*CMemStream::CMemStream( const CMemStream&amp; other ) :</font>
+00051 <font class="comment"> IStream (other)</font>
+00052 <font class="comment">{</font>
+00053 <font class="comment"> operator=( other );</font>
+00054 <font class="comment">}</font>
+00055 <font class="comment">*/</font>
+00056
+00057 <font class="comment">/*</font>
+00058 <font class="comment"> * Assignment operator</font>
+00059 <font class="comment"> */</font>
+00060 <font class="comment">/*CMemStream&amp; CMemStream::operator=( const CMemStream&amp; other )</font>
+00061 <font class="comment">{</font>
+00062 <font class="comment"> IStream::operator= (other);</font>
+00063 <font class="comment"> _Buffer = other._Buffer;</font>
+00064 <font class="comment"> _BufPos = _Buffer.getPtr() + other.lengthS();</font>
+00065 <font class="comment"> _StringMode = other._StringMode;</font>
+00066 <font class="comment"> return *this;</font>
+00067 <font class="comment">}</font>
+00068 <font class="comment">*/</font>
+00069
+00070 <font class="comment">/*</font>
+00071 <font class="comment"> * serial (inherited from IStream)</font>
+00072 <font class="comment"> */</font>
+<a name="l00073"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a5">00073</a> <font class="keywordtype">void</font> CMemStream::serialBuffer(uint8 *buf, uint len)
+00074 {
+00075 <font class="comment">// commented for optimum performance</font>
+00076 <a class="code" href="debug_8h.html#a6">nlassert</a> (len &gt; 0);
+00077 <a class="code" href="debug_8h.html#a6">nlassert</a> (buf != NULL);
+00078
+00079 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() )
+00080 {
+00081 <font class="comment">// Check that we don't read more than there is to read</font>
+00082 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()+len &gt; <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>() )
+00083 {
+00084 <font class="keywordflow">throw</font> EStreamOverflow();
+00085 }
+00086 <font class="comment">// Serialize in</font>
+00087 CFastMem::memcpy( buf, <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>, len );
+00088 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += len;
+00089 }
+00090 <font class="keywordflow">else</font>
+00091 {
+00092 <font class="comment">// Serialize out</font>
+00093
+00094 <a class="code" href="classNLMISC_1_1CMemStream.html#a18">increaseBufferIfNecessary</a> (len);
+00095 <font class="comment">/* uint32 oldBufferSize = _Buffer.size();</font>
+00096 <font class="comment"> if (_BufPos - _Buffer.getPtr() + len &gt; oldBufferSize)</font>
+00097 <font class="comment"> {</font>
+00098 <font class="comment"> // need to increase the buffer size</font>
+00099 <font class="comment"> uint32 pos = _BufPos - _Buffer.getPtr();</font>
+00100 <font class="comment"> _Buffer.resize(oldBufferSize*2 + len);</font>
+00101 <font class="comment"> _BufPos = _Buffer.getPtr() + pos;</font>
+00102 <font class="comment"> }</font>
+00103 <font class="comment">*/</font>
+00104 CFastMem::memcpy( <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>, buf, len );
+00105 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += len;
+00106
+00107 <font class="comment">/* _Buffer.resize( size );</font>
+00108 <font class="comment"> _BufPos = _Buffer.end() - len;</font>
+00109 <font class="comment"> CFastMem::memcpy( &amp;(*_BufPos), buf, len );</font>
+00110 <font class="comment"> _BufPos = _Buffer.end();*/</font>
+00111 }
+00112 }
+00113
+00114 <font class="comment">/*</font>
+00115 <font class="comment"> * serialBit (inherited from IStream)</font>
+00116 <font class="comment"> */</font>
+<a name="l00117"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a6">00117</a> <font class="keywordtype">void</font> CMemStream::serialBit(<font class="keywordtype">bool</font> &amp;bit)
+00118 {
+00119 <font class="comment">/* if ( _StringMode )</font>
+00120 <font class="comment"> {</font>
+00121 <font class="comment">*/</font> uint8 u;
+00122 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() )
+00123 {
+00124 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>( u );
+00125 bit = (u!=0);
+00126 }
+00127 <font class="keywordflow">else</font>
+00128 {
+00129 u = (uint8)bit;
+00130 <a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a>( u );
+00131 }
+00132 <font class="comment">/* }</font>
+00133 <font class="comment"> else</font>
+00134 <font class="comment"> {</font>
+00135 <font class="comment"> uint len = sizeof(uint8);</font>
+00136 <font class="comment"> uint8 thebuf;</font>
+00137 <font class="comment"></font>
+00138 <font class="comment"> if ( isReading() )</font>
+00139 <font class="comment"> {</font>
+00140 <font class="comment"> // Check that we don't read more than there is to read</font>
+00141 <font class="comment"> if ( lengthS()+len &gt; lengthR() )</font>
+00142 <font class="comment"> {</font>
+00143 <font class="comment"> throw EStreamOverflow();</font>
+00144 <font class="comment"> }</font>
+00145 <font class="comment"> // Serialize in</font>
+00146 <font class="comment"> memcpy( &amp;thebuf, &amp;(*_BufPos), len );</font>
+00147 <font class="comment"> _BufPos += len;</font>
+00148 <font class="comment"> bit = (thebuf!=0);</font>
+00149 <font class="comment"> }</font>
+00150 <font class="comment"> else</font>
+00151 <font class="comment"> {</font>
+00152 <font class="comment"> thebuf = (uint8)bit;</font>
+00153 <font class="comment"> // Serialize out</font>
+00154 <font class="comment"> _Buffer.resize( _Buffer.size() + len );</font>
+00155 <font class="comment"> _BufPos = _Buffer.end() - len;</font>
+00156 <font class="comment"> memcpy( &amp;(*_BufPos), &amp;thebuf, len );</font>
+00157 <font class="comment"> _BufPos = _Buffer.end();</font>
+00158 <font class="comment"> }</font>
+00159 <font class="comment"> }*/</font>
+00160 }
+00161
+00162
+00163 <font class="comment">/*</font>
+00164 <font class="comment"> * seek (inherited from IStream)</font>
+00165 <font class="comment"> */</font>
+<a name="l00166"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a7">00166</a> <font class="keywordtype">bool</font> CMemStream::seek (sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>, TSeekOrigin origin) <font class="keywordflow">throw</font>(EStream)
+00167 {
+00168 <font class="keywordflow">switch</font> (origin)
+00169 {
+00170 <font class="keywordflow">case</font> begin:
+00171 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &gt;= (sint)length())
+00172 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00173 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &lt; 0)
+00174 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00175 _BufPos=_Buffer.getPtr()+<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>;
+00176 <font class="keywordflow">break</font>;
+00177 <font class="keywordflow">case</font> current:
+00178 <font class="keywordflow">if</font> (getPos ()+<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &gt;= (sint)length())
+00179 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00180 <font class="keywordflow">if</font> (getPos ()+<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &lt; 0)
+00181 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00182 _BufPos+=<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>;
+00183 <font class="keywordflow">break</font>;
+00184 <font class="keywordflow">case</font> end:
+00185 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &lt; -(sint)length())
+00186 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00187 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> &gt; 0)
+00188 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00189 _BufPos=_Buffer.getPtr()+_Buffer.size()+<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>;
+00190 <font class="keywordflow">break</font>;
+00191 }
+00192 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00193 }
+00194
+00195
+00196 <font class="comment">/*</font>
+00197 <font class="comment"> * getPos (inherited from IStream)</font>
+00198 <font class="comment"> */</font>
+00199 <font class="comment">/*sint32 CMemStream::getPos () throw(EStream)</font>
+00200 <font class="comment">{</font>
+00201 <font class="comment"> return _BufPos - _Buffer.getPtr();</font>
+00202 <font class="comment">// if (_Buffer.getPtr() == NULL)</font>
+00203 <font class="comment">// return 0;</font>
+00204 <font class="comment">// else</font>
+00205 <font class="comment">// return (sint32)&amp;(_BufPos[0])-(sint32)&amp;(_Buffer[0]);</font>
+00206 <font class="comment"></font>
+00207 <font class="comment">}</font>
+00208 <font class="comment">*/</font>
+00209
+00210 <font class="comment">/*</font>
+00211 <font class="comment"> * Clears the message</font>
+00212 <font class="comment"> */</font>
+00213 <font class="comment">/*void CMemStream::clear()</font>
+00214 <font class="comment">{</font>
+00215 <font class="comment"> resetPtrTable();</font>
+00216 <font class="comment"> _Buffer.clear();</font>
+00217 <font class="comment"> _BufPos = _Buffer.getPtr();</font>
+00218 <font class="comment">}</font>
+00219 <font class="comment">*/</font>
+00220
+<a name="l00221"></a><a class="code" href="classNLMISC_1_1CMemStream.html#a14">00221</a> <font class="keywordtype">void</font> CMemStream::resize (uint32 size)
+00222 {
+00223 <font class="keywordflow">if</font> (size == <a class="code" href="classNLMISC_1_1CMemStream.html#a10">length</a>()) <font class="keywordflow">return</font>;
+00224 <font class="comment">// need to increase the buffer size</font>
+00225 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();
+00226 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize(size);
+00227 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + pos;
+00228 }
+00229
+00230 <font class="comment">/*</font>
+00231 <font class="comment"> * Fills the message buffer</font>
+00232 <font class="comment"> */</font>
+00233 <font class="comment">/*void CMemStream::fill( const uint8 *srcbuf, uint32 len )</font>
+00234 <font class="comment">{</font>
+00235 <font class="comment"> if (len == 0) return;</font>
+00236 <font class="comment"></font>
+00237 <font class="comment"> _Buffer.resize( len );</font>
+00238 <font class="comment"> _BufPos = _Buffer.getPtr();</font>
+00239 <font class="comment"> CFastMem::memcpy( _BufPos, srcbuf, len );</font>
+00240 <font class="comment">}</font>
+00241 <font class="comment">*/</font>
+00242
+00243 <font class="comment">/* EXPERIMENTAL: Returns a pointer to the message buffer for filling by an external function (use at your own risk,</font>
+00244 <font class="comment"> * you MUST fill the number of bytes you specify in "msgsize").</font>
+00245 <font class="comment"> * This method prevents from doing one useless buffer copy, using fill().</font>
+00246 <font class="comment"> */</font>
+00247 <font class="comment">/*uint8 *CMemStream::bufferToFill( uint32 msgsize )</font>
+00248 <font class="comment">{</font>
+00249 <font class="comment"> if (msgsize == 0) return NULL;</font>
+00250 <font class="comment"></font>
+00251 <font class="comment"> // Same as fill() but the memcpy is done by an external function</font>
+00252 <font class="comment"> _Buffer.resize( msgsize );</font>
+00253 <font class="comment"> _BufPos = _Buffer.getPtr();</font>
+00254 <font class="comment"> return _BufPos;</font>
+00255 <font class="comment">}</font>
+00256 <font class="comment">*/</font>
+00257
+00258 <font class="comment">/*</font>
+00259 <font class="comment"> * Transforms the message from input to output or from output to input</font>
+00260 <font class="comment"> */</font>
+00261 <font class="comment">/*void CMemStream::invert()</font>
+00262 <font class="comment">{</font>
+00263 <font class="comment"> if ( isReading() )</font>
+00264 <font class="comment"> {</font>
+00265 <font class="comment"> // In-&gt;Out: We want to write (serialize out) what we have read (serialized in)</font>
+00266 <font class="comment"> resetPtrTable();</font>
+00267 <font class="comment"> setInOut( false );</font>
+00268 <font class="comment">// _BufPos = _Buffer.end();</font>
+00269 <font class="comment"> }</font>
+00270 <font class="comment"> else</font>
+00271 <font class="comment"> {</font>
+00272 <font class="comment"> // Out-&gt;In: We want to read (serialize in) what we have written (serialized out)</font>
+00273 <font class="comment"> resetPtrTable();</font>
+00274 <font class="comment"> setInOut( true );</font>
+00275 <font class="comment"> _BufPos = _Buffer.getPtr();</font>
+00276 <font class="comment"> }</font>
+00277 <font class="comment">}</font>
+00278 <font class="comment">*/</font>
+00279
+00280
+00281
+00282 <font class="comment">/*** String-specific methods ***/</font>
+00283
+00284
+00285 <font class="comment">//const char SEPARATOR = ' ';</font>
+00286 <font class="comment">//const int SEP_SIZE = 1; // the code is easier to read with that</font>
+00287
+00288
+00289
+00290 <font class="comment">/*</font>
+00291 <font class="comment"> * Input: read from the stream until the next separator, and return the number of bytes read. The separator is then skipped.</font>
+00292 <font class="comment"> */</font>
+<a name="l00293"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z297_0">00293</a> uint CMemStream::serialSeparatedBufferIn( uint8 *buf, uint len )
+00294 {
+00295 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a> &amp;&amp; <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() );
+00296
+00297 <font class="comment">// Check that we don't read more than there is to read</font>
+00298 <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()+<a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size() ) || <font class="comment">// we are at the end</font>
+00299 ( <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()+len+<a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a> &gt; <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>() ) &amp;&amp; (<a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>[<a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size()-1] != <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> ) ) <font class="comment">// we are before the end</font>
+00300 {
+00301 <font class="keywordflow">throw</font> EStreamOverflow();
+00302 }
+00303 <font class="comment">// Serialize in</font>
+00304 uint32 i = 0;
+00305 <font class="keywordflow">while</font> ( (i&lt;len) &amp;&amp; (*_BufPos) != <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> )
+00306 {
+00307 *(buf+i) = *<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>;
+00308 i++;
+00309 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>++;
+00310 }
+00311 <font class="comment">// Exceeds len</font>
+00312 <font class="keywordflow">if</font> ( (*_BufPos) != <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> )
+00313 {
+00314 <font class="keywordflow">throw</font> EStreamOverflow();
+00315 }
+00316 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a>;
+00317 <font class="keywordflow">return</font> i;
+00318 }
+00319
+00320
+00321 <font class="comment">/*</font>
+00322 <font class="comment"> * Output: writes len bytes from buf into the stream</font>
+00323 <font class="comment"> */</font>
+<a name="l00324"></a><a class="code" href="classNLMISC_1_1CMemStream.html#z297_1">00324</a> <font class="keywordtype">void</font> CMemStream::serialSeparatedBufferOut( uint8 *buf, uint len )
+00325 {
+00326 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNLMISC_1_1CMemStream.html#n2">_StringMode</a> &amp;&amp; (!<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) );
+00327
+00328 <font class="comment">// Serialize out</font>
+00329 uint32 oldBufferSize = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size();
+00330 <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 + <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a>) &gt; oldBufferSize)
+00331 {
+00332 <font class="comment">// need to increase the buffer size</font>
+00333 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize(oldBufferSize*2 + len + <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a>);
+00334 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.getPtr() + oldBufferSize;
+00335 }
+00336
+00337 CFastMem::memcpy( <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>, buf, len );
+00338 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += len;
+00339 *(<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>++) = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>;
+00340
+00341 <font class="comment">// Serialize out</font>
+00342 <font class="comment">/* _Buffer.resize( _Buffer.size() + len + SEP_SIZE );</font>
+00343 <font class="comment"> _BufPos = _Buffer.end() - len - SEP_SIZE;</font>
+00344 <font class="comment"> CFastMem::memcpy( &amp;(*_BufPos), buf, len );</font>
+00345 <font class="comment"> _Buffer[_Buffer.size()-1] = SEPARATOR;</font>
+00346 <font class="comment"> _BufPos = _Buffer.end();</font>
+00347 <font class="comment">*/</font>}
+00348
+00349 <font class="comment">/*</font>
+00350 <font class="comment">// Input</font>
+00351 <font class="comment">#define readnumber(dest,thetype,digits,convfunc) \</font>
+00352 <font class="comment"> char number_as_cstring [digits+1]; \</font>
+00353 <font class="comment"> uint realdigits = serialSeparatedBufferIn( (uint8*)&amp;number_as_cstring, digits ); \</font>
+00354 <font class="comment"> number_as_cstring[realdigits] = '\0'; \</font>
+00355 <font class="comment"> dest = (thetype)convfunc( number_as_cstring );</font>
+00356 <font class="comment"></font>
+00357 <font class="comment">// Output</font>
+00358 <font class="comment">#define writenumber(src,format,digits) \</font>
+00359 <font class="comment"> char number_as_cstring [digits+1]; \</font>
+00360 <font class="comment"> sprintf( number_as_cstring, format, src ); \</font>
+00361 <font class="comment"> serialSeparatedBufferOut( (uint8*)&amp;number_as_cstring, strlen(number_as_cstring) );</font>
+00362 <font class="comment">*/</font>
+00363
+00364 <font class="comment">/*</font>
+00365 <font class="comment"> * atoihex</font>
+00366 <font class="comment"> */</font>
+00367 <font class="comment">/*inline int atoihex( const char* ident )</font>
+00368 <font class="comment">{</font>
+00369 <font class="comment"> int number;</font>
+00370 <font class="comment"> sscanf( ident, "%x", &amp;number );</font>
+00371 <font class="comment"> return number;</font>
+00372 <font class="comment">}</font>
+00373 <font class="comment"></font>
+00374 <font class="comment">inline uint32 atoui( const char *ident)</font>
+00375 <font class="comment">{</font>
+00376 <font class="comment"> return (uint32) strtoul (ident, NULL, 10);</font>
+00377 <font class="comment">}</font>
+00378 <font class="comment">*/</font>
+00379 <font class="comment">/***************************************************************/</font>
+00380 <font class="comment">/******************* THE FOLLOWING CODE IS COMMENTED OUT *******/</font>
+00381 <font class="comment">/***************************************************************</font>
+00382 <font class="comment"></font>
+00383 <font class="comment">// ======================================================================================================</font>
+00384 <font class="comment">void CMemStream::serial(uint8 &amp;b) </font>
+00385 <font class="comment">{</font>
+00386 <font class="comment"> if ( _StringMode )</font>
+00387 <font class="comment"> {</font>
+00388 <font class="comment"> if ( isReading() )</font>
+00389 <font class="comment"> {</font>
+00390 <font class="comment"> readnumber( b, uint8, 3, atoi ); // 255</font>
+00391 <font class="comment"> }</font>
+00392 <font class="comment"> else</font>
+00393 <font class="comment"> {</font>
+00394 <font class="comment"> writenumber( (uint16)b,"%hu", 3 );</font>
+00395 <font class="comment"> }</font>
+00396 <font class="comment"> }</font>
+00397 <font class="comment"> else</font>
+00398 <font class="comment"> {</font>
+00399 <font class="comment"> fastSerial (b);</font>
+00400 <font class="comment"> }</font>
+00401 <font class="comment">}</font>
+00402 <font class="comment"></font>
+00403 <font class="comment">// ======================================================================================================</font>
+00404 <font class="comment">void CMemStream::serial(sint8 &amp;b) </font>
+00405 <font class="comment">{</font>
+00406 <font class="comment"> if ( _StringMode )</font>
+00407 <font class="comment"> {</font>
+00408 <font class="comment"> if ( isReading() )</font>
+00409 <font class="comment"> {</font>
+00410 <font class="comment"> readnumber( b, sint8, 4, atoi ); // -128</font>
+00411 <font class="comment"> }</font>
+00412 <font class="comment"> else</font>
+00413 <font class="comment"> {</font>
+00414 <font class="comment"> writenumber( (sint16)b, "%hd", 4 );</font>
+00415 <font class="comment"> }</font>
+00416 <font class="comment"> }</font>
+00417 <font class="comment"> else</font>
+00418 <font class="comment"> {</font>
+00419 <font class="comment"> fastSerial (b);</font>
+00420 <font class="comment"> }</font>
+00421 <font class="comment">}</font>
+00422 <font class="comment"></font>
+00423 <font class="comment">// ======================================================================================================</font>
+00424 <font class="comment">void CMemStream::serial(uint16 &amp;b) </font>
+00425 <font class="comment">{</font>
+00426 <font class="comment"> if ( _StringMode )</font>
+00427 <font class="comment"> {</font>
+00428 <font class="comment"> // No byte swapping in text mode</font>
+00429 <font class="comment"> if ( isReading() )</font>
+00430 <font class="comment"> {</font>
+00431 <font class="comment"> readnumber( b, uint16, 5, atoi ); // 65535</font>
+00432 <font class="comment"> }</font>
+00433 <font class="comment"> else</font>
+00434 <font class="comment"> {</font>
+00435 <font class="comment"> writenumber( b, "%hu", 5 );</font>
+00436 <font class="comment"> }</font>
+00437 <font class="comment"> }</font>
+00438 <font class="comment"> else</font>
+00439 <font class="comment"> {</font>
+00440 <font class="comment"> fastSerial (b);</font>
+00441 <font class="comment"> }</font>
+00442 <font class="comment">}</font>
+00443 <font class="comment"></font>
+00444 <font class="comment">// ======================================================================================================</font>
+00445 <font class="comment">void CMemStream::serial(sint16 &amp;b) </font>
+00446 <font class="comment">{</font>
+00447 <font class="comment"> if ( _StringMode )</font>
+00448 <font class="comment"> {</font>
+00449 <font class="comment"> if ( isReading() )</font>
+00450 <font class="comment"> {</font>
+00451 <font class="comment"> readnumber( b, sint16, 6, atoi ); // -32768</font>
+00452 <font class="comment"> }</font>
+00453 <font class="comment"> else</font>
+00454 <font class="comment"> {</font>
+00455 <font class="comment"> writenumber( b, "%hd", 6 );</font>
+00456 <font class="comment"> }</font>
+00457 <font class="comment"> }</font>
+00458 <font class="comment"> else</font>
+00459 <font class="comment"> {</font>
+00460 <font class="comment"> fastSerial (b);</font>
+00461 <font class="comment"> }</font>
+00462 <font class="comment">}</font>
+00463 <font class="comment"></font>
+00464 <font class="comment">// ======================================================================================================</font>
+00465 <font class="comment">void CMemStream::serial(uint32 &amp;b) </font>
+00466 <font class="comment">{</font>
+00467 <font class="comment"> if ( _StringMode )</font>
+00468 <font class="comment"> {</font>
+00469 <font class="comment"> if ( isReading() )</font>
+00470 <font class="comment"> {</font>
+00471 <font class="comment"> readnumber( b, uint32, 10, atoui ); // 4294967295</font>
+00472 <font class="comment"> }</font>
+00473 <font class="comment"> else</font>
+00474 <font class="comment"> {</font>
+00475 <font class="comment"> writenumber( b, "%u", 10 );</font>
+00476 <font class="comment"> }</font>
+00477 <font class="comment"> }</font>
+00478 <font class="comment"> else</font>
+00479 <font class="comment"> {</font>
+00480 <font class="comment"> fastSerial (b);</font>
+00481 <font class="comment"> }</font>
+00482 <font class="comment">}</font>
+00483 <font class="comment"></font>
+00484 <font class="comment"></font>
+00485 <font class="comment">// ======================================================================================================</font>
+00486 <font class="comment">void CMemStream::serial(sint32 &amp;b) </font>
+00487 <font class="comment">{</font>
+00488 <font class="comment"> if ( _StringMode )</font>
+00489 <font class="comment"> {</font>
+00490 <font class="comment"> if ( isReading() )</font>
+00491 <font class="comment"> {</font>
+00492 <font class="comment"> readnumber( b, sint32, 11, atoi ); // -2147483648</font>
+00493 <font class="comment"> }</font>
+00494 <font class="comment"> else</font>
+00495 <font class="comment"> {</font>
+00496 <font class="comment"> writenumber( b, "%d", 11 );</font>
+00497 <font class="comment"> }</font>
+00498 <font class="comment"> }</font>
+00499 <font class="comment"> else</font>
+00500 <font class="comment"> {</font>
+00501 <font class="comment"> fastSerial (b);</font>
+00502 <font class="comment"> }</font>
+00503 <font class="comment">}</font>
+00504 <font class="comment"></font>
+00505 <font class="comment">// ======================================================================================================</font>
+00506 <font class="comment">void CMemStream::serial(uint64 &amp;b) </font>
+00507 <font class="comment">{</font>
+00508 <font class="comment"> if ( _StringMode )</font>
+00509 <font class="comment"> {</font>
+00510 <font class="comment"> if ( isReading() )</font>
+00511 <font class="comment"> {</font>
+00512 <font class="comment"> readnumber( b, uint64, 20, atoiInt64 ); // 18446744073709551615</font>
+00513 <font class="comment"> }</font>
+00514 <font class="comment"> else</font>
+00515 <font class="comment"> {</font>
+00516 <font class="comment"> writenumber( b, "%"NL_I64"u", 20 );</font>
+00517 <font class="comment"> }</font>
+00518 <font class="comment"> }</font>
+00519 <font class="comment"> else</font>
+00520 <font class="comment"> {</font>
+00521 <font class="comment"> fastSerial (b);</font>
+00522 <font class="comment"> }</font>
+00523 <font class="comment">}</font>
+00524 <font class="comment"></font>
+00525 <font class="comment">// ======================================================================================================</font>
+00526 <font class="comment">void CMemStream::serial(sint64 &amp;b) </font>
+00527 <font class="comment">{</font>
+00528 <font class="comment"> if ( _StringMode )</font>
+00529 <font class="comment"> {</font>
+00530 <font class="comment"> if ( isReading() )</font>
+00531 <font class="comment"> {</font>
+00532 <font class="comment"> readnumber( b, sint64, 20, atoiInt64 ); // -9223372036854775808</font>
+00533 <font class="comment"> }</font>
+00534 <font class="comment"> else</font>
+00535 <font class="comment"> {</font>
+00536 <font class="comment"> writenumber( b, "%"NL_I64"d", 20 );</font>
+00537 <font class="comment"> }</font>
+00538 <font class="comment"> }</font>
+00539 <font class="comment"> else</font>
+00540 <font class="comment"> {</font>
+00541 <font class="comment"> fastSerial (b);</font>
+00542 <font class="comment"> }</font>
+00543 <font class="comment">}</font>
+00544 <font class="comment"></font>
+00545 <font class="comment">// ======================================================================================================</font>
+00546 <font class="comment">void CMemStream::serial(float &amp;b) </font>
+00547 <font class="comment">{</font>
+00548 <font class="comment"> if ( _StringMode )</font>
+00549 <font class="comment"> {</font>
+00550 <font class="comment"> if ( isReading() )</font>
+00551 <font class="comment"> {</font>
+00552 <font class="comment"> readnumber( b, float, 128, atof ); // ?</font>
+00553 <font class="comment"> }</font>
+00554 <font class="comment"> else</font>
+00555 <font class="comment"> {</font>
+00556 <font class="comment"> writenumber( (double)b, "%f", 128 );</font>
+00557 <font class="comment"> }</font>
+00558 <font class="comment"> }</font>
+00559 <font class="comment"> else</font>
+00560 <font class="comment"> {</font>
+00561 <font class="comment"> fastSerial (b);</font>
+00562 <font class="comment"> }</font>
+00563 <font class="comment">}</font>
+00564 <font class="comment"></font>
+00565 <font class="comment">// ======================================================================================================</font>
+00566 <font class="comment">void CMemStream::serial(double &amp;b) </font>
+00567 <font class="comment">{</font>
+00568 <font class="comment"> if ( _StringMode )</font>
+00569 <font class="comment"> {</font>
+00570 <font class="comment"> if ( isReading() )</font>
+00571 <font class="comment"> {</font>
+00572 <font class="comment"> readnumber( b, double, 128, atof ); //</font>
+00573 <font class="comment"> }</font>
+00574 <font class="comment"> else</font>
+00575 <font class="comment"> {</font>
+00576 <font class="comment"> writenumber( b, "%f", 128 );</font>
+00577 <font class="comment"> }</font>
+00578 <font class="comment"> }</font>
+00579 <font class="comment"> else</font>
+00580 <font class="comment"> {</font>
+00581 <font class="comment"> fastSerial (b);</font>
+00582 <font class="comment"> }</font>
+00583 <font class="comment">}</font>
+00584 <font class="comment"></font>
+00585 <font class="comment">// ======================================================================================================</font>
+00586 <font class="comment">void CMemStream::serial(bool &amp;b) </font>
+00587 <font class="comment">{</font>
+00588 <font class="comment"> if ( _StringMode )</font>
+00589 <font class="comment"> {</font>
+00590 <font class="comment"> serialBit(b);</font>
+00591 <font class="comment"> }</font>
+00592 <font class="comment"> else</font>
+00593 <font class="comment"> {</font>
+00594 <font class="comment">#ifdef NL_LITTLE_ENDIAN</font>
+00595 <font class="comment"> if(isReading())</font>
+00596 <font class="comment"> {</font>
+00597 <font class="comment"> IStream::serial( b );</font>
+00598 <font class="comment"> }</font>
+00599 <font class="comment"> else</font>
+00600 <font class="comment"> {</font>
+00601 <font class="comment"> *(uint8*)_BufPos = b;</font>
+00602 <font class="comment"> _BufPos += sizeof(uint8);</font>
+00603 <font class="comment"> }</font>
+00604 <font class="comment">#else // NL_LITTLE_ENDIAN</font>
+00605 <font class="comment"> IStream::serial( b );</font>
+00606 <font class="comment">#endif // NL_LITTLE_ENDIAN</font>
+00607 <font class="comment"> }</font>
+00608 <font class="comment">}</font>
+00609 <font class="comment"></font>
+00610 <font class="comment"></font>
+00611 <font class="comment">#ifndef NL_OS_CYGWIN</font>
+00612 <font class="comment">// ======================================================================================================</font>
+00613 <font class="comment">void CMemStream::serial(char &amp;b) </font>
+00614 <font class="comment">{</font>
+00615 <font class="comment"> if ( _StringMode )</font>
+00616 <font class="comment"> {</font>
+00617 <font class="comment"> char buff [2];</font>
+00618 <font class="comment"> if ( isReading() )</font>
+00619 <font class="comment"> {</font>
+00620 <font class="comment"> serialBuffer( (uint8*)buff, 2 );</font>
+00621 <font class="comment"> b = buff[0];</font>
+00622 <font class="comment"> }</font>
+00623 <font class="comment"> else</font>
+00624 <font class="comment"> {</font>
+00625 <font class="comment"> buff[0] = b;</font>
+00626 <font class="comment"> buff[1] = SEPARATOR;</font>
+00627 <font class="comment"> serialBuffer( (uint8*)buff, 2 );</font>
+00628 <font class="comment"> }</font>
+00629 <font class="comment"> }</font>
+00630 <font class="comment"> else</font>
+00631 <font class="comment"> {</font>
+00632 <font class="comment"> fastSerial (b);</font>
+00633 <font class="comment"> }</font>
+00634 <font class="comment">}</font>
+00635 <font class="comment">#endif</font>
+00636 <font class="comment"></font>
+00637 <font class="comment">// ======================================================================================================</font>
+00638 <font class="comment">void CMemStream::serial(std::string &amp;b) </font>
+00639 <font class="comment">{</font>
+00640 <font class="comment"> if ( _StringMode )</font>
+00641 <font class="comment"> {</font>
+00642 <font class="comment"> sint32 len=0;</font>
+00643 <font class="comment"> // Read/Write the length.</font>
+00644 <font class="comment"> if(isReading())</font>
+00645 <font class="comment"> {</font>
+00646 <font class="comment"> serial(len);</font>
+00647 <font class="comment"> nlassert( len&lt;1000000 ); // limiting string size</font>
+00648 <font class="comment"> b.resize(len);</font>
+00649 <font class="comment"> }</font>
+00650 <font class="comment"> else</font>
+00651 <font class="comment"> {</font>
+00652 <font class="comment"> len= b.size();</font>
+00653 <font class="comment"> serial(len);</font>
+00654 <font class="comment"> }</font>
+00655 <font class="comment"> </font>
+00656 <font class="comment"> // Read/Write the string.</font>
+00657 <font class="comment"> for(sint i=0;i&lt;len;i++)</font>
+00658 <font class="comment"> serialBuffer( (uint8*)&amp;(b[i]), sizeof(b[i]) );</font>
+00659 <font class="comment"></font>
+00660 <font class="comment"> char sep = SEPARATOR;</font>
+00661 <font class="comment"> serialBuffer( (uint8*)&amp;sep, 1 );</font>
+00662 <font class="comment"> }</font>
+00663 <font class="comment"> else</font>
+00664 <font class="comment"> {</font>
+00665 <font class="comment"> IStream::serial( b );</font>
+00666 <font class="comment"> }</font>
+00667 <font class="comment">}</font>
+00668 <font class="comment"></font>
+00669 <font class="comment"></font>
+00670 <font class="comment">// ======================================================================================================</font>
+00671 <font class="comment">void CMemStream::serial(ucstring &amp;b) </font>
+00672 <font class="comment">{</font>
+00673 <font class="comment"> if ( _StringMode )</font>
+00674 <font class="comment"> {</font>
+00675 <font class="comment"> sint32 len=0;</font>
+00676 <font class="comment"> // Read/Write the length.</font>
+00677 <font class="comment"> if(isReading())</font>
+00678 <font class="comment"> {</font>
+00679 <font class="comment"> serial(len);</font>
+00680 <font class="comment"> b.resize(len);</font>
+00681 <font class="comment"> }</font>
+00682 <font class="comment"> else</font>
+00683 <font class="comment"> {</font>
+00684 <font class="comment"> len= b.size();</font>
+00685 <font class="comment"> serial(len);</font>
+00686 <font class="comment"> }</font>
+00687 <font class="comment"> // Read/Write the string.</font>
+00688 <font class="comment"> for(sint i=0;i&lt;len;i++)</font>
+00689 <font class="comment"> serialBuffer( (uint8*)&amp;b[i], sizeof( sizeof(b[i]) ) );</font>
+00690 <font class="comment"></font>
+00691 <font class="comment"> char sep = SEPARATOR;</font>
+00692 <font class="comment"> serialBuffer( (uint8*)&amp;sep, 1 );</font>
+00693 <font class="comment"> }</font>
+00694 <font class="comment"> else</font>
+00695 <font class="comment"> {</font>
+00696 <font class="comment"> IStream::serial( b );</font>
+00697 <font class="comment"> }</font>
+00698 <font class="comment">}</font>
+00699 <font class="comment"></font>
+00700 <font class="comment"></font>
+00701 <font class="comment">// Specialisation of serialCont() for vector&lt;bool&gt;</font>
+00702 <font class="comment">void CMemStream::serialCont(std::vector&lt;bool&gt; &amp;cont)</font>
+00703 <font class="comment">{</font>
+00704 <font class="comment"> sint32 len=0;</font>
+00705 <font class="comment"> if(isReading())</font>
+00706 <font class="comment"> {</font>
+00707 <font class="comment"> serial(len);</font>
+00708 <font class="comment"> // special version for vector: adjut good size.</font>
+00709 <font class="comment"> contReset(cont);</font>
+00710 <font class="comment"> cont.reserve(len);</font>
+00711 <font class="comment"></font>
+00712 <font class="comment"> for(sint i=0;i&lt;len;i++)</font>
+00713 <font class="comment"> {</font>
+00714 <font class="comment"> bool v;</font>
+00715 <font class="comment"> serial(v);</font>
+00716 <font class="comment"> cont.insert(cont.end(), v);</font>
+00717 <font class="comment"> }</font>
+00718 <font class="comment"> }</font>
+00719 <font class="comment"> else</font>
+00720 <font class="comment"> {</font>
+00721 <font class="comment"> len= cont.size();</font>
+00722 <font class="comment"> serial(len);</font>
+00723 <font class="comment"></font>
+00724 <font class="comment"> std::vector&lt;bool&gt;::iterator it= cont.begin();</font>
+00725 <font class="comment"> for(sint i=0;i&lt;len;i++, it++)</font>
+00726 <font class="comment"> {</font>
+00727 <font class="comment"> bool b = *it;</font>
+00728 <font class="comment"> serial( b );</font>
+00729 <font class="comment"> }</font>
+00730 <font class="comment"> }</font>
+00731 <font class="comment">}</font>
+00732 <font class="comment"></font>
+00733 <font class="comment"></font>
+00734 <font class="comment">// Serialisation in hexadecimal</font>
+00735 <font class="comment">void CMemStream::serialHex(uint32 &amp;b)</font>
+00736 <font class="comment">{</font>
+00737 <font class="comment"> if ( _StringMode )</font>
+00738 <font class="comment"> {</font>
+00739 <font class="comment"> if ( isReading() )</font>
+00740 <font class="comment"> {</font>
+00741 <font class="comment"> readnumber( b, uint32, 10, atoihex ); // 4294967295</font>
+00742 <font class="comment"> }</font>
+00743 <font class="comment"> else</font>
+00744 <font class="comment"> {</font>
+00745 <font class="comment"> writenumber( b, "%x", 10 );</font>
+00746 <font class="comment"> }</font>
+00747 <font class="comment"> }</font>
+00748 <font class="comment"> else</font>
+00749 <font class="comment"> {</font>
+00750 <font class="comment"> IStream::serial( b );</font>
+00751 <font class="comment"> }</font>
+00752 <font class="comment">}</font>
+00753 <font class="comment"></font>
+00754 <font class="comment">***************************************************************/</font>
+00755 }
+00756
+00757
+</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=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>