pion::algorithm Struct Reference

## Static Public Member Functions

static bool | base64_decode (std::string const &input, std::string &output)
static bool | base64_encode (std::string const &input, std::string &output)
static std::string | url_decode (const std::string &str)
| escapes URL-encoded strings (a%20value+with%20spaces)
static std::string | url_encode (const std::string &str)
| encodes strings so that they are safe for URLs (with%20spaces)
static std::string | xml_encode (const std::string &str)
| TODO: escapes XML/HTML-encoded strings (1 < 2) More...
static void | float_from_bytes (long double &value, const unsigned char *ptr, size_t num_exp_bits, size_t num_fraction_bits)
static void | float_to_bytes (long double value, unsigned char *ptr, size_t num_exp_bits, size_t num_fraction_bits)
static boost::uint8_t | to_uint8 (unsigned char byte)
| convert sequence of one byte to 8-bit unsigned integer
static boost::int8_t | to_int8 (unsigned char byte)
| convert sequence of one byte to 8-bit signed integer
static boost::uint8_t | to_uint8 (char byte)
| convert sequence of one byte to 8-bit unsigned integer
static boost::int8_t | to_int8 (char byte)
| convert sequence of one byte to 8-bit signed integer
static boost::uint16_t | to_uint16 (unsigned char high, unsigned char low)
| convert sequence of two bytes to 16-bit unsigned integer
static boost::int16_t | to_int16 (unsigned char high, unsigned char low)
| convert sequence of two bytes to 16-bit signed integer
static boost::uint32_t | to_uint24 (unsigned char high, unsigned char mid, unsigned char low)
| convert sequence of three bytes to 24-bit unsigned integer
static boost::int32_t | to_int24 (unsigned char high, unsigned char mid, unsigned char low)
| convert sequence of three bytes to 24-bit signed integer
static boost::uint32_t | to_uint32 (unsigned char high, unsigned char mid1, unsigned char mid2, unsigned char low)
| convert sequence of four bytes to 32-bit unsigned integer
static boost::int32_t | to_int32 (unsigned char high, unsigned char mid1, unsigned char mid2, unsigned char low)
| convert sequence of four bytes to 32-bit signed integer
static boost::uint64_t | to_uint64 (unsigned char high, unsigned char mid1, unsigned char mid2, unsigned char mid3, unsigned char mid4, unsigned char mid5, unsigned char mid6, unsigned char low)
| convert sequence of eight bytes to 64-bit unsigned integer
static boost::int64_t | to_int64 (unsigned char high, unsigned char mid1, unsigned char mid2, unsigned char mid3, unsigned char mid4, unsigned char mid5, unsigned char mid6, unsigned char low)
| convert sequence of eight bytes to 64-bit signed integer
template<typename T1 , typename T2 >
static boost::uint16_t | to_uint16 (T1 high, T2 low)
| convert sequence of two bytes to 16-bit unsigned integer
template<typename T1 , typename T2 >
static boost::int16_t | to_int16 (T1 high, T2 low)
| convert sequence of two bytes to 16-bit signed integer
template<typename T1 , typename T2 , typename T3 >
static boost::uint32_t | to_uint24 (T1 high, T2 mid, T3 low)
| convert sequence of three bytes to 24-bit unsigned integer
template<typename T1 , typename T2 , typename T3 >
static boost::int32_t | to_int24 (T1 high, T2 mid, T3 low)
| convert sequence of three bytes to 24-bit signed integer
template<typename T1 , typename T2 , typename T3 , typename T4 >
static boost::uint32_t | to_uint32 (T1 high, T2 mid1, T3 mid2, T4 low)
| convert sequence of four bytes to 32-bit unsigned integer
template<typename T1 , typename T2 , typename T3 , typename T4 >
static boost::int32_t | to_int32 (T1 high, T2 mid1, T3 mid2, T4 low)
| convert sequence of four bytes to 32-bit signed integer
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
static boost::uint64_t | to_uint64 (T1 high, T2 mid1, T3 mid2, T4 mid3, T5 mid4, T6 mid5, T7 mid6, T8 low)
| convert sequence of eight bytes to 64-bit unsigned integer
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
static boost::int64_t | to_int64 (T1 high, T2 mid1, T3 mid2, T4 mid3, T5 mid4, T6 mid5, T7 mid6, T8 low)
| convert sequence of eight bytes to 64-bit signed integer
template<typename Byte >
static boost::uint8_t | to_uint8 (const Byte *buf)
| convert byte pointer into an 8-bit unsigned integer
template<typename Byte >
static boost::int8_t | to_int8 (const Byte *buf)
| convert byte pointer into an 8-bit signed integer
template<typename Byte >
static boost::uint16_t | to_uint16 (const Byte *buf)
| convert sequence of two bytes to 16-bit unsigned integer
template<typename Byte >
static boost::int16_t | to_int16 (const Byte *buf)
| convert sequence of two bytes to 16-bit signed integer
template<typename Byte >
static boost::uint32_t | to_uint24 (const Byte *buf)
| convert sequence of three bytes to 24-bit unsigned integer
template<typename Byte >
static boost::int32_t | to_int24 (const Byte *buf)
| convert sequence of three bytes to 24-bit signed integer
template<typename Byte >
static boost::uint32_t | to_uint32 (const Byte *buf)
| convert sequence of four bytes to 32-bit unsigned integer
template<typename Byte >
static boost::int32_t | to_int32 (const Byte *buf)
| convert sequence of four bytes to 32-bit signed integer
template<typename Byte >
static boost::uint64_t | to_uint64 (const Byte *buf)
| convert sequence of eight bytes to 64-bit unsigned integer
template<typename Byte >
static boost::int64_t | to_int64 (const Byte *buf)
| convert sequence of eight bytes to 64-bit signed integer
template<typename Byte >
static void | from_uint8 (Byte *buf, const boost::uint8_t n)
| convert 8-bit unsigned integer into sequence of one byte
template<typename Byte >
static void | from_int8 (Byte *buf, const boost::int8_t n)
| convert 8-bit signed integer into sequence of one byte
template<typename Byte >
static void | from_uint16 (Byte *buf, const boost::uint16_t n)
| convert 16-bit unsigned integer into sequence of two bytes
template<typename Byte >
static void | from_int16 (Byte *buf, const boost::int16_t n)
| convert 16-bit signed integer into sequence of two bytes
template<typename Byte >
static void | from_uint24 (Byte *buf, const boost::uint32_t n)
| convert 24-bit unsigned integer into sequence of three bytes
template<typename Byte >
static void | from_int24 (Byte *buf, const boost::int32_t n)
| convert 24-bit signed integer into sequence of three bytes
template<typename Byte >
static void | from_uint32 (Byte *buf, const boost::uint32_t n)
| convert 32-bit unsigned integer into sequence of four bytes
template<typename Byte >
static void | from_int32 (Byte *buf, const boost::int32_t n)
| convert 32-bit signed integer into sequence of four bytes
template<typename Byte >
static void | from_uint64 (Byte *buf, const boost::uint64_t n)
| convert 64-bit unsigned integer into sequence of eight bytes
template<typename Byte >
static void | from_int64 (Byte *buf, const boost::int64_t n)
| convert 64-bit signed integer into sequence of eight bytes
template<typename Byte >
static float | to_float (const Byte *ptr)
template<typename Byte >
static double | to_double (const Byte *ptr)
template<typename Byte >
static long double | to_long_double (const Byte *ptr)
template<typename Byte >
static void | from_float (Byte *ptr, const float n)
template<typename Byte >
static void | from_double (Byte *ptr, const double n)
template<typename Byte >
static void | from_long_double (Byte *ptr, const long double n)

## Detailed Description

Definition at line 19 of file algorithm.hpp.

## Member Function Documentation

## base64_decode()

bool pion::algorithm::base64_decode | ( | std::string const & | input,
|  | std::string & | output
| ) |  |

static

base64 decoding

Parameters

  input | - base64 encoded string
  output | - decoded string ( may include non-text chars)

Returns
  true if successful, false if input string contains non-base64 symbols

Definition at line 24 of file algorithm.cpp.

Referenced by pion::http::basic_auth::parse_credentials().

## base64_encode()

bool pion::algorithm::base64_encode | ( | std::string const & | input,
|  | std::string & | output
| ) |  |

static

base64 encoding

Parameters

  input | - arbitrary string ( may include non-text chars)
  output | - base64 encoded string

Returns
  true if successful,

Definition at line 104 of file algorithm.cpp.

Referenced by pion::http::cookie_auth::process_login().

## float_from_bytes()

void pion::algorithm::float_from_bytes | ( | long double & | value,
|  | const unsigned char * | ptr,
|  | size_t | num_exp_bits,
|  | size_t | num_fraction_bits
| ) |  |

static

convert sequence of bytes in IEEE 754 format into a native floating point data type reference: http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Definition at line 319 of file algorithm.cpp.

## float_to_bytes()

void pion::algorithm::float_to_bytes | ( | long double | value,
|  | unsigned char * | ptr,
|  | size_t | num_exp_bits,
|  | size_t | num_fraction_bits
| ) |  |

static

convert native floating point type into a sequence of bytes in IEEE 754 format reference: http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Definition at line 350 of file algorithm.cpp.

## from_double()

template<typename Byte >

static void pion::algorithm::from_double | ( | Byte * | ptr,
|  | const double | n
| ) |  |

inline static

convert double into sequence of eight bytes in "double precision" binary64 format http://en.wikipedia.org/wiki/Double_precision_floating-point_format

Definition at line 375 of file algorithm.hpp.

## from_float()

template<typename Byte >

static void pion::algorithm::from_float | ( | Byte * | ptr,
|  | const float | n
| ) |  |

inline static

convert float into sequence of four bytes in "single precision" binary32 format http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Definition at line 368 of file algorithm.hpp.

## from_long_double()

template<typename Byte >

static void pion::algorithm::from_long_double | ( | Byte * | ptr,
|  | const long double | n
| ) |  |

inline static

convert long double into sequence of sixteen bytes in 128-bit "quadruple precision" format http://en.wikipedia.org/wiki/Quadruple_precision_floating-point_format

Definition at line 382 of file algorithm.hpp.

## to_double()

template<typename Byte >

static double pion::algorithm::to_double | ( | const Byte * | ptr | ) |

inline static

convert sequence of eight bytes in 64-bit "double precision" binary64 format into a double http://en.wikipedia.org/wiki/Double_precision_floating-point_format

Definition at line 350 of file algorithm.hpp.

## to_float()

template<typename Byte >

static float pion::algorithm::to_float | ( | const Byte * | ptr | ) |

inline static

convert sequence of four bytes in 32-bit "single precision" binary32 format into a float http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Definition at line 341 of file algorithm.hpp.

## to_long_double()

template<typename Byte >

static long double pion::algorithm::to_long_double | ( | const Byte * | ptr | ) |

inline static

convert sequence of sixteen bytes in 128-bit "quadruple precision" format into a long double http://en.wikipedia.org/wiki/Quadruple_precision_floating-point_format

Definition at line 359 of file algorithm.hpp.

## xml_encode()

std::string pion::algorithm::xml_encode | ( | const std::string & | str | ) |

static

TODO: escapes XML/HTML-encoded strings (1 < 2)

encodes strings so that they are safe for XML/HTML (2 > 1)

Definition at line 235 of file algorithm.cpp.

Referenced by pion::http::server::handle_forbidden_request(), pion::http::server::handle_method_not_allowed(), pion::http::server::handle_not_found_request(), pion::http::server::handle_server_error(), and pion::plugins::FileService::operator()().

The documentation for this struct was generated from the following files:

- include/pion/algorithm.hpp
- src/algorithm.cpp