Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 626e7b9df2c26f4a1ac4abc5819592a1 > files > 84

atlascpp-devel-0.6.2-1.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Atlas-C++: Packed.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Atlas-C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Packed.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// This file may be redistributed and modified only under the terms of</span>
<a name="l00002"></a>00002 <span class="comment">// the GNU Lesser General Public License (See COPYING for details).</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2000-2001 Stefanus Du Toit, Michael Day</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="comment">// $Id$</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#ifndef ATLAS_CODECS_PACKED_H</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define ATLAS_CODECS_PACKED_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;<a class="code" href="_utility_8h.html" title="Various utility functions for codec implementation.">Atlas/Codecs/Utility.h</a>&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;Atlas/Codec.h&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;iosfwd&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;stack&gt;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="keyword">namespace </span>Atlas { <span class="keyword">namespace </span>Codecs {
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="comment">/*</span>
<a name="l00019"></a>00019 <span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">The form for each element of this codec is as follows:</span>
<a name="l00021"></a>00021 <span class="comment"></span>
<a name="l00022"></a>00022 <span class="comment">[type][name=][data][|endtype]</span>
<a name="l00023"></a>00023 <span class="comment">  </span>
<a name="l00024"></a>00024 <span class="comment">( ) for lists</span>
<a name="l00025"></a>00025 <span class="comment">[ ] for maps</span>
<a name="l00026"></a>00026 <span class="comment">$ for string</span>
<a name="l00027"></a>00027 <span class="comment">@ for int</span>
<a name="l00028"></a>00028 <span class="comment"># for float</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="comment">Sample output for this codec: (whitespace added for clarity)</span>
<a name="l00031"></a>00031 <span class="comment"></span>
<a name="l00032"></a>00032 <span class="comment">[@id=17$name=Fred +28the +2b great+29#weight=1.5(args=@1@2@3)]</span>
<a name="l00033"></a>00033 <span class="comment"></span>
<a name="l00034"></a>00034 <span class="comment">The complete specification is located in cvs at:</span>
<a name="l00035"></a>00035 <span class="comment">    forge/protocols/atlas/spec/packed_syntax.html</span>
<a name="l00036"></a>00036 <span class="comment">    </span>
<a name="l00037"></a>00037 <span class="comment">*/</span>
<a name="l00038"></a>00038   
<a name="l00039"></a><a class="code" href="class_atlas_1_1_codecs_1_1_packed.html">00039</a> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_codecs_1_1_packed.html">Packed</a> : <span class="keyword">public</span> <a class="code" href="class_atlas_1_1_codec.html" title="Atlas stream codec.">Codec</a>
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041 <span class="keyword">public</span>:
<a name="l00042"></a>00042     
<a name="l00043"></a>00043     <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html">Packed</a>(std::iostream&amp; s, <a class="code" href="class_atlas_1_1_bridge.html" title="Atlas stream bridge.">Atlas::Bridge</a> &amp; b);
<a name="l00044"></a>00044 
<a name="l00045"></a>00045     <span class="keyword">virtual</span> <span class="keywordtype">void</span> poll(<span class="keywordtype">bool</span> can_read = <span class="keyword">true</span>);
<a name="l00046"></a>00046 
<a name="l00047"></a>00047     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#aa1025906528a9e63632ac82869d8959f" title="Begin an Atlas stream.">streamBegin</a>();
<a name="l00048"></a>00048     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#add15b886e94e021fe67054338d7034e7" title="Start a message in an Atlas stream.">streamMessage</a>();
<a name="l00049"></a>00049     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a371462bc444b23cec214b16a24b07f15" title="Ends the Atlas stream.">streamEnd</a>();
<a name="l00050"></a>00050 
<a name="l00051"></a>00051     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a75baed666483f7682a7f2fc5b9075ac1" title="Starts a map object to the currently streamed map.">mapMapItem</a>(<span class="keyword">const</span> std::string&amp; name);
<a name="l00052"></a>00052     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a0401e573abff06ef6e950bcc315e5c43" title="Starts a list object to the currently streamed map.">mapListItem</a>(<span class="keyword">const</span> std::string&amp; name);
<a name="l00053"></a>00053     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a1e948765dca6032d16ac352ca3f2a100" title="Adds an integer to the currently streames map.">mapIntItem</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keywordtype">long</span>);
<a name="l00054"></a>00054     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#abcdc8cb40c93dedff17ed21a46476d48" title="Adds a float to the currently streamed map.">mapFloatItem</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keywordtype">double</span>);
<a name="l00055"></a>00055     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a65a781725c1a9466df4a3bfcea816cee" title="Adds a string to the currently streamed map.">mapStringItem</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keyword">const</span> std::string&amp;);
<a name="l00056"></a>00056     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#aef09bee989f01c8dc1c9e17522a160f2" title="Ends the currently streamed map.">mapEnd</a>();
<a name="l00057"></a>00057     
<a name="l00058"></a>00058     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#ade8397fb05919b8b176cae28b3ac84f8" title="Starts a map object in the currently streamed list.">listMapItem</a>();
<a name="l00059"></a>00059     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a22f787d37a376fb37691bd620b1aec30" title="Starts a list object in the currently streamed list.">listListItem</a>();
<a name="l00060"></a>00060     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a791c1574ec71fc788321eb52d9b5cc3d" title="Adds an integer to the currently streames list.">listIntItem</a>(<span class="keywordtype">long</span>);
<a name="l00061"></a>00061     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a3380933293a260ed408c228a73f8e4f7" title="Adds a float to the currently streamed list.">listFloatItem</a>(<span class="keywordtype">double</span>);
<a name="l00062"></a>00062     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a15943602a93b9db484e95b9fbcacd1a2" title="Adds a string to the currently streamed list.">listStringItem</a>(<span class="keyword">const</span> std::string&amp;);
<a name="l00063"></a>00063     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_atlas_1_1_codecs_1_1_packed.html#a00766e5f47d2918e18b3de24d2f51a2f" title="Ends the currently streamed list.">listEnd</a>();
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="keyword">protected</span>:
<a name="l00066"></a>00066     
<a name="l00067"></a>00067     std::iostream&amp; m_socket;
<a name="l00068"></a>00068     <a class="code" href="class_atlas_1_1_bridge.html" title="Atlas stream bridge.">Bridge</a> &amp; m_bridge;
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     <span class="keyword">enum</span> State
<a name="l00071"></a>00071     {
<a name="l00072"></a>00072         PARSE_STREAM,
<a name="l00073"></a>00073         PARSE_MAP,
<a name="l00074"></a>00074         PARSE_LIST,
<a name="l00075"></a>00075         PARSE_MAP_BEGIN,
<a name="l00076"></a>00076         PARSE_LIST_BEGIN,
<a name="l00077"></a>00077         PARSE_INT,
<a name="l00078"></a>00078         PARSE_FLOAT,
<a name="l00079"></a>00079         PARSE_STRING,
<a name="l00080"></a>00080         PARSE_NAME
<a name="l00081"></a>00081     };
<a name="l00082"></a>00082     
<a name="l00083"></a>00083     std::stack&lt;State&gt; m_state;
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     std::string m_name;
<a name="l00086"></a>00086     std::string m_data;
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseStream(<span class="keywordtype">char</span>);
<a name="l00089"></a>00089     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseMap(<span class="keywordtype">char</span>);
<a name="l00090"></a>00090     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseList(<span class="keywordtype">char</span>);
<a name="l00091"></a>00091     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseMapBegin(<span class="keywordtype">char</span>);
<a name="l00092"></a>00092     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseListBegin(<span class="keywordtype">char</span>);
<a name="l00093"></a>00093     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseInt(<span class="keywordtype">char</span>);
<a name="l00094"></a>00094     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseFloat(<span class="keywordtype">char</span>);
<a name="l00095"></a>00095     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseString(<span class="keywordtype">char</span>);
<a name="l00096"></a>00096     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseName(<span class="keywordtype">char</span>);
<a name="l00097"></a>00097 
<a name="l00098"></a>00098     <span class="keyword">inline</span> <span class="keyword">const</span> std::string hexEncode(<span class="keyword">const</span> std::string&amp; data)
<a name="l00099"></a>00099     {
<a name="l00100"></a>00100         <span class="keywordflow">return</span> hexEncodeWithPrefix(<span class="stringliteral">&quot;+&quot;</span>, <span class="stringliteral">&quot;+[]()@#$=&quot;</span>, data);
<a name="l00101"></a>00101     }
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="keyword">inline</span> <span class="keyword">const</span> std::string hexDecode(<span class="keyword">const</span> std::string&amp; data)
<a name="l00104"></a>00104     {
<a name="l00105"></a>00105         <span class="keywordflow">return</span> hexDecodeWithPrefix(<span class="stringliteral">&quot;+&quot;</span>, data);
<a name="l00106"></a>00106     }
<a name="l00107"></a>00107 };
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 } } <span class="comment">// namespace Atlas::Codecs</span>
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<HR>
<P>Copyright 2000-2004 the respective authors.</P>
<P>This document can be licensed under the terms of the GNU Free Documentation
License or the GNU General Public License and may be freely distributed under
the terms given by one of these licenses.</P>