Memory-Mapped Files

Overview
Acknowledgments
Installation
Headers
Reference

Overview

The classes mapped_file_source, mapped_file_sink and mapped_file provide access to memory-mapped files on Windows and POSIX systems. These Devices behave much like the File Wrappers basic_file_source, basic_file_sink and basic_file, with the following important differences:

Wide-character versions of the memory-mapped file Devices may be defined as follows, using the template converter:

    #include <boost/iostreams/converter.hpp>
    #include <boost/iostreams/maped_file.hpp>

    typedef converter<mapped_file_source>  wmapped_file_source;
    typedef converter<mapped_file_sink>    wmapped_file_sink;

Acknowledgments

The memory-mapped file Devices are based on the work of Craig Henderson ([Henderson]).

Installation

The memory-mapped file Devices depend on the source file <libs/iostreams/src/mapped_file.cpp>. This source file makes use of Windows or POSIX headers depending on the user's operating system. For installation instructions see Installation.

Headers

<boost/iostreams/device/mapped_file.hpp>

Reference

Class mapped_file_source

Description

Model of Source providing read-only access to memory-mapped files on Windows and POSIX systems.

Synopsis

namespace boost { namespace iostreams {

class mapped_file_source : public source { // Exposition only
public:
    mapped_file_source(const std::string& path);
    ...
};

} } // End namespace boost::io

mapped_file_source::mapped_file_source

    mapped_file_source(const std::string& path);

Constructs a mapped_file_source to access the file with the given pathname.

Class mapped_file_sink

Description

Model of Sink providing write-only access to memory-mapped files on Windows and POSIX systems.

Synopsis

namespace boost { namespace iostreams {

class mapped_file_sink : public sink { // Exposition only
public:
    mapped_file_sink(const std::string& path);
    ...
};

} } // End namespace boost::io

mapped_file_sink::mapped_file_sink

    mapped_file_sink(const std::string& path);

Constructs a mapped_file_sink to access the file with the given pathname.

Class mapped_file

Description

Model of SeekableDevice providing read-write access to memory-mapped files on Windows and POSIX systems.

Synopsis

namespace boost { namespace iostreams {

class mapped_file : public device<seekable> { // Exposition only
public:
    mapped_file(const std::string& path);
    ...
};

} } // End namespace boost::io

mapped_file_::mapped_file

    mapped_file(const std::string& path);

Constructs a mapped_file to access the file with the given pathname.