FBB::EoiBuf(3bobcat)

πŸ’– FBB::EoiBuf πŸ’–

okay bestie, welcome to FBB::EoiBuf from the bobcat manual pages (that's the 3bobcat bit, iykyk) ✨

🌸 NAME 🌸

FBB::EoiBuf β€” a std::streambuf class offering an eoi manipulator. literally that's the whole vibe πŸŽ€


✨ SYNOPSIS ✨

#include <bobcat/eoibuf>
Linking option: -lbobcat

πŸ¦‹ DESCRIPTION πŸ¦‹

So. The class EoiBuf inherits from Eoi and may therefore be used as a base class of classes specializing std::streambuf. It also provides a configurable character buffer for storing characters received from their devices. 🌈

Here's the tea, bestie: often, when deriving classes from std::streambuf, the derived classes must implement storage to and retrieval from a character buffer. Not me having to write that from scratch every single time 😭. By deriving from EoiBuf, buffer-handling is automatically provided: it contains a (resizable) character buffer, and offers a setp member as well as a setg member that can be used to specify the index range of the buffer from which extractions receive characters. πŸ’…

Also β€” and this part is iconic β€” when overriding its base class's eoi_ member it can be used to signal the end of input inserted into std::ostream classes using EoiBuf objects as std::streambuf objects. πŸ‘‘


πŸ’œ NAMESPACE πŸ’œ

FBB

All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. periodt.


🧚 INHERITS FROM 🧚

FBB::Eoi (and thus from: std::streambuf)

so yeah, you're getting the whole family tree, no cap 🌳


πŸŽ€ PROTECTED CONSTRUCTOR πŸŽ€

Analogously to std::streambuf, only protected constructors are available. so you can't just new one up in the middle of the street, babe πŸ™ˆ

  • EoiBuf() β€” The default constructor initializes an empty buffer. ✨
  • EoiBuf(size_t size) β€” This initializes an empty buffer of a predefined size of size characters .

Note that there's no inherent limit to the size of the internal buffer: its size can always be enlarged or reduced. it's giving elastic πŸ’…

🚨 Copy and move constructors (and assignment operators) are not available. not a thing. don't try it.

πŸ’… PROTECTED MEMBER FUNCTIONS πŸ’…

All members of std::streambuf and Eoi are available, as FBB::EoiBuf inherits from these classes. you get it all, bestie, no gatekeeping 🫢

  • std::string &buffer() β€” A reference to the internal buffer is returned; πŸ“
  • size_t bufSize() const β€” The length (size) of the internal buffer is returned; πŸ“
  • void resize(size_t size) β€” The size of the internal buffer is changed to size characters; 🌸
  • void setg(unsigned next, unsigned beyond) β€” The streambuf::eback member returns the address of the internal buffer's first character, streambuf::gptr returns the address of the internal buffer's next character, streambuf::egptr returns the address of the internal buffer's beyond character; πŸ”₯
  • void setp() β€” The streambuf::pbase and pptr members return the address of the internal buffer's first character, streambuf::epptr returns the address immediately beyond the internal buffer's last character; ✨
  • unsigned char *ucharPtr() β€” The address of the first character of the internal buffer is returned as a pointer to an unsigned character; πŸ‘‘
  • unsigned char const *ucharPtr() const β€” Same as the previous member, but this time the address of the first character of the internal buffer is returned as a pointer to an immutable unsigned character. πŸ”’

🌟 PROTECTED STATIC MEMBER FUNCTIONS 🌟

The following two static members are provided as convenient functions for derived classes to convert the address of the first character of std::string objects to pointers to unsigned characters:

  • unsigned char *ucharPtr(std::string &str) β€” The address of the first character of str is returned as a pointer to an unsigned character; πŸ’–
  • unsigned char const *ucharPtr(std::string const &str) const β€” Same as the previous member, but this time the address of the first character of str is returned as a pointer to an immutable unsigned character. πŸ¦‹

🌈 EXAMPLE 🌈

The following two functions are defined in the (internally used only) class FBB::OSymCryptBase, which is the base class of osymcryptstreambuf(3bobcat). internally used only, so don't come for me about it πŸ’€

  • evpUpdate β€” updates the ongoing encryption or decryption, e.g., using the openssl function EVP_EncryptUpdate, using ucharPtr to access characters currently in EoiBuf's buffer:
#include "osymcryptbase.ih"

void OSymCryptBase::evpUpdate()
{
    size_t inBufRead = pptr() - pbase();    // # read chars

    checkOutBufSize(inBufRead);

    int nOutputChars;

    if (not ((*d_evpUpdate)(                // en/decrypt the bytes in d_inBuf
            ctx(),
            uOutBuf(), &nOutputChars,
            ucharPtr(), inBufRead
        ))
    )
        throw Exception{} << "EVP_{En,De}cryptUpdate failed";

    d_outStream.write(outBuf(), nOutputChars);      // write the processed
                                                    // chars to d_outSteam

    setp();
}
  • eoi_ β€” overrides FBB::Eoi::eoi_() function, preventing new information from being inserted into the FBB::OSymCryptBase object (and thus from being inserted into its FBB::OSymCryptStreambuf derived class):
#include "osymcryptbase.ih"

void OSymCryptBase::eoi_()
{
    if (d_eoi)
        return;

    evpUpdate();                // process available chars in the input
    d_eoi = true;
    resize(0);                  // clear the input buffer
    evpUpdate();                // update an empty buffer

}

πŸ“ FILES πŸ“

bobcat/eoibuf β€” defines the class interface πŸ“


πŸ‘€ SEE ALSO πŸ‘€

bobcat(7), eoi(3bobcat)

go read those too, bestie, they're the siblings 🫢


πŸ’€ BUGS πŸ’€

None Reported.

and that's the flex of the century, honestly πŸ‘‘


πŸŽ€ 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. cute name, cute origin story πŸ’–


This is free software, distributed under the terms of the GNU General Public License (GPL). slay πŸŽ‰


⭐ AUTHOR ⭐

Frank B. Brokken (f.b.brokken@rug.nl). the icon, the legend, the main character πŸ‘‘


that's the whole page, bestie β€” this one ships with libbobcat-dev_6.15.01, dated 2005-2026, and yes it's been serving looks since 2005 πŸ’…βœ¨ mwah, go compile something gorgeous πŸŽ€

πŸ“¦ where this page comes from