block/include/nil/crypto3/detail/pack.hpp File Reference
#include <nil/crypto3/detail/type_traits.hpp>
#include <nil/crypto3/detail/stream_endian.hpp>
#include <nil/crypto3/detail/exploder.hpp>
#include <nil/crypto3/detail/imploder.hpp>
#include <nil/crypto3/detail/reverser.hpp>
#include <nil/crypto3/detail/predef.hpp>
#include <boost/static_assert.hpp>
#include <boost/predef/other/endian.h>
#include <boost/predef/architecture.h>
#include <algorithm>
#include <climits>
#include <iterator>
#include <type_traits>
+ Include dependency graph for block/include/nil/crypto3/detail/pack.hpp:

Go to the source code of this file.

Classes

struct  nil::crypto3::detail::can_memcpy< Endianness, InputBits, OutputBits, InT, OutT >
 can_memcpy trait is derived from host_can_memcpy trait and is invoked depending on data endianness. Note that there is a single endianness template parameter since otherwise we have to transform data in accordance with endianness conversion rules. More...
 
struct  nil::crypto3::detail::can_memcpy< stream_endian::host_unit< UnitBits >, InputBits, OutputBits, InT, OutT >
 
struct  nil::crypto3::detail::host_can_memcpy< UnitBits, InputBits, OutputBits, InT, OutT >
 The group of traits below is used to determine the possibility of fast data copy. By fast data copy we mean that the data is stored contiguously in the memory, so it can be copied faster byte-by-byte. Currently, fast data copy is implemented by memcpy function call. More...
 
struct  nil::crypto3::detail::packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, InputType, OutputType >
 This packer deals with arbitrary input and output (but not bool) data elements. More...
 
struct  nil::crypto3::detail::packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, bool, bool >
 This packer deals with bool input and output data elements. More...
 
struct  nil::crypto3::detail::packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, bool, OutputType >
 This packer deals with bool input data and arbitrary (but not bool) output data elements. More...
 
struct  nil::crypto3::detail::packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, InputType, bool >
 This packer deals with arbitrary (but not bool) input data and bool output data elements. More...
 
struct  nil::crypto3::detail::real_packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, InputType, OutputType, SameEndianness, Implode, Explode >
 Real_packer is used to transform input data divided into chunks of the bit size InputValueBits represented in input endianness (InputEndianness) into output data (of the same bit length) divided into chunks of the bit size OutputValueBits represented in output endianness (OutputEndianness). More...
 
struct  nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >
 This real_packer deals with the case of equal sizes (i.e. InputValueBits == OutputValueBits) and same endianness representations (i.e., speaking informally, InputEndianness == OutputEndianness). It packs input elements with ValueBits size represented in Endianness endianness into output elements with the same ValueBits size represented in the same Endianness endianness. More...
 
struct  nil::crypto3::detail::real_packer< InputEndian< UnitBits >, OutputEndian< UnitBits >, ValueBits, ValueBits, InputType, OutputType, false, false, false >
 This real_packer deals with the case of equal sizes (i.e. InputValueBits == OutputValueBits) and different endianness representations (or, speaking informally, InputEndianness != OutputEndianness). It invokes functions which pack input elements with ValueBits size represented in InputEndianness endianness into output elements with the same ValueBits size represented in another OutputEndianness endianness. More...
 
struct  nil::crypto3::detail::real_packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, InputType, OutputType, SameEndianness, false, true >
 This real_packer deals with case InputValueBits > OutputValueBits and invokes explode function, which, in its turn, packs input elements with InputValueBits size represented in InputEndianness endianness into output elements with OutputValueBits size represented in OutputEndianness endianness. More...
 
struct  nil::crypto3::detail::real_packer< InputEndianness, OutputEndianness, InputValueBits, OutputValueBits, InputType, OutputType, SameEndianness, true, false >
 This real_packer deals with case InputValueBits < OutputValueBits and invokes implode function, which, in its turn, packs input elements with InputValueBits size represented in InputEndianness endianness into output elements with OutputValueBits size represented in OutputEndianness endianness. More...
 

Namespaces

 nil
 
 nil::crypto3
 
 nil::crypto3::detail
 

Functions

template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputType , typename OutputType >
void nil::crypto3::detail::pack (const InputType &in, OutputType &out)
 Packs immutable data referenced by in into data referenced by out. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename InCatT , typename OutputIterator , typename = typename std::enable_if<nil::crypto3::detail::is_iterator<InputIterator>::value>::type, typename = typename std::enable_if<nil::crypto3::detail::is_iterator<OutputIterator>::value>::type>
void nil::crypto3::detail::pack (InputIterator first, InputIterator last, InCatT, OutputIterator out)
 Packs elements from the range [first, last) into elements starting from out. Works for input containers meeting InCatT category requirements and output containers meeting OutputIterator requirements. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator , typename = typename std::enable_if<nil::crypto3::detail::is_iterator<OutputIterator>::value>::type>
void nil::crypto3::detail::pack (InputIterator first, InputIterator last, OutputIterator out)
 Generic function that chooses pack function depending on input iterator category. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputType , typename = typename std::enable_if<!std::is_arithmetic<OutputType>::value>::type>
void nil::crypto3::detail::pack (InputIterator first, InputIterator last, OutputType &out)
 Packs elements from range [first, last) into data referenced by out with non-arithmetic value type. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack (InputIterator first, InputIterator last, std::random_access_iterator_tag, OutputIterator out)
 Packs elements from the range [first, last) into elements starting from out. Works for input containers meeting RandomAccessIterator requirements. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename InCatT , typename OutputIterator , typename OutCatT >
void nil::crypto3::detail::pack (InputIterator in_first, InputIterator in_last, InCatT, OutputIterator out, OutputIterator, OutCatT)
 Packs elements from the range [first, last) into elements starting from out. Works for input containers meeting InCatT category requirements and output containers meeting OutCatT category requirements. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack (InputIterator in_first, InputIterator in_last, OutputIterator out_first, OutputIterator out_last)
 Generic function that chooses pack function depending on input and output iterator category. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack (InputIterator in_first, InputIterator in_last, std::random_access_iterator_tag, OutputIterator out_first, OutputIterator out_last, std::random_access_iterator_tag)
 Packs elements from the range [first, last) into elements starting from out. Works for input and output containers meeting RandomAccessIterator requirements. More...
 
template<typename InputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputRange , typename OutputIterator >
void nil::crypto3::detail::pack_from (const InputRange &r, OutputIterator out)
 Packs elements from range [first, last) represented in InputEndianness endianness into elements starting from out represented in machine-dependent endianness. More...
 
template<typename InputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack_from (InputIterator first, InputIterator last, OutputIterator out)
 Packs elements from range [first, last) represented in InputEndianness endianness into elements starting from out represented in machine-dependent endianness. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack_n (InputIterator in, std::size_t in_n, OutputIterator out)
 Packs in_n input elements starting from in into output elements beginning from out. More...
 
template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack_n (InputIterator in, std::size_t in_n, OutputIterator out, std::size_t out_n)
 Packs in_n input elements starting from in into in_out elements beginning from out. More...
 
template<typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputRange , typename OutputIterator >
void nil::crypto3::detail::pack_to (const InputRange &r, OutputIterator out)
 Packs elements from range [first, last) represented in machine-dependent endianness into elements starting from out represented in OutputEndianness endianness. More...
 
template<typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator >
void nil::crypto3::detail::pack_to (InputIterator first, InputIterator last, OutputIterator out)
 Packs elements from range [first, last) represented in machine-dependent endianness into elements starting from out represented in OutputEndianness endianness. More...