Skip to content

Namespace cowboys::base64

Namespace List > cowboys > base64

A namespace for base64 encoding and decoding. Does not convert to and frombase64 in the typical way. Only guarantees that x == b64_inv(b64(x)), aside from doubles which have problems with precision, so x ~= b64_inv(b64(x)).

Public Static Attributes

Type Name
constexpr char CHARS = = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"
The characters used to represent digits in base64 .
constexpr std::array< size_t, MAX_CHAR+1 > CHAR_TO_IDX = = {
std::array<size_t, MAX_CHAR + 1> indices{};
for (size_t i = 0; i < 64; ++i) {
indices[CHARS[i]] = i;
}
return indices;
}()
constexpr size_t MAX_CHAR = = *std::max_element(CHARS, CHARS + 64)

Public Static Functions

Type Name
std::string B2ToB64 (const std::string & binary)
Converts a binary string to a base64 string.
std::string B64ToB2 (std::string base64)
Converts a base64 string to a binary string.
double B64ToDouble (const std::string & value)
Converts a base64 string to a double. See DoubleToB64 for precision issues.
size_t B64ToULL (std::string num_base64)
Converts a number in base64 to base10.
std::string DoubleToB64 (double value)
Converts a double to a base64 string. Assumes that the stoull(to_string(value)) is possible. Only guarantees that x ~= b64_inv(b64(x)) due to precision errors. Empirically accurate up to 3 decimal places, e.g. round(x, 3) = round(b64_inv(b64(x)), 3).
std::string ULLToB64 (size_t ull)
Converts a number in base10 to base64 .

Public Static Attributes Documentation

variable CHARS

constexpr char CHARS[];

variable CHAR_TO_IDX

constexpr std::array<size_t, MAX_CHAR + 1> CHAR_TO_IDX;

variable MAX_CHAR

constexpr size_t MAX_CHAR;

Public Static Functions Documentation

function B2ToB64

Converts a binary string to a base64 string.

static std::string cowboys::base64::B2ToB64 (
    const std::string & binary
) 

Parameters:

  • binary A string of 1s and 0s representing binary.

Returns:

The binary string in base64.

function B64ToB2

Converts a base64 string to a binary string.

static std::string cowboys::base64::B64ToB2 (
    std::string base64
) 

Parameters:

Returns:

The base64 string in binary.

function B64ToDouble

Converts a base64 string to a double. See DoubleToB64 for precision issues.

static double cowboys::base64::B64ToDouble (
    const std::string & value
) 

Parameters:

  • value The base64 string to convert.

Returns:

The base64 string as a double.

function B64ToULL

Converts a number in base64 to base10.

static size_t cowboys::base64::B64ToULL (
    std::string num_base64
) 

Parameters:

  • num_base64 The number in base64 as a string.

Returns:

The number in base10.

function DoubleToB64

Converts a double to a base64 string. Assumes that the stoull(to_string(value)) is possible. Only guarantees that x ~= b64_inv(b64(x)) due to precision errors. Empirically accurate up to 3 decimal places, e.g. round(x, 3) = round(b64_inv(b64(x)), 3).

static std::string cowboys::base64::DoubleToB64 (
    double value
) 

Parameters:

  • value The double to convert.

Returns:

The double in base64.

function ULLToB64

Converts a number in base10 to base64 .

static std::string cowboys::base64::ULLToB64 (
    size_t ull
) 

Parameters:

  • ull The number to convert.

Returns:

The number in base64 as a string.


The documentation for this class was generated from the following file source/Agents/GP/CGPGenotype.hpp