171 lines
7.3 KiB
HTML
Executable File
171 lines
7.3 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Memory-Mapped Files</TITLE>
|
|
<LINK REL="stylesheet" HREF="../../../../boost.css">
|
|
<LINK REL="stylesheet" HREF="../theme/iostreams.css">
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<!-- Begin Banner -->
|
|
|
|
<H1 CLASS="title">Memory-Mapped Files</H1>
|
|
<HR CLASS="banner">
|
|
|
|
<!-- End Banner -->
|
|
|
|
<DL class="page-index">
|
|
<DT><A href="#overview">Overview</A></DT>
|
|
<DT><A href="#acknowledgments">Acknowledgments</A></DT>
|
|
<DT><A href="#installation">Installation</A></DT>
|
|
<DT><A href="#headers">Headers</A></DT>
|
|
<DT><A href="#reference">Reference</A>
|
|
<UL>
|
|
<LI CLASS="square"><A href="#mapped_file_source">Class <CODE>mapped_file_source</CODE></A></LI>
|
|
<LI CLASS="square"><A href="#mapped_file_sink">Class <CODE>mapped_file_sink</CODE></A></LI>
|
|
<LI CLASS="square"><A href="#mapped_file">Class <CODE>mapped_file</CODE></A></LI>
|
|
</UL>
|
|
</DT>
|
|
</DL>
|
|
|
|
<HR>
|
|
|
|
<A NAME="overview">
|
|
<H2>Overview</H2>
|
|
|
|
<P>
|
|
The classes <CODE>mapped_file_source</CODE>, <CODE>mapped_file_sink</CODE> and <CODE>mapped_file</CODE> provide access to memory-mapped files on Windows and POSIX systems. These <A HREF="../concepts.html#device_concepts">Devices</A> behave much like the <A HREF="file.html">File Wrappers</A> <CODE>basic_file_source</CODE>, <CODE>basic_file_sink</CODE> and <CODE>basic_file</CODE>, with the following important differences:
|
|
</P>
|
|
<UL>
|
|
<LI CLASS="square">Files must exist before being opened, and are never truncated; attempting to write past the end of a file results in an error.
|
|
<LI CLASS="square">Files are always opened in binary mode.
|
|
<LI CLASS="square">Wide-character streams are not supported.
|
|
</UL>
|
|
<P>
|
|
Wide-character versions of the memory-mapped file Devices may be defined as follows, using the template <A HREF="converter.html"><CODE>converter</CODE></A>:
|
|
<PRE CLASS="broken_ie"> <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/converter.hpp"><SPAN CLASS="literal"><boost/iostreams/converter.hpp></SPAN></A>
|
|
<SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/iostreams/device/mapped_file.hpp"><SPAN CLASS="literal"><boost/iostreams/maped_file.hpp></SPAN></A>
|
|
|
|
typedef converter<mapped_file_source> <SPAN CLASS="defined">wmapped_file_source</SPAN>;
|
|
typedef converter<mapped_file_sink> <SPAN CLASS="defined">wmapped_file_sink</SPAN>;</PRE>
|
|
</P>
|
|
|
|
<A NAME="acknowledgments">
|
|
<H2>Acknowledgments</H2>
|
|
|
|
<P>
|
|
The memory-mapped file Devices are based on the work of Craig Henderson (<A CLASS="bib_ref" HREF="../bibliography.html#henderson">[Henderson]</A>).
|
|
</P>
|
|
|
|
<A NAME="installation">
|
|
<H2>Installation</H2>
|
|
|
|
<P>
|
|
The memory-mapped file Devices depend on the source file <A CLASS="header" HREF="../../src/mapped_file.cpp"><CODE><libs/iostreams/src/mapped_file.cpp></CODE></A>. This source file makes use of Windows or POSIX headers depending on the user's operating system. For installation instructions see <A HREF="../installation.html">Installation</A>.
|
|
</P>
|
|
|
|
<A NAME="headers">
|
|
<H2>Headers</H2>
|
|
|
|
<DL class="page-index">
|
|
<DT><A CLASS="header" HREF="../../../../boost/iostreams/device/mapped_file.hpp"><CODE><boost/iostreams/device/mapped_file.hpp></CODE></A></DT>
|
|
</DL>
|
|
|
|
<A NAME="reference">
|
|
<H2>Reference</H2>
|
|
|
|
<A NAME="mapped_file_source">
|
|
<H3>Class <CODE>mapped_file_source</CODE></H3>
|
|
|
|
<H4>Description</H4>
|
|
|
|
<P>Model of <A HREF="../concepts/source.html">Source</A> providing read-only access to memory-mapped files on Windows and POSIX systems.</P>
|
|
|
|
<H4>Synopsis</H4>
|
|
|
|
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
|
|
|
|
<SPAN CLASS="keyword">class</SPAN> <SPAN CLASS="defined">mapped_file_source</SPAN> : <SPAN CLASS="keyword">public</SPAN> <A CLASS="documented" HREF="device.html#synopsis">source</A> { <SPAN CLASS="comment">// Exposition only</SPAN>
|
|
<SPAN CLASS="keyword">public</SPAN>:
|
|
<A CLASS="documented" HREF="#mapped_file_source_constructor">mapped_file_source</A>(<SPAN CLASS="keyword">const</SPAN> std::string& path);
|
|
<SPAN CLASS="omitted">...</SPAN>
|
|
};
|
|
|
|
} } // End namespace boost::io</PRE>
|
|
|
|
<A NAME="mapped_file_source_constructor"></A>
|
|
<H4><CODE>mapped_file_source::mapped_file_source</CODE></H4>
|
|
|
|
<PRE CLASS="broken_ie"> mapped_file_source(<SPAN CLASS="keyword">const</SPAN> std::string& path);</PRE>
|
|
|
|
<P>Constructs a <CODE>mapped_file_source</CODE> to access the file with the given pathname.</P>
|
|
|
|
<A NAME="mapped_file_sink">
|
|
<H3>Class <CODE>mapped_file_sink</CODE></H3>
|
|
|
|
<H4>Description</H4>
|
|
|
|
<P>Model of <A HREF="../concepts/sink.html">Sink</A> providing write-only access to memory-mapped files on Windows and POSIX systems.</P>
|
|
|
|
<H4>Synopsis</H4>
|
|
|
|
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
|
|
|
|
<SPAN CLASS="keyword">class</SPAN> <SPAN CLASS="defined">mapped_file_sink</SPAN> : <SPAN CLASS="keyword">public</SPAN> <A CLASS="documented" HREF="device.html#synopsis">sink</A> { <SPAN CLASS="comment">// Exposition only</SPAN>
|
|
<SPAN CLASS="keyword">public</SPAN>:
|
|
<A CLASS="documented" HREF="#mapped_file_sink_constructor">mapped_file_sink</A>(<SPAN CLASS="keyword">const</SPAN> std::string& path);
|
|
<SPAN CLASS="omitted">...</SPAN>
|
|
};
|
|
|
|
} } // End namespace boost::io</PRE>
|
|
|
|
<A NAME="mapped_file_sink_constructor"></A>
|
|
<H4><CODE>mapped_file_sink::mapped_file_sink</CODE></H4>
|
|
|
|
<PRE CLASS="broken_ie"> mapped_file_sink(<SPAN CLASS="keyword">const</SPAN> std::string& path);</PRE>
|
|
|
|
<P>Constructs a <CODE>mapped_file_sink</CODE> to access the file with the given pathname.</P>
|
|
|
|
<A NAME="mapped_file">
|
|
<H3>Class <CODE>mapped_file</CODE></H3>
|
|
|
|
<H4>Description</H4>
|
|
|
|
<P>Model of <A HREF="../concepts/seekable_device.html">SeekableDevice</A> providing read-write access to memory-mapped files on Windows and POSIX systems.</P>
|
|
|
|
<H4>Synopsis</H4>
|
|
|
|
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
|
|
|
|
<SPAN CLASS="keyword">class</SPAN> <SPAN CLASS="defined">mapped_file</SPAN> : <SPAN CLASS="keyword">public</SPAN> <A CLASS="documented" HREF="device.html#description">device<seekable></A> { <SPAN CLASS="comment">// Exposition only</SPAN>
|
|
<SPAN CLASS="keyword">public</SPAN>:
|
|
<A CLASS="documented" HREF="#mapped_file_constructor">mapped_file</A>(<SPAN CLASS="keyword">const</SPAN> std::string& path);
|
|
<SPAN CLASS="omitted">...</SPAN>
|
|
};
|
|
|
|
} } // End namespace boost::io</PRE>
|
|
|
|
<A NAME="mapped_file_constructor"></A>
|
|
<H4><CODE>mapped_file_::mapped_file</CODE></H4>
|
|
|
|
<PRE CLASS="broken_ie"> mapped_file(<SPAN CLASS="keyword">const</SPAN> std::string& path);</PRE>
|
|
|
|
<P>Constructs a <CODE>mapped_file</CODE> to access the file with the given pathname.</P>
|
|
|
|
<!-- Begin Footer -->
|
|
|
|
<HR>
|
|
<P CLASS="copyright">Revised
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
|
20 May, 2004
|
|
<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
|
|
</P>
|
|
|
|
<P CLASS="copyright">© Copyright Jonathan Turkanis, 2004</P>
|
|
<P CLASS="copyright">
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)
|
|
</P>
|
|
|
|
<!-- End Footer -->
|
|
|
|
</BODY> |