Sophie

Sophie

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

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++: XML.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">XML.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 under the terms of the</span>
<a name="l00002"></a>00002 <span class="comment">// GNU Lesser General Public License (See COPYING for details).</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2000-2001 Michael Day, Stefanus Du Toit</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_XML_H</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define ATLAS_CODECS_XML_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;Atlas/Codec.h&gt;</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;iosfwd&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;stack&gt;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="keyword">namespace </span>Atlas { <span class="keyword">namespace </span>Codecs {
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="comment">/*</span>
<a name="l00018"></a>00018 <span class="comment"></span>
<a name="l00019"></a>00019 <span class="comment">Sample output for this codec: (whitespace added for clarity)</span>
<a name="l00020"></a>00020 <span class="comment"></span>
<a name="l00021"></a>00021 <span class="comment">&lt;atlas&gt;</span>
<a name="l00022"></a>00022 <span class="comment">    &lt;map&gt;</span>
<a name="l00023"></a>00023 <span class="comment">        &lt;int name=&quot;foo&quot;&gt;13&lt;/int&gt;</span>
<a name="l00024"></a>00024 <span class="comment">        &lt;float name=&quot;meep&quot;&gt;1.5&lt;/float&gt;</span>
<a name="l00025"></a>00025 <span class="comment">        &lt;string name=&quot;bar&quot;&gt;hello&lt;/string&gt;</span>
<a name="l00026"></a>00026 <span class="comment">        &lt;list name=&quot;args&quot;&gt;</span>
<a name="l00027"></a>00027 <span class="comment">            &lt;int&gt;1&lt;/int&gt;</span>
<a name="l00028"></a>00028 <span class="comment">            &lt;int&gt;2&lt;/int&gt;</span>
<a name="l00029"></a>00029 <span class="comment">            &lt;float&gt;3.0&lt;/float&gt;</span>
<a name="l00030"></a>00030 <span class="comment">        &lt;/list&gt;</span>
<a name="l00031"></a>00031 <span class="comment">    &lt;/map&gt;</span>
<a name="l00032"></a>00032 <span class="comment">&lt;/atlas&gt;</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/xml_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_x_m_l.html">00039</a> <span class="keyword">class </span><a class="code" href="class_atlas_1_1_codecs_1_1_x_m_l.html">XML</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_x_m_l.html">XML</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_x_m_l.html#a9cbefd1382ea48a02f6bfbe77522c69c" 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_x_m_l.html#aa6ce5cd99469c6721f48801b281ad932" 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_x_m_l.html#a55d9bf52e0dfaf21c9a2d3bb4791eb4d" 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_x_m_l.html#a86e959f3be8b632c9f1a423200f62c7f" 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_x_m_l.html#a56da44d433a35492f7942954b274c62e" 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_x_m_l.html#add8bd6b56acff81a028cd3a6c531dd26" 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_x_m_l.html#a8441bcaec4501d333afc35f933c8174e" 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_x_m_l.html#a5355b556b056d470969239d15c0f9de6" 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_x_m_l.html#a7f1597a56dfc8dacd25e0e01b945509d" 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_x_m_l.html#a774ee041ef0b366e9d4774d05a0d59cc" 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_x_m_l.html#a988dec1eb555a628e126e6b7b9ca3030" 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_x_m_l.html#a8efdd84a2883040a5e3474296182987b" 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_x_m_l.html#ad7cf9e3357e26620b6050ed655069deb" 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_x_m_l.html#a2114ad49bbc74f4fa720c3cb026dc4c5" 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_x_m_l.html#a6733dc902217abf8e0077acee9344b6e" 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> Token
<a name="l00071"></a>00071     {
<a name="l00072"></a>00072         TOKEN_TAG,
<a name="l00073"></a>00073         TOKEN_START_TAG,
<a name="l00074"></a>00074         TOKEN_END_TAG,
<a name="l00075"></a>00075         TOKEN_DATA
<a name="l00076"></a>00076     };
<a name="l00077"></a>00077     
<a name="l00078"></a>00078     Token m_token;
<a name="l00079"></a>00079     
<a name="l00080"></a>00080     <span class="keyword">enum</span> State
<a name="l00081"></a>00081     {
<a name="l00082"></a>00082         PARSE_NOTHING,
<a name="l00083"></a>00083         PARSE_STREAM,
<a name="l00084"></a>00084         PARSE_MAP,
<a name="l00085"></a>00085         PARSE_LIST,
<a name="l00086"></a>00086         PARSE_INT,
<a name="l00087"></a>00087         PARSE_FLOAT,
<a name="l00088"></a>00088         PARSE_STRING
<a name="l00089"></a>00089     };
<a name="l00090"></a>00090     
<a name="l00091"></a>00091     std::stack&lt;State&gt; m_state;
<a name="l00092"></a>00092     std::stack&lt;std::string&gt; m_data;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094     std::string m_tag;
<a name="l00095"></a>00095     std::string m_name;
<a name="l00096"></a>00096 
<a name="l00097"></a>00097     <span class="keyword">inline</span> <span class="keywordtype">void</span> tokenTag(<span class="keywordtype">char</span>);
<a name="l00098"></a>00098     <span class="keyword">inline</span> <span class="keywordtype">void</span> tokenStartTag(<span class="keywordtype">char</span>);
<a name="l00099"></a>00099     <span class="keyword">inline</span> <span class="keywordtype">void</span> tokenEndTag(<span class="keywordtype">char</span>);
<a name="l00100"></a>00100     <span class="keyword">inline</span> <span class="keywordtype">void</span> tokenData(<span class="keywordtype">char</span>);
<a name="l00101"></a>00101 
<a name="l00102"></a>00102     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseStartTag();
<a name="l00103"></a>00103     <span class="keyword">inline</span> <span class="keywordtype">void</span> parseEndTag();
<a name="l00104"></a>00104 };
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 } } <span class="comment">// namespace Atlas::Codecs</span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="preprocessor">#endif // ATLAS_CODECS_XML_H</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>