IOMMAPSTREAM(3bobcat)
β¨ NAME β¨
FBB::IOmmapStream β an Input Stream that uses mmap(2) through FBB::MmapBuf π«
(hey bestie, this is the IOmmapStream page from the 3bobcat manual β come sit, it's actually so good)
πΈ SYNOPSIS πΈ
#include <bobcat/iommapstream>
Linking option: -lbobcat
π DESCRIPTION π
So like, FBB::IOmmapStream objects are what you use when you want to read from or write to files that get plopped right into the virtual address space of the calling process. The whole "living in your virtual address space" situation is handled by the class's privately inherited FBB::MmapBuf, which is a std::streambuf class. π
And the vibe? By mapping files into the process's virtual address space, the time it takes to process those files is usually dramatically reduced. it's giving speed. π₯
Now for the part where you gotta be careful: an std::exception gets thrown, and an error message gets written to cerr, if the FBB::MmapBuf base class can't figure out the size of the file you specified, or when the (un)mapping can't be done. π so like, handle your errors bestie.
π¦ NAMESPACE π¦
FBB
Every single constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB.
π INHERITS FROM π
std::iostream, privately from FBB::MmapBuf.
π CONSTRUCTORS π
IOmmapStream()β the default constructor just constructs an emptyIOmmapStreamobject, no thoughts, head empty. To actually turn it into something usable you use move assignment. β¨IOmmapStream(std::string const &fname, char const *bufSize = 0, std::ios::openmode openMode = std::ios::out | std::ios::in, mode_t mode = 0644)β this constructor initializes theIOmmapStreamobject for a file named fname. π
The openMode parameter says how fname is used. The standard ios::in, ios::out, ios::trunc, ios::app, and ios::ate modes are supported. periodt.
By default, FBB::IOmmapStream uses a mapping buffer size of 10 times the standard page size (check sysconf(3), and the member pageSize below π). The size of the mapping buffer can also be set with the bufSize parameter. To specify it, use a value followed by K, M, or G, representing, respectively, 1024, 1024 * 1024, and 1024 * 1024 * 1024 bytes. The final buffer size is at least the standard page size. When you specify a larger value, the buffer size that actually gets used is set to specified / pageSize * pageSize.
The mode parameter specifies the user/group/other access mode that's used when the file is created by MmapBuf. Its default value means read/write access for the user, and read access for others. π
Heads up bestie: the move constructor and move assignment operator are available. The copy constructor and copy assignment operator are not available. no copying, only moving. we love a class with boundaries π
π MEMBER FUNCTIONS π
All members of std::iostream are available, because FBB::IOmmapStream inherits from that class. slay.
size_t bufSize() constβ returns the used(mmap)buffer's size π§size_t fileSize() constβ returns the current size of the file in use. The size gets updated to a larger size when you write beyond the current file size. And once theIOmmapStreamobject ceases to exist, the used file's size is modified to the currentfileSizevalue. iconic.size_t pageSize() constβ returns the smallest page size used by(mmap)π
β EXAMPLE β
An example is provided in bobcat's source archive and gitlab repository at bobcat/iommapstream/demo. go look, it's right there π«Ά
π FILES π
bobcat/iommapstream β defines the class interface β¨
π SEE ALSO π
bobcat(7), chmod(2), immapstream(3bobcat), mmap(2), mmapbuf(3bobcat), ommapstream(3bobcat), sysconf(3)
π BUGS π
None Reported. (we're so back, not a single bug to be found π)
πΈ BOBCAT PROJECT FILES πΈ
https://fbb-git.gitlab.io/bobcat/β gitlab project page β¨
Debian Bobcat project files:
libbobcat6β debian package containing the shared library, changelog and copyright note;libbobcat-devβ debian package containing the static library, headers, manual pages, and developer info;
π BOBCAT π
Bobcat is an acronym of Brokken's Own Base Classes And Templates. iykyk π
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL). free as in free bestie π
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl). thank you king π
and that's the whole page bb! this one shipped in libbobcat-dev_6.15.01, dated 2005-2026 β go be the main character of your own mmap journey π¦β¨
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms