126 lines
7.1 KiB
HTML
Executable File

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>LOOP: String Stream</title>
<style type="text/css" media="all"><!--
@import "../../loop.css";
@import "../../layout1.css";
--></style>
</head>
<body>
<div id="Header">Class Models for Lua</div>
<div id="Logo"><img alt="small (1K)" src="../../small.gif" height="70"></div>
<div id="Menu">
<div class="outside"><div class="inside"><ul>
<li><a href="../../index.html", title="">Home</a></li>
<li><a href="../../release/index.html", title="Installation">Install</a></li>
<li><a href="../../manual/index.html", title="User Manual">Manual</a></li>
<li><a href="../index.html", title="Class Library">Library</a>
<div class="outside"><div class="inside"><ul>
<li><a href="../overview.html#collection", title="Collections">collection</a>
</li>
<li><a href="../overview.html#compiler", title="Compiling">compiler</a>
</li>
<li><a href="../overview.html#debug", title="Debugging">debug</a>
</li>
<li><a href="../overview.html#object", title="Objects">object</a>
</li>
<li><a href="../overview.html#serial", title="Serialization">serial</a>
</li>
<li><a href="../overview.html#thread", title="Threading">thread</a>
</li>
</ul></div></div>
</li>
<li><a href="../../contact.html", title="Contact People">Contact</a></li>
<li><a href="http://luaforge.net/projects/oil/", title="Project at LuaForge">LuaForge</a></li>
</ul></div></div>
</div>
<div class="content">
<h1>String Stream</h1>
<h2><code>loop.serial.StringStream</code></h2><br>
<p>Subclass of <code><a href="Serializer.html">Serializer</a></code> that serializes values into a string.
It is also used to restore values serialized in a string using the serialization mechanism provided by <code><a href="Serializer.html">Serializer</a></code>.
This class is useful to pack values into strings that can be stored in run-time memory or other sort of storage.</p>
<p>Instances of this class implement the <code>write</code> method required by <code><a href="Serializer.html">Serializer</a></code> in such way that it stores the pieces of the serialized code in the instance itself and concatenates them to produce the serialized code.</p>
<h2>Behavior</h2>
<h3>Fields</h3>
<dl>
<dt><code><b>data</b></code> [optional]</dt>
<dd>
String containing sequences of serialized values separated by null characters (<i>i.e.</i> <code>"\0"</code>).
This string must contain the serialized code of the values to be restored.
If this field evaluates to <code>false</code> then the serialized code produced previously by the instance is used to retrieve values.
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt><code><b>put</b>(...)</code></dt>
<dd>
Serializes the arguments and stores the results in the instance so it is used to form the complete final serialized code in a string.
The sequences of values serialized by this function are separated by null characters (<i>i.e.</i> <code>"\0"</code>).
</dd>
<dt><code><b>get</b>()</code></dt>
<dd>
Each time this method is called, it restores one of the set of values serialized in the string stored in field <code>data</code>, in the same order they were serialized.
All the set of values stored in the string stored in field <code>data</code> must be separated by null characters (<i>i.e.</i> <code>"\0"</code>).
</dd>
</dl>
<h3>Meta-Fields</h3>
<dl>
<dt><code><b>__tostring</b></code></dt>
<dd>
Concatenates all the pieces of serialized code to form a string containing all serialized values.
If there are more than one sequence of values serialized then such sequences are separated by null characters (<i>i.e.</i> <code>"\0"</code>).
</dd>
</dl>
<h2>Remarks</h2>
<ul>
<li>Methods <code>serialize</code> and <code>load</code> of the superclass <code><a href="Serializer.html">Serializer</a></code> should not be used because they break the serialization policy used by this class.</li>
</ul>
<h2>Examples</h2>
<h3><a name="$ExampleName">$ExampleDescription</a></h3>
<pre>
-- example missing
</pre>
</div>
<div class="content">
<p><small><strong>Copyright (C) 2004-2008 Tecgraf, PUC-Rio</strong></small></p>
<small>This project is currently being maintained by <a href="http://www.tecgraf.puc-rio.br">Tecgraf</a> at <a href="http://www.puc-rio.br">PUC-Rio</a>.</small>
</div>
</body>
</html>