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/string__stream_8cpp-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/string__stream_8cpp-source.html | 456 |
1 files changed, 456 insertions, 0 deletions
diff --git a/docs/doxygen/nel/string__stream_8cpp-source.html b/docs/doxygen/nel/string__stream_8cpp-source.html new file mode 100644 index 00000000..c5a9a229 --- /dev/null +++ b/docs/doxygen/nel/string__stream_8cpp-source.html @@ -0,0 +1,456 @@ +<!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>string_stream.cpp</h1><a href="string__stream_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2001 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="string__stream_8h.html">nel/misc/string_stream.h</a>"</font> +00027 +00028 <font class="preprocessor">#include <vector></font> +00029 +00030 <font class="keyword">namespace </font>NLMISC { +00031 +00032 +00033 <font class="keyword">const</font> <font class="keywordtype">char</font> <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> = <font class="charliteral">' '</font>; +00034 <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> +00035 +00036 +00037 +00038 <font class="comment">/*</font> +00039 <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> +00040 <font class="comment"> */</font> +<a name="l00041"></a><a class="code" href="classNLMISC_1_1CStringStream.html#a3">00041</a> uint CStringStream::serialSeparatedBufferIn( uint8 *buf, uint len ) +00042 { +00043 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ); +00044 +00045 <font class="comment">// Check that we don't read more than there is to read</font> +00046 <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>.end() ) || <font class="comment">// we are at the end</font> +00047 ( <a class="code" href="classNLMISC_1_1CMemStream.html#b0">lengthS</a>()+len+<a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a> > <a class="code" href="classNLMISC_1_1CMemStream.html#b1">lengthR</a>() ) && (<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> +00048 { +00049 <font class="keywordflow">throw</font> EStreamOverflow(); +00050 } +00051 <font class="comment">// Serialize in</font> +00052 uint32 i = 0; +00053 <font class="keywordflow">while</font> ( (i<len) && (*_BufPos) != <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> ) +00054 { +00055 *(buf+i) = *<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>; +00056 i++; +00057 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>++; +00058 } +00059 <font class="comment">// Exceeds len</font> +00060 <font class="keywordflow">if</font> ( (*_BufPos) != <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a> ) +00061 { +00062 <font class="keywordflow">throw</font> EStreamOverflow(); +00063 } +00064 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> += <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a>; +00065 <font class="keywordflow">return</font> i; +00066 } +00067 +00068 <font class="comment">/*</font> +00069 <font class="comment"> * Output: writes len bytes from buf into the stream</font> +00070 <font class="comment"> */</font> +<a name="l00071"></a><a class="code" href="classNLMISC_1_1CStringStream.html#a4">00071</a> <font class="keywordtype">void</font> CStringStream::serialSeparatedBufferOut( uint8 *buf, uint len ) +00072 { +00073 <a class="code" href="debug_8h.html#a6">nlassert</a>( ! <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ); +00074 +00075 <font class="comment">// Serialize out</font> +00076 <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.resize( <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.size() + len + <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a> ); +00077 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.end() - len - <a class="code" href="namespaceNLMISC.html#a170">SEP_SIZE</a>; +00078 memcpy( &(*<a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a>), buf, len ); +00079 <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>; +00080 <a class="code" href="classNLMISC_1_1CMemStream.html#n1">_BufPos</a> = <a class="code" href="classNLMISC_1_1CMemStream.html#n0">_Buffer</a>.end(); +00081 } +00082 +00083 +00084 <font class="comment">// Input</font> +<a name="l00085"></a><a class="code" href="string__stream_8cpp.html#a0">00085</a> <font class="preprocessor">#define readnumber(dest,thetype,digits,convfunc) \</font> +00086 <font class="preprocessor"> char number_as_cstring [digits+1]; \</font> +00087 <font class="preprocessor"> uint realdigits = serialSeparatedBufferIn( (uint8*)&number_as_cstring, digits ); \</font> +00088 <font class="preprocessor"> number_as_cstring[realdigits] = '\0'; \</font> +00089 <font class="preprocessor"> dest = (thetype)convfunc( number_as_cstring );</font> +00090 <font class="preprocessor"></font> +00091 <font class="comment">// Output</font> +<a name="l00092"></a><a class="code" href="string__stream_8cpp.html#a1">00092</a> <font class="preprocessor">#define writenumber(src,format,digits) \</font> +00093 <font class="preprocessor"> char number_as_cstring [digits+1]; \</font> +00094 <font class="preprocessor"> sprintf( number_as_cstring, format, src ); \</font> +00095 <font class="preprocessor"> serialSeparatedBufferOut( (uint8*)&number_as_cstring, strlen(number_as_cstring) );</font> +00096 <font class="preprocessor"></font> +00098 +00099 <font class="comment">/*</font> +00100 <font class="comment"> * atoihex</font> +00101 <font class="comment"> */</font> +00102 <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 ) +00103 { +00104 <font class="keywordtype">int</font> number; +00105 sscanf( ident, <font class="stringliteral">"%x"</font>, &number ); +00106 <font class="keywordflow">return</font> number; +00107 } +00108 +00109 <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) +00110 { +00111 <font class="keywordflow">return</font> (uint32) strtoul (ident, NULL, 10); +00112 } +00113 +00114 <font class="comment">// ======================================================================================================</font> +<a name="l00115"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_0">00115</a> <font class="keywordtype">void</font> CStringStream::serial(uint8 &b) +00116 { +00117 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00118 { +00119 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint8, 3, atoi ); <font class="comment">// 255</font> +00120 } +00121 <font class="keywordflow">else</font> +00122 { +00123 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (uint16)b,<font class="stringliteral">"%hu"</font>, 3 ); +00124 } +00125 } +00126 +00127 <font class="comment">// ======================================================================================================</font> +<a name="l00128"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_1">00128</a> <font class="keywordtype">void</font> CStringStream::serial(sint8 &b) +00129 { +00130 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00131 { +00132 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint8, 4, atoi ); <font class="comment">// -128</font> +00133 } +00134 <font class="keywordflow">else</font> +00135 { +00136 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (sint16)b, <font class="stringliteral">"%hd"</font>, 4 ); +00137 } +00138 } +00139 +00140 <font class="comment">// ======================================================================================================</font> +<a name="l00141"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_2">00141</a> <font class="keywordtype">void</font> CStringStream::serial(uint16 &b) +00142 { +00143 <font class="comment">// No byte swapping in text mode</font> +00144 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00145 { +00146 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint16, 5, atoi ); <font class="comment">// 65535</font> +00147 } +00148 <font class="keywordflow">else</font> +00149 { +00150 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%hu"</font>, 5 ); +00151 } +00152 } +00153 +00154 <font class="comment">// ======================================================================================================</font> +<a name="l00155"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_3">00155</a> <font class="keywordtype">void</font> CStringStream::serial(sint16 &b) +00156 { +00157 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00158 { +00159 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint16, 6, atoi ); <font class="comment">// -32768</font> +00160 } +00161 <font class="keywordflow">else</font> +00162 { +00163 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%hd"</font>, 6 ); +00164 } +00165 } +00166 +00167 <font class="comment">// ======================================================================================================</font> +<a name="l00168"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_4">00168</a> <font class="keywordtype">void</font> CStringStream::serial(uint32 &b) +00169 { +00170 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00171 { +00172 <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> +00173 } +00174 <font class="keywordflow">else</font> +00175 { +00176 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%u"</font>, 10 ); +00177 } +00178 } +00179 +00180 <font class="comment">// ======================================================================================================</font> +<a name="l00181"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_5">00181</a> <font class="keywordtype">void</font> CStringStream::serial(sint32 &b) +00182 { +00183 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00184 { +00185 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint32, 11, atoi ); <font class="comment">// -2147483648</font> +00186 } +00187 <font class="keywordflow">else</font> +00188 { +00189 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%d"</font>, 11 ); +00190 } +00191 } +00192 +00193 <font class="comment">// ======================================================================================================</font> +<a name="l00194"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_6">00194</a> <font class="keywordtype">void</font> CStringStream::serial(uint64 &b) +00195 { +00196 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00197 { +00198 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, uint64, 20, atoiInt64 ); <font class="comment">// 18446744073709551615</font> +00199 } +00200 <font class="keywordflow">else</font> +00201 { +00202 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%"</font>NL_I64<font class="stringliteral">"u"</font>, 20 ); +00203 } +00204 } +00205 +00206 <font class="comment">// ======================================================================================================</font> +<a name="l00207"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_7">00207</a> <font class="keywordtype">void</font> CStringStream::serial(sint64 &b) +00208 { +00209 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00210 { +00211 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, sint64, 20, atoiInt64 ); <font class="comment">// -9223372036854775808</font> +00212 } +00213 <font class="keywordflow">else</font> +00214 { +00215 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%"</font>NL_I64<font class="stringliteral">"d"</font>, 20 ); +00216 } +00217 } +00218 +00219 <font class="comment">// ======================================================================================================</font> +<a name="l00220"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_8">00220</a> <font class="keywordtype">void</font> CStringStream::serial(<font class="keywordtype">float</font> &b) +00221 { +00222 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00223 { +00224 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, <font class="keywordtype">float</font>, 128, atof ); <font class="comment">// ?</font> +00225 } +00226 <font class="keywordflow">else</font> +00227 { +00228 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( (<font class="keywordtype">double</font>)b, <font class="stringliteral">"%f"</font>, 128 ); +00229 } +00230 } +00231 +00232 <font class="comment">// ======================================================================================================</font> +<a name="l00233"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_9">00233</a> <font class="keywordtype">void</font> CStringStream::serial(<font class="keywordtype">double</font> &b) +00234 { +00235 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00236 { +00237 <a class="code" href="mem__stream_8h.html#a0">readnumber</a>( b, <font class="keywordtype">double</font>, 128, atof ); <font class="comment">//</font> +00238 } +00239 <font class="keywordflow">else</font> +00240 { +00241 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%f"</font>, 128 ); +00242 } +00243 } +00244 +00245 <font class="comment">// ======================================================================================================</font> +<a name="l00246"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_10">00246</a> <font class="keywordtype">void</font> CStringStream::serial(<font class="keywordtype">bool</font> &b) +00247 { +00248 <a class="code" href="classNLMISC_1_1CStringStream.html#a5">serialBit</a>(b); +00249 } +00250 +00251 +00252 <font class="comment">// ======================================================================================================</font> +<a name="l00253"></a><a class="code" href="classNLMISC_1_1CStringStream.html#a5">00253</a> <font class="keywordtype">void</font> CStringStream::serialBit(<font class="keywordtype">bool</font> &bit) +00254 { +00255 uint8 u; +00256 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00257 { +00258 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>( u ); +00259 bit = (u!=0); +00260 } +00261 <font class="keywordflow">else</font> +00262 { +00263 u = (uint8)bit; +00264 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>( u ); +00265 } +00266 } +00267 +00268 +00269 <font class="preprocessor">#ifndef NL_OS_CYGWIN</font> +00270 <font class="preprocessor"></font><font class="comment">// ======================================================================================================</font> +<a name="l00271"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_11">00271</a> <font class="keywordtype">void</font> CStringStream::serial(<font class="keywordtype">char</font> &b) +00272 { +00273 <font class="keywordtype">char</font> buff [2]; +00274 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00275 { +00276 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)buff, 2 ); +00277 b = buff[0]; +00278 } +00279 <font class="keywordflow">else</font> +00280 { +00281 buff[0] = b; +00282 buff[1] = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00283 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)buff, 2 ); +00284 } +00285 +00286 } +00287 <font class="preprocessor">#endif</font> +00288 <font class="preprocessor"></font> +00289 <font class="comment">// ======================================================================================================</font> +<a name="l00290"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_12">00290</a> <font class="keywordtype">void</font> CStringStream::serial(std::string &b) +00291 { +00292 sint32 len=0; +00293 <font class="comment">// Read/Write the length.</font> +00294 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00295 { +00296 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00297 <a class="code" href="debug_8h.html#a6">nlassert</a>( len<1000000 ); <font class="comment">// limiting string size</font> +00298 b.resize(len); +00299 } +00300 <font class="keywordflow">else</font> +00301 { +00302 len= b.size(); +00303 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00304 } +00305 +00306 <font class="comment">// Read/Write the string.</font> +00307 <font class="keywordflow">for</font>(sint i=0;i<len;i++) +00308 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&(b[i]), <font class="keyword">sizeof</font>(b[i]) ); +00309 +00310 <font class="keywordtype">char</font> sep = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00311 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&sep, 1 ); +00312 } +00313 +00314 +00315 <font class="comment">// ======================================================================================================</font> +<a name="l00316"></a><a class="code" href="classNLMISC_1_1CStringStream.html#z328_13">00316</a> <font class="keywordtype">void</font> CStringStream::serial(<a class="code" href="classucstring.html">ucstring</a> &b) +00317 { +00318 sint32 len=0; +00319 <font class="comment">// Read/Write the length.</font> +00320 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00321 { +00322 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00323 b.resize(len); +00324 } +00325 <font class="keywordflow">else</font> +00326 { +00327 len= b.size(); +00328 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00329 } +00330 <font class="comment">// Read/Write the string.</font> +00331 <font class="keywordflow">for</font>(sint i=0;i<len;i++) +00332 <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]) ) ); +00333 +00334 <font class="keywordtype">char</font> sep = <a class="code" href="namespaceNLMISC.html#a169">SEPARATOR</a>; +00335 <a class="code" href="classNLMISC_1_1CMemStream.html#a5">serialBuffer</a>( (uint8*)&sep, 1 ); +00336 } +00337 +00338 +00339 <font class="comment">// Specialisation of serialCont() for vector<bool></font> +<a name="l00340"></a><a class="code" href="classNLMISC_1_1CStringStream.html#a21">00340</a> <font class="keywordtype">void</font> CStringStream::serialCont(std::vector<bool> &cont) +00341 { +00342 sint32 len=0; +00343 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) +00344 { +00345 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00346 <font class="comment">// special version for vector: adjut good size.</font> +00347 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(cont); +00348 cont.reserve(len); +00349 +00350 <font class="keywordflow">for</font>(sint i=0;i<len;i++) +00351 { +00352 <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00353 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +00354 cont.insert(cont.end(), <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +00355 } +00356 } +00357 <font class="keywordflow">else</font> +00358 { +00359 len= cont.size(); +00360 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>(len); +00361 +00362 std::vector<bool>::iterator it= cont.begin(); +00363 <font class="keywordflow">for</font>(sint i=0;i<len;i++, it++) +00364 { +00365 <font class="keywordtype">bool</font> b = *it; +00366 <a class="code" href="classNLMISC_1_1CStringStream.html#a6">serial</a>( b ); +00367 } +00368 } +00369 } +00370 +00371 +00372 <font class="comment">/*</font> +00373 <font class="comment"> * Serialisation in hexadecimal</font> +00374 <font class="comment"> */</font> +<a name="l00375"></a><a class="code" href="classNLMISC_1_1CStringStream.html#a22">00375</a> <font class="keywordtype">void</font> CStringStream::serialHex(uint32 &b) +00376 { +00377 <font class="keywordflow">if</font> ( <a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() ) +00378 { +00379 <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> +00380 } +00381 <font class="keywordflow">else</font> +00382 { +00383 <a class="code" href="mem__stream_8h.html#a1">writenumber</a>( b, <font class="stringliteral">"%x"</font>, 10 ); +00384 } +00385 } +00386 +00387 +00388 } <font class="comment">// NLMISC</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> |