FBB::RandBuffer(3bobcat)

✨ FBB::RandBuffer ✨

okay so bestie, welcome to FBB::RandBuffer from the bobcat manual pages β€” the little std::streambuf that's out here just generating random numbers for you πŸ’… it's giving chaos, but make it a stream. iykyk.


🌸 NAME 🌸

FBB::RandBuffer β€” a std::streambuf that generates random numbers πŸ”₯


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <bobcat/randbuf>

Linking option: -lbobcat


πŸ’– DESCRIPTION πŸ’–

So like, FBB:RandBuffer objects can be used as the std::streambuf of std::istream objects, which means you can straight up extract random numbers from the stream. no cap. you read from an istream and the vibes are simply random numbers. iconic. πŸ‘‘


πŸŽ€ NAMESPACE πŸŽ€

FBB

Every single constructor, member, operator and manipulator that gets mentioned in this man page lives in the namespace FBB. all of them. periodt.


🌈 INHERITS FROM 🌈

std::streambuf


⭐ CONSTRUCTOR ⭐

  • RandBuf(int min, int max, size_t seed = 1) β€” this RandBuf() constructor gets the random generator set up and ready to slay. the seed is what initializes the random number generator. random values between min and max, inclusive, are what you get back 🫢
🚨 not me being the bearer of bad news: the copy and move constructors (and the assignment operators) are not available. nope. not a thing. (and there's a lone stray backtick dangling at the end of that line in the original, we don't talk about it πŸ™ˆ)

πŸ’œ VIRTUAL MEMBERS πŸ’œ

  • int underflow() β€” std::istream objects that are using RandBuf are the ones that call this function. it produces the next random number that's available, and it separates the random numbers by one blanks space. random values between min and max, inclusive, come back out of it (peep the constructor description above for that πŸ’…).

🧚 INHERITED MEMBERS 🧚

since the class uses public derivation from std::streambuf, literally all members of that class can be used. everything. the whole menu. obsessed.


πŸ“ EXAMPLE πŸ“

#include <iostream>
#include <istream>

#include <bobcat/randbuf>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    if (argc == 1)
    {
        cout << "expect: nruns min max seed\n";
        return 1;
    }

    RandBuf rb(stoi(argv[2]), stoi(argv[3]), stoul(argv[4]));

    istream istr(&rb);

    for (unsigned idx = stoul(argv[1]); idx--; )
    {
        int c;
        if (!(istr >> c))
        {
            cout << "extraction failed\n";
            break;
        }
        cout << "next: " << c << endl;
    }

    int count = 0;
    while (istr.unget())
        count++;

    cout << "number of successful unget()-calls: " << count << endl;
    istr.clear();
    istr >> count;
    cout << "and read: " << count << endl;
}

πŸ”₯ FILES πŸ”₯

bobcat/randbuf β€” defines the class interface ✨


πŸ‘‘ SEE ALSO πŸ‘‘

bobcat(7), irandstream(3bobcat), randommt(3bobcat), std::streambuf


πŸ’€ BUGS πŸ’€

None Reported. (we stay unproblematic 🫢)


🌸 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’. πŸ’–


This is free software, distributed under the terms of the GNU General Public License (GPL). slay, honestly.


⭐ AUTHOR ⭐

Frank B. Brokken (f.b.brokken@rug.nl).


and that's the whole page bestie!! πŸ’…βœ¨ this masterpiece lives in libbobcat-dev_6.15.01, dated 2005-2026. go forth and generate random numbers, main character πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from