69 lines
14 KiB
HTML
69 lines
14 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!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=UTF-8" /><title>The Be Book - Classes And Methods - The Support Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheSupportKit.html" title="The Support Kit" /><link rel="prev" href="BMallocIO.html" title="BMallocIO" /><link rel="next" href="BPositionIO.html" title="BPositionIO" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BMallocIO.html" title="BMallocIO"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BPositionIO.html" title="BPositionIO"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Support Kit</div></div><div id="headerB">Prev: <a href="BMallocIO.html">BMallocIO</a> Up: <a href="TheSupportKit.html">The Support Kit</a> Next: <a href="BPositionIO.html">BPositionIO</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO"></a>BMemoryIO</h2></div></div></div><a id="id1272997" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td>
|
||
<a class="link" href="BPositionIO.html" title="BPositionIO"><code class="classname">BPositionIO</code></a>
|
||
</td></tr><tr><td>Mix-in Classes:</td><td>–</td></tr><tr><td>Declared In:</td><td><code class="filename">support/DataIO.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libbe.so</code></td></tr><tr><td>Allocation:</td><td>–</td></tr></tbody></table></td><td>
|
||
<a class="link overview" href="BMemoryIO_Overview.html" title="BMemoryIO">Class Overview</a>
|
||
<div class="toc"><ul><li><span class="section"><a href="BMemoryIO.html#BMemoryIO_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BMemoryIO.html#BMemoryIO_MemberFunctions">Member Functions</a></span></li></ul></div>
|
||
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_Constructor"></a>BMemoryIO()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BMemoryIO</span>(<span class="methodparam"><span class="type">void* </span><span class="parameter">buffer</span></span>,<br /> <span class="methodparam"><span class="type">size_t </span><span class="parameter">numBytes</span></span>);</code>
|
||
|
||
<code class="constructorsynopsis cpp"><span class="methodname">BMemoryIO</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">void* </span><span class="parameter">buffer</span></span>,<br /> <span class="methodparam"><span class="type">size_t </span><span class="parameter">numBytes</span></span>);</code>
|
||
</div><p>
|
||
The <code class="classname">BMemoryIO</code> constructor assigns the object a buffer with at least
|
||
<code class="parameter">numBytes</code> of available memory. If the buffer is declared <span class="emphasis"><em>const</em></span>, the object
|
||
is read-only; calls to
|
||
<a class="link" href="BPositionIO.html#BPositionIO_Write" title="Write(), WriteAt()"><code class="methodname">Write()</code></a>
|
||
(inherited from <a class="link" href="BPositionIO.html" title="BPositionIO"><code class="classname">BPositionIO</code></a>) and
|
||
<a class="link" href="BMemoryIO.html#BMemoryIO_WriteAt" title="WriteAt()"><code class="methodname">WriteAt()</code></a> will fail. Otherwise, the
|
||
buffer can be both read and written. In either case, the caller retains
|
||
responsibility for the buffer; the <code class="classname">BMemoryIO</code> object won't free it.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_Destructor"></a>~BMemoryIO()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BMemoryIO</span>();</code><p>
|
||
The <code class="classname">BMemoryIO</code> destructor does nothing.
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_ReadAt"></a>ReadAt()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">ssize_t </span><span class="methodname">ReadAt</span>(<span class="methodparam"><span class="type">off_t </span><span class="parameter">position</span></span>,<br /> <span class="methodparam"><span class="type">void* </span><span class="parameter">buffer</span></span>,<br /> <span class="methodparam"><span class="type">size_t </span><span class="parameter">numBytes</span></span>);</code><p>
|
||
Copies up to <code class="parameter">numBytes</code> bytes of data from the object into the <code class="parameter">buffer</code> and
|
||
returns the actual number of bytes placed in the buffer. The data is read
|
||
beginning at the <code class="parameter">position</code> offset.
|
||
</p><p>
|
||
This function doesn't read beyond the end of the data. If there are fewer
|
||
than <code class="parameter">numBytes</code> of data available at the <code class="parameter">position</code> offset, it reads only
|
||
through the last data byte and returns a smaller number than <code class="parameter">numBytes</code>. If
|
||
<code class="parameter">position</code> is out of range, it returns 0.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_Seek"></a><a id="BMemoryIO_Position"></a>
|
||
Seek(), Position()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">off_t </span><span class="methodname">Seek</span>(<span class="methodparam"><span class="type">off_t </span><span class="parameter">position</span></span>,<br /> <span class="methodparam"><span class="type">int32 </span><span class="parameter">mode</span></span>);</code><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">off_t </span><span class="methodname">Position</span>() <span class="modifier">const</span>;</code><p>
|
||
<code class="methodname">Seek()</code> sets the position in the data buffer where the
|
||
<a class="link" href="BPositionIO.html#BPositionIO_Read" title="Read(), ReadAt()"><code class="methodname">Read()</code></a> and
|
||
<a class="link" href="BPositionIO.html#BPositionIO_Write" title="Write(), WriteAt()"><code class="methodname">Write()</code></a>
|
||
functions (inherited from
|
||
<a class="link" href="BPositionIO.html" title="BPositionIO"><code class="classname">BPositionIO</code></a>)
|
||
begin reading and writing. How the <code class="parameter">position</code>
|
||
argument is understood depends on the <code class="parameter">mode</code>
|
||
flag. There are three possible modes:
|
||
</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">SEEK_SET</code>.</span></p></td><td><p>The <code class="parameter">position</code> passed is an offset from
|
||
the beginning of allocated memory; in other words, the current position is
|
||
set to <code class="parameter">position</code>. For this mode,
|
||
<code class="parameter">position</code> should be a positive value.</p></td></tr><tr><td><p><span class="term"><code class="constant">SEEK_CUR</code>.</span></p></td><td><p>The <code class="parameter">position</code> argument is an offset from the current
|
||
position; the value of the argument is added to the current position.</p></td></tr><tr><td><p><span class="term"><code class="constant">SEEK_END</code>.</span></p></td><td><p>The <code class="parameter">position</code> argument is an offset from
|
||
the end of the object's data buffer. In this mode the
|
||
<code class="parameter">position</code> argument must be negative.</p></td></tr></tbody></table><p>
|
||
<a class="link" href="BPositionIO.html#BPositionIO_Write" title="Write(), WriteAt()"><code class="methodname">Write()</code></a>
|
||
fails if the current position is beyond the end of assigned memory.
|
||
</p><p>
|
||
Both <code class="methodname">Seek()</code> and <code class="methodname">Position()</code>
|
||
return the current position as an offset in
|
||
bytes from the beginning of allocated memory.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMemoryIO_WriteAt"></a>WriteAt()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">ssize_t </span><span class="methodname">WriteAt</span>(<span class="methodparam"><span class="type">off_t </span><span class="parameter">position</span></span>,<br /> <span class="methodparam"><span class="modifier">const </span><span class="type">void* </span><span class="parameter">buffer</span></span>,<br /> <span class="methodparam"><span class="type">size_t </span><span class="parameter">numBytes</span></span>);</code><p>
|
||
Copies <code class="parameter">numBytes</code> bytes of data from <code class="parameter">buffer</code>
|
||
into allocated memory beginning
|
||
at <code class="parameter">position</code>, and returns the number of bytes written.
|
||
</p><p>
|
||
<code class="methodname">WriteAt()</code> won't write outside the memory buffer.
|
||
If <code class="parameter">position</code> is beyond
|
||
the end of the buffer, it returns 0. If the object is read-only, it
|
||
returns <code class="constant">B_NOT_ALLOWED</code>.
|
||
</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BMallocIO.html">BMallocIO</a> Up: <a href="TheSupportKit.html">The Support Kit</a> Next: <a href="BPositionIO.html">BPositionIO</a> </div><div id="footerB"><div id="footerBL"><a href="BMallocIO.html" title="BMallocIO"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BPositionIO.html" title="BPositionIO"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|