All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Utility module

Provides general purpose utilities. More...

Classes

class  gears::utility::any
 A class that contains a type erased value. More...
 
class  gears::utility::invalid_base64
 Exception thrown when input string is invalid base64. More...
 
class  gears::utility::maybe< T >
 An optional data type. More...
 
struct  gears::utility::tribool
 Implements Kleene's logic for three-state booleans. More...
 
struct  gears::utility::triple< T, U, V >
 Implements a three-element tuple. More...
 

Functions

std::string gears::utility::base64::encode (const std::string &str)
 Encodes a string to base64. More...
 
std::string gears::utility::base64::decode (const std::string &str)
 Decodes a string from base64. More...
 
template<typename T , typename... Args>
constexpr std::array< T,
sizeof...(Args)> 
gears::utility::make_array (Args &&...args)
 Constructs an std::array instance. More...
 
template<typename T , typename... Args>
detail::unique_type< T >::single gears::utility::make_unique (Args &&...args)
 Constructs an std::unique_ptr instance. More...
 
template<typename T >
detail::unique_type< T >::array gears::utility::make_unique (size_t size)
  More...
 

Variables

constexpr indeterminate_t gears::utility::indeterminate {}
 Represents an indeterminate tribool value.
 

Detailed Description

This module provides utilities that are general enough to not belong in a specific module.

Function Documentation

std::string gears::utility::base64::decode ( const std::string &  str)
inline

Decodes a string from base64. If the input string is not in base64 then a gears::utility::invalid_base64 exception is thrown.

Parameters
strThe base64 string to decode.
Exceptions
gears::utility::invalid_base64Thrown when the input string is invalid.
Returns
The decoded string

Definition at line 121 of file base64.hpp.

std::string gears::utility::base64::encode ( const std::string &  str)
inline

Encodes a string to base64. The string to encode is done byte by byte. Padding is done through character =. The character for the 62nd index is + and the index for the 63rd index is /. There is no line limit imposed.

Parameters
strThe string to encode.
Returns
base64 encoded string.

Definition at line 62 of file base64.hpp.

template<typename T , typename... Args>
constexpr std::array<T, sizeof...(Args)> gears::utility::make_array ( Args &&...  args)

Constructs an std::array instance from the arguments provided of type T. This allows for quick generation of std::array instances similar to raw C arrays.

auto arr = utility::make_array<int>(1, 2, 3, 4, 5, 6, 7, 8);
// same as
// int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
Parameters
argsArguments to store into the array.
Template Parameters
TThe type of the array.
Returns
An std::array containing the elements provided.

Definition at line 67 of file utility/helpers.hpp.

template<typename T , typename... Args>
detail::unique_type<T>::single gears::utility::make_unique ( Args &&...  args)
inlinedelete

Constructs an std::unique_ptr instance from the arguments provided. This is the same function as std::make_unique which was added in C++14. Constructing a type with known bounds is forbidden.

Parameters
argsArguments to pass to the constructor of the type.
sizeThe size of the array to construct.
Template Parameters
TType to construct.
Returns
An std::unique_ptr containing the resource made.

Definition at line 85 of file utility/helpers.hpp.

template<typename T >
detail::unique_type<T>::array gears::utility::make_unique ( size_t  size)
inline

Definition at line 98 of file utility/helpers.hpp.