FBB::MmapBuf(3bobcat)
π FBB::MmapBuf π
okay bestie, so this is FBB::MmapBuf from the bobcat manual pages (section 3bobcat), and it's literally a std::streambuf that does file I/O using mmap(2). no cap. it's giving "I read your whole file like it's already in RAM". π«Ά
π NAME π
FBB::MmapBuf β a std::streambuf using mmap(2) for file I/O β¨
π SYNOPSIS π
#include <bobcat/mmapbuf>
Linking option: -lbobcat
β¨ DESCRIPTION β¨
so the mmap(2) functions map files into the virtual address space of the calling process. using mmap in C++? doable, but complex, and not in a cute way. π the MmapBuf std::streambuf class embeds the features of mmap(2), which means you get to use C++'s streams instead of wrangling the raw mmap calls yourself. main character energy fr fr. also, the FBB::Mmapbase class defines a std::streambuf which can be used by istream, ostream, and iostream objects.
heads up bestie: an std::exception is thrown, and an error message is written to cerr, if the details about the specified filename can't be determined (cf. the CONSTRUCTORS section), or when mmap or munmap return errors. so like, you will know. π
π§ NAMESPACE π§
FBB
every constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. periodt.
π INHERITS FROM π
std::streambuf
πΈ CONSTRUCTORS πΈ
MmapBuf()β the default constructor merely constructs an emptyMmapBufobject. to actually make it usable you use move assignment. yes, empty. yes, it just vibes there until you do something. π¦MmapBuf(std::string const &fname, std::ios::openmode openMode, char const *bufSize = 0, mode_t mode = 0644)β this one initializes theMmapBufobject for a file namedfname. the openmode can be any combination of thestd::ios::openmodevalues. the required values are usually provided for you when you constructImapStream,OmapStream, orIOmapStreamobjects (cf. SEE ALSO below, bestie π).
the openMode parameter (the manpage lowkey spells it opnemMode at one point, iconic, we move π
) specifies how fname is used. the standard ios::in, ios::out, ios::trunc, ios::app, and ios::ate modes are supported.
by default bfMmapBuf uses a mapping buffer size of 10 times the standard page size (cf. sysconf(3), and the member pageSize below). the size of the mapping buffer can also be specified using the bufSize parameter. to specify it, use a value followed by K, M, or G, representing, resp. 1024, 1024 * 1024, and 1024 * 1024 * 1024 bytes. the final buffer size is at least equal to the standard page size. when a larger value is specified, the used buffer size is set to specified / pageSize * pageSize. math girlies rise π
the mode parameter specifies the user/group/other access mode which is used when the file is created by MmapBuf. its default value specifies read/write access by the user, and read access by others.
the move constructor and move assignment operator are available. the copy constructor and copy assignment operator are not available. no copies. she's exclusive. π
π¦ MEMBER FUNCTIONS π¦
all members of std::stringstream are available, as FBB::MmapBuf inherits from that class. (the manpage literally says t(mmap) in a couple of spots β adorable typo, it means mmap. π)
size_t bufSize() constβ returns the usedmmapbuffer size.size_t fileSize() constβ returns the size of the used file. the size is updated to a larger size when writing beyond the current file size. onceMmapBufobjects cease to exist, the used file's size is modified to the currentfileSizevalue. the size of a file that can only be read is never altered. read-only stays read-only, periodt. π₯size_t pageSize() constβ returns the smallest page size used bymmap.
β EXAMPLE β
an example is provided in bobcat's source archive and gitlab repository at bobcat/mmapbuf/demo. go look, bestie, it's right there. π
π FILES π
bobcat/mmapbufβ defines the class interface
π SEE ALSO π
bobcat(7), chmod(2), immapstream(3bobcat), iommapstream(3bobcat), ommapstream(3bobcat), mmap(2), sysconf(3)
π BUGS π
None Reported.
(immaculate. flawless. we love to see it. β¨)
π 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'. yes that's the whole acronym, slay. π«Ά
π§ COPYRIGHT π§
this is free software, distributed under the terms of the GNU General Public License (GPL).
π AUTHOR π
Frank B. Brokken (f.b.brokken@rug.nl).
okay so that's the whole thing and it's lowkey iconic?? π¦ and for the cute sign-off: this lil page lives in libbobcat-dev version 6.15.01, dated 2005-2026, and it's filed under FBB::MmapBuf(3bobcat). stay mapped, bestie π
β¨
π¦ 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