FBB::MmapBuf(3bobcat)

πŸ“¦
version 6.15.01 Β· 3 versions
, in ubuntu stonking

πŸ’– 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 empty MmapBuf object. 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 the MmapBuf object for a file named fname. the openmode can be any combination of the std::ios::openmode values. the required values are usually provided for you when you construct ImapStream, OmapStream, or IOmapStream objects (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 used mmap buffer 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. once MmapBuf objects cease to exist, the used file's size is modified to the current fileSize value. 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 by mmap.

⭐ 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 πŸ‘‘

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. 🫢


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