Code Example: Hello World

This simple example can be used for checking whether your build system has been successfully setup to use the otacast library.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

#include <otacast/encoder.hpp>
#include <otacast/to_string.hpp>
#include <otacast/version.hpp>

int main()
{
    // Print the version of the library used
    std::cout << "version:      " << otacast::version() << "\n";

    // Create the encoder object with a specific finite field
    otacast::encoder encoder;

    otacast::finite_field field = otacast::finite_field::binary8;
    std::size_t block_bytes = 1024 * 1000; // 1 MB
    std::size_t symbol_bytes = 1500;
    std::size_t width = 5;

    encoder.configure(field, block_bytes, symbol_bytes, width);

    std::cout << "block_bytes:  " << encoder.block_bytes() << "\n";
    std::cout << "symbol_bytes: " << encoder.symbol_bytes() << "\n";
    std::cout << "width:        " << encoder.width() << "\n";
    std::cout << "symbols       " << encoder.symbols() << "\n";
    std::cout << "field         " << otacast::to_string(encoder.finite_field())
              << "\n";
    return 0;
}