# Rrgen | A Header Only C++ Library For Storing Safe, Randomly Generated Data Into Modern Containers

**URL:** <https://onehack.st/t/rrgen-a-header-only-c-library-for-storing-safe-randomly-generated-data-into-modern-containers/280780>\
**Category:** Tools & Scripts\
**Tags:** tools, programming, ai, hosting\
**Created:** [April 4, 2024, 10:15pm UTC](https://onehack.st/t/rrgen-a-header-only-c-library-for-storing-safe-randomly-generated-data-into-modern-containers/280780 "2024-04-04T22:15:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoBody](https://onehack.st/user_avatar/onehack.st/nobody/32/163880_2.png) [@NoBody](https://onehack.st/u/NoBody)\
**Post date:** [April 4, 2024, 10:15pm UTC](https://onehack.st/t/rrgen-a-header-only-c-library-for-storing-safe-randomly-generated-data-into-modern-containers/280780/1 "2024-04-04T22:15:35Z")

</div>

[![](https://raw.githubusercontent.com/josh0xA/rrgen/master/docs/rrgen_logo.png)](https://raw.githubusercontent.com/josh0xA/rrgen/master/docs/rrgen_logo.png)

[![lisence](https://camo.githubusercontent.com/6552afb9038154d801c50b6e55a76db78a6787a8d6e2b5252a44864503c52887/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://lbesson.mit-license.org/)

## About

This library was developed to combat insecure methods of storing random data into modern C++ containers. For example, old and clunky PRNGs. Thus, rrgen uses STL’s distribution engines in order to efficiently and safely store a random number distribution into a given C++ container.

## Installation

1. `git clone https://github.com/josh0xA/rrgen.git`

2. `cd rrgen`

3. `make`

4. Add `include/rrgen.hpp` to your project tree for access to the library classes and functions.

## Official Documentation

_rrgen/docs/index.rst_

## Supported Containers

1. `std::vector<>`

2. `std::list<>`

3. `std::array<>`

4. `std::stack<>`

## Example Usages

```auto
#include "../include/rrgen.hpp"
#include <iostream>

int main(void)
{
    // Example usage for rrgen vector
    rrgen::rrand<float, std::vector, 10> rrvec;
    rrvec.gen_rrvector(false, true, 0, 10);
    for (auto &i : rrvec.contents())
    {
        std::cout << i << " ";
    } // ^ the same as rrvec.show_contents()

    // Example usage for rrgen list (frontside insertion)
    rrgen::rrand<int, std::list, 10> rrlist;
    rrlist.gen_rrlist(false, true, "fside", 5, 25);
    std::cout << '\n'; rrlist.show_contents();
    std::cout << "Size: " << rrlist.contents().size() << '\n';

    // Example usage for rrgen array
    rrgen::rrand_array<int, 5> rrarr;
    rrarr.gen_rrarray(false, true, 5, 35);
    for (auto &i : rrarr.contents())
    {
        std::cout << i << " ";
    } // ^ the same as rrarr.show_contents()

    // Example usage for rrgen stack 
    rrgen::rrand_stack<float, 10> rrstack;
    rrstack.gen_rrstack(false, true, 200, 1000);
    for (auto m = rrstack.xsize(); m > 0; m--)
    {
        std::cout << rrstack.grab_top() << " ";
        rrstack.pop_off();
        if (m == 1) { std::cout << '\n'; }
    } 
}

```

Note: This is a transferred repository, from a completely unrelated project.

## License

MIT License  
Copyright (c) Josh Schiavone

## GitHub:

[https://github.com/josh0xA/rrgen](https://github.com/josh0xA/rrgen)
