PionNetworkLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pion::algorithm Struct Reference

#include <algorithm.hpp>

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) More...
 
static std::string url_encode (const std::string &str)
 encodes strings so that they are safe for URLs (with%20spaces) More...
 
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 More...
 
static boost::int8_t to_int8 (unsigned char byte)
 convert sequence of one byte to 8-bit signed integer More...
 
static boost::uint8_t to_uint8 (char byte)
 convert sequence of one byte to 8-bit unsigned integer More...
 
static boost::int8_t to_int8 (char byte)
 convert sequence of one byte to 8-bit signed integer More...
 
static boost::uint16_t to_uint16 (unsigned char high, unsigned char low)
 convert sequence of two bytes to 16-bit unsigned integer More...
 
static boost::int16_t to_int16 (unsigned char high, unsigned char low)
 convert sequence of two bytes to 16-bit signed integer More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
template<typename Byte >
static boost::uint8_t to_uint8 (const Byte *buf)
 convert byte pointer into an 8-bit unsigned integer More...
 
template<typename Byte >
static boost::int8_t to_int8 (const Byte *buf)
 convert byte pointer into an 8-bit signed integer More...
 
template<typename Byte >
static boost::uint16_t to_uint16 (const Byte *buf)
 convert sequence of two bytes to 16-bit unsigned integer More...
 
template<typename Byte >
static boost::int16_t to_int16 (const Byte *buf)
 convert sequence of two bytes to 16-bit signed integer More...
 
template<typename Byte >
static boost::uint32_t to_uint24 (const Byte *buf)
 convert sequence of three bytes to 24-bit unsigned integer More...
 
template<typename Byte >
static boost::int32_t to_int24 (const Byte *buf)
 convert sequence of three bytes to 24-bit signed integer More...
 
template<typename Byte >
static boost::uint32_t to_uint32 (const Byte *buf)
 convert sequence of four bytes to 32-bit unsigned integer More...
 
template<typename Byte >
static boost::int32_t to_int32 (const Byte *buf)
 convert sequence of four bytes to 32-bit signed integer More...
 
template<typename Byte >
static boost::uint64_t to_uint64 (const Byte *buf)
 convert sequence of eight bytes to 64-bit unsigned integer More...
 
template<typename Byte >
static boost::int64_t to_int64 (const Byte *buf)
 convert sequence of eight bytes to 64-bit signed integer More...
 
template<typename Byte >
static void from_uint8 (Byte *buf, const boost::uint8_t n)
 convert 8-bit unsigned integer into sequence of one byte More...
 
template<typename Byte >
static void from_int8 (Byte *buf, const boost::int8_t n)
 convert 8-bit signed integer into sequence of one byte More...
 
template<typename Byte >
static void from_uint16 (Byte *buf, const boost::uint16_t n)
 convert 16-bit unsigned integer into sequence of two bytes More...
 
template<typename Byte >
static void from_int16 (Byte *buf, const boost::int16_t n)
 convert 16-bit signed integer into sequence of two bytes More...
 
template<typename Byte >
static void from_uint24 (Byte *buf, const boost::uint32_t n)
 convert 24-bit unsigned integer into sequence of three bytes More...
 
template<typename Byte >
static void from_int24 (Byte *buf, const boost::int32_t n)
 convert 24-bit signed integer into sequence of three bytes More...
 
template<typename Byte >
static void from_uint32 (Byte *buf, const boost::uint32_t n)
 convert 32-bit unsigned integer into sequence of four bytes More...
 
template<typename Byte >
static void from_int32 (Byte *buf, const boost::int32_t n)
 convert 32-bit signed integer into sequence of four bytes More...
 
template<typename Byte >
static void from_uint64 (Byte *buf, const boost::uint64_t n)
 convert 64-bit unsigned integer into sequence of eight bytes More...
 
template<typename Byte >
static void from_int64 (Byte *buf, const boost::int64_t n)
 convert 64-bit signed integer into sequence of eight bytes More...
 
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)
 

Static Public Attributes

static const char *const UTF8_REPLACEMENT_CHAR = "\xEF\xBF\xBD"
 3-byte character sequence representing the UTF-8 replacement character More...
 

Member Function Documentation

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

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

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,

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

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

References SHIFT_BITMASK.

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

References SHIFT_BITMASK.

template<typename Byte >
static void pion::algorithm::from_double ( Byte *  ptr,
const double  n 
)
inlinestatic

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

template<typename Byte >
static void pion::algorithm::from_float ( Byte *  ptr,
const float  n 
)
inlinestatic

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

template<typename Byte >
static void pion::algorithm::from_int16 ( Byte *  buf,
const boost::int16_t  n 
)
inlinestatic

convert 16-bit signed integer into sequence of two bytes

template<typename Byte >
static void pion::algorithm::from_int24 ( Byte *  buf,
const boost::int32_t  n 
)
inlinestatic

convert 24-bit signed integer into sequence of three bytes

template<typename Byte >
static void pion::algorithm::from_int32 ( Byte *  buf,
const boost::int32_t  n 
)
inlinestatic

convert 32-bit signed integer into sequence of four bytes

template<typename Byte >
static void pion::algorithm::from_int64 ( Byte *  buf,
const boost::int64_t  n 
)
inlinestatic

convert 64-bit signed integer into sequence of eight bytes

template<typename Byte >
static void pion::algorithm::from_int8 ( Byte *  buf,
const boost::int8_t  n 
)
inlinestatic

convert 8-bit signed integer into sequence of one byte

template<typename Byte >
static void pion::algorithm::from_long_double ( Byte *  ptr,
const long double  n 
)
inlinestatic

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

template<typename Byte >
static void pion::algorithm::from_uint16 ( Byte *  buf,
const boost::uint16_t  n 
)
inlinestatic

convert 16-bit unsigned integer into sequence of two bytes

template<typename Byte >
static void pion::algorithm::from_uint24 ( Byte *  buf,
const boost::uint32_t  n 
)
inlinestatic

convert 24-bit unsigned integer into sequence of three bytes

template<typename Byte >
static void pion::algorithm::from_uint32 ( Byte *  buf,
const boost::uint32_t  n 
)
inlinestatic

convert 32-bit unsigned integer into sequence of four bytes

template<typename Byte >
static void pion::algorithm::from_uint64 ( Byte *  buf,
const boost::uint64_t  n 
)
inlinestatic

convert 64-bit unsigned integer into sequence of eight bytes

template<typename Byte >
static void pion::algorithm::from_uint8 ( Byte *  buf,
const boost::uint8_t  n 
)
inlinestatic

convert 8-bit unsigned integer into sequence of one byte

template<typename Byte >
static double pion::algorithm::to_double ( const Byte *  ptr)
inlinestatic

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

template<typename Byte >
static float pion::algorithm::to_float ( const Byte *  ptr)
inlinestatic

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

static boost::int16_t pion::algorithm::to_int16 ( unsigned char  high,
unsigned char  low 
)
inlinestatic

convert sequence of two bytes to 16-bit signed integer

template<typename T1 , typename T2 >
static boost::int16_t pion::algorithm::to_int16 ( T1  high,
T2  low 
)
inlinestatic

convert sequence of two bytes to 16-bit signed integer

template<typename Byte >
static boost::int16_t pion::algorithm::to_int16 ( const Byte *  buf)
inlinestatic

convert sequence of two bytes to 16-bit signed integer

static boost::int32_t pion::algorithm::to_int24 ( unsigned char  high,
unsigned char  mid,
unsigned char  low 
)
inlinestatic

convert sequence of three bytes to 24-bit signed integer

template<typename T1 , typename T2 , typename T3 >
static boost::int32_t pion::algorithm::to_int24 ( T1  high,
T2  mid,
T3  low 
)
inlinestatic

convert sequence of three bytes to 24-bit signed integer

template<typename Byte >
static boost::int32_t pion::algorithm::to_int24 ( const Byte *  buf)
inlinestatic

convert sequence of three bytes to 24-bit signed integer

static boost::int32_t pion::algorithm::to_int32 ( unsigned char  high,
unsigned char  mid1,
unsigned char  mid2,
unsigned char  low 
)
inlinestatic

convert sequence of four bytes to 32-bit signed integer

template<typename T1 , typename T2 , typename T3 , typename T4 >
static boost::int32_t pion::algorithm::to_int32 ( T1  high,
T2  mid1,
T3  mid2,
T4  low 
)
inlinestatic

convert sequence of four bytes to 32-bit signed integer

template<typename Byte >
static boost::int32_t pion::algorithm::to_int32 ( const Byte *  buf)
inlinestatic

convert sequence of four bytes to 32-bit signed integer

static boost::int64_t pion::algorithm::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 
)
inlinestatic

convert sequence of eight bytes to 64-bit signed integer

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
static boost::int64_t pion::algorithm::to_int64 ( T1  high,
T2  mid1,
T3  mid2,
T4  mid3,
T5  mid4,
T6  mid5,
T7  mid6,
T8  low 
)
inlinestatic

convert sequence of eight bytes to 64-bit signed integer

template<typename Byte >
static boost::int64_t pion::algorithm::to_int64 ( const Byte *  buf)
inlinestatic

convert sequence of eight bytes to 64-bit signed integer

static boost::int8_t pion::algorithm::to_int8 ( unsigned char  byte)
inlinestatic

convert sequence of one byte to 8-bit signed integer

static boost::int8_t pion::algorithm::to_int8 ( char  byte)
inlinestatic

convert sequence of one byte to 8-bit signed integer

template<typename Byte >
static boost::int8_t pion::algorithm::to_int8 ( const Byte *  buf)
inlinestatic

convert byte pointer into an 8-bit signed integer

template<typename Byte >
static long double pion::algorithm::to_long_double ( const Byte *  ptr)
inlinestatic

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

static boost::uint16_t pion::algorithm::to_uint16 ( unsigned char  high,
unsigned char  low 
)
inlinestatic

convert sequence of two bytes to 16-bit unsigned integer

Referenced by pion::spdy::parser::is_spdy_control_frame(), pion::spdy::parser::parse_header_payload(), and pion::spdy::parser::populate_frame().

template<typename T1 , typename T2 >
static boost::uint16_t pion::algorithm::to_uint16 ( T1  high,
T2  low 
)
inlinestatic

convert sequence of two bytes to 16-bit unsigned integer

template<typename Byte >
static boost::uint16_t pion::algorithm::to_uint16 ( const Byte *  buf)
inlinestatic

convert sequence of two bytes to 16-bit unsigned integer

static boost::uint32_t pion::algorithm::to_uint24 ( unsigned char  high,
unsigned char  mid,
unsigned char  low 
)
inlinestatic

convert sequence of three bytes to 24-bit unsigned integer

template<typename T1 , typename T2 , typename T3 >
static boost::uint32_t pion::algorithm::to_uint24 ( T1  high,
T2  mid,
T3  low 
)
inlinestatic

convert sequence of three bytes to 24-bit unsigned integer

template<typename Byte >
static boost::uint32_t pion::algorithm::to_uint24 ( const Byte *  buf)
inlinestatic

convert sequence of three bytes to 24-bit unsigned integer

static boost::uint32_t pion::algorithm::to_uint32 ( unsigned char  high,
unsigned char  mid1,
unsigned char  mid2,
unsigned char  low 
)
inlinestatic
template<typename T1 , typename T2 , typename T3 , typename T4 >
static boost::uint32_t pion::algorithm::to_uint32 ( T1  high,
T2  mid1,
T3  mid2,
T4  low 
)
inlinestatic

convert sequence of four bytes to 32-bit unsigned integer

template<typename Byte >
static boost::uint32_t pion::algorithm::to_uint32 ( const Byte *  buf)
inlinestatic

convert sequence of four bytes to 32-bit unsigned integer

static boost::uint64_t pion::algorithm::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 
)
inlinestatic

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::uint64_t pion::algorithm::to_uint64 ( T1  high,
T2  mid1,
T3  mid2,
T4  mid3,
T5  mid4,
T6  mid5,
T7  mid6,
T8  low 
)
inlinestatic

convert sequence of eight bytes to 64-bit unsigned integer

template<typename Byte >
static boost::uint64_t pion::algorithm::to_uint64 ( const Byte *  buf)
inlinestatic

convert sequence of eight bytes to 64-bit unsigned integer

static boost::uint8_t pion::algorithm::to_uint8 ( unsigned char  byte)
inlinestatic

convert sequence of one byte to 8-bit unsigned integer

static boost::uint8_t pion::algorithm::to_uint8 ( char  byte)
inlinestatic

convert sequence of one byte to 8-bit unsigned integer

template<typename Byte >
static boost::uint8_t pion::algorithm::to_uint8 ( const Byte *  buf)
inlinestatic

convert byte pointer into an 8-bit unsigned integer

std::string pion::algorithm::url_decode ( const std::string &  str)
static

escapes URL-encoded strings (a%20value+with%20spaces)

Referenced by pion::http::plugin_service::get_relative_resource().

std::string pion::algorithm::url_encode ( const std::string &  str)
static

encodes strings so that they are safe for URLs (with%20spaces)

Referenced by pion::http::types::make_query_string().

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)

References UTF8_REPLACEMENT_CHAR.

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

Member Data Documentation

const char *const pion::algorithm::UTF8_REPLACEMENT_CHAR = "\xEF\xBF\xBD"
static

3-byte character sequence representing the UTF-8 replacement character

Referenced by xml_encode().


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