Pack functions

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::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...
 

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<detail::is_iterator<InputIterator>::value>::type, typename = typename std::enable_if<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 InputIterator , typename InCatT , typename OutputIterator , typename OutCatT >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack (InputIterator first, InputIterator last, InCatT, OutputIterator out, OutCatT)
 Packs elements in range [first, last) into elements iterated by out. This function is invoked only if input or output iterator doesn't meet RandomAccessIterator requirements. More...
 
template<typename InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack (InputIterator first, InputIterator last, OutputIterator out)
 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 , typename = typename std::enable_if<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 InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack (InputIterator first, InputIterator last, std::random_access_iterator_tag, OutputIterator out, std::random_access_iterator_tag)
 Packs elements in range [first, last) into elements iterated by out. This function is invoked only if input and output iterators meet RandomAccessIterator requirements. However, the restriction can be weakened to ContiguousIterator usage. 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 InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n (InputIterator in, std::size_t in_n, OutputIterator out)
 Packs in_n elements iterated by in into elements iterated by 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)
 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<std::size_t InputValueBits, std::size_t OutputValueBits>
static std::enable_if< can_memcpy< Endianness, InputValueBits, OutputValueBits, InputType, OutputType >::value >::type nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n (InputType *in, std::size_t n, OutputType *out)
 Packs n InputType elements pointed by pointer in into OutType elements pointed by out. This function is invoked only if memcpy call is possible. More...
 
template<std::size_t InputValueBits, std::size_t OutputValueBits>
static std::enable_if< can_memcpy< Endianness, InputValueBits, OutputValueBits, InputType, OutputType >::value >::type nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n (InputType const *in, std::size_t n, OutputType *out)
 Packs n InputType elements pointed by constant pointer in (which, hence, cannot be iterated) into OutType elements pointed by out. This function is invoked only if memcpy call is possible. 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...
 

Detailed Description

Function Documentation

◆ pack() [1/11]

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 
)
inline

Packs immutable data referenced by in into data referenced by out.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputType
OutputType
Parameters
in
out
Returns

◆ pack() [2/11]

template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename InCatT , typename OutputIterator , typename = typename std::enable_if<detail::is_iterator<InputIterator>::value>::type, typename = typename std::enable_if<detail::is_iterator<OutputIterator>::value>::type>
void nil::crypto3::detail::pack ( InputIterator  first,
InputIterator  last,
InCatT  ,
OutputIterator  out 
)
inline

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.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
InCatT
OutputIterator
Parameters
first
last
InCatT
out
Returns

◆ pack() [3/11]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<typename InputIterator , typename InCatT , typename OutputIterator , typename OutCatT >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack ( InputIterator  first,
InputIterator  last,
InCatT  ,
OutputIterator  out,
OutCatT   
)
inlinestatic

Packs elements in range [first, last) into elements iterated by out. This function is invoked only if input or output iterator doesn't meet RandomAccessIterator requirements.

Template Parameters
InputIterator
InCatT
OutputIterator
OutCatT
Parameters
first
last
InCatT
out
OutCatT
Returns

◆ pack() [4/11]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<typename InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack ( InputIterator  first,
InputIterator  last,
OutputIterator  out 
)
inlinestatic

Generic function that chooses pack function depending on input and output iterator category.

Template Parameters
InputIterator
OutputIterator
Parameters
first
last
out
Returns

◆ pack() [5/11]

template<typename InputEndianness , typename OutputEndianness , std::size_t InputValueBits, std::size_t OutputValueBits, typename InputIterator , typename OutputIterator , typename = typename std::enable_if<detail::is_iterator<OutputIterator>::value>::type>
void nil::crypto3::detail::pack ( InputIterator  first,
InputIterator  last,
OutputIterator  out 
)
inline

Generic function that chooses pack function depending on input iterator category.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
out
Returns

◆ pack() [6/11]

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 
)
inline

Packs elements from range [first, last) into data referenced by out with non-arithmetic value type.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputType
OutputType
Parameters
in
out
Returns

◆ pack() [7/11]

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 
)
inline

Packs elements from the range [first, last) into elements starting from out. Works for input containers meeting RandomAccessIterator requirements.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
random_access_iterator_tag
out
Returns

◆ pack() [8/11]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<typename InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack ( InputIterator  first,
InputIterator  last,
std::random_access_iterator_tag  ,
OutputIterator  out,
std::random_access_iterator_tag   
)
inlinestatic

Packs elements in range [first, last) into elements iterated by out. This function is invoked only if input and output iterators meet RandomAccessIterator requirements. However, the restriction can be weakened to ContiguousIterator usage.

Template Parameters
InputIterator
OutputIterator
Parameters
first
last
random_access_iterator_tag
out
random_access_iterator_tag
Returns

◆ pack() [9/11]

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   
)
inline

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.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
InCatT
OutputIterator
OutCatT
Parameters
in_first
in_last
InCatT
out
OutputIterator
OutCatT
Returns

◆ pack() [10/11]

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 
)
inline

Generic function that chooses pack function depending on input and output iterator category.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
in_first
in_last
out_first
out_last
Returns

◆ pack() [11/11]

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   
)
inline

Packs elements from the range [first, last) into elements starting from out. Works for input and output containers meeting RandomAccessIterator requirements.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
in_first
in_last
random_access_iterator_tag
out_first
out_last
random_access_iterator_tag
Returns

◆ pack_from() [1/2]

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 
)
inline

Packs elements from range [first, last) represented in InputEndianness endianness into elements starting from out represented in machine-dependent endianness.

Template Parameters
InputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
out
Returns

◆ pack_from() [2/2]

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 
)
inline

Packs elements from range [first, last) represented in InputEndianness endianness into elements starting from out represented in machine-dependent endianness.

Template Parameters
InputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
out
Returns

◆ pack_n() [1/5]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<typename InputIterator , typename OutputIterator >
static void nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n ( InputIterator  in,
std::size_t  in_n,
OutputIterator  out 
)
inlinestatic

Packs in_n elements iterated by in into elements iterated by out.

Template Parameters
InputIterator
OutputIterator
Parameters
in
in_n
out
Returns

◆ pack_n() [2/5]

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 
)
inline

Packs in_n input elements starting from in into output elements beginning from out.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
in
in_n
out
Returns

◆ pack_n() [3/5]

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 
)
inline

Packs in_n input elements starting from in into in_out elements beginning from out.

Template Parameters
InputEndianness
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
in
in_n
out
out_n
Returns

◆ pack_n() [4/5]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<std::size_t InputValueBits, std::size_t OutputValueBits>
static std::enable_if< can_memcpy<Endianness, InputValueBits, OutputValueBits, InputType, OutputType>::value>::type nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n ( InputType *  in,
std::size_t  n,
OutputType *  out 
)
inlinestatic

Packs n InputType elements pointed by pointer in into OutType elements pointed by out. This function is invoked only if memcpy call is possible.

Parameters
in
n
out
Returns

◆ pack_n() [5/5]

template<typename Endianness , std::size_t ValueBits, typename InputType , typename OutputType >
template<std::size_t InputValueBits, std::size_t OutputValueBits>
static std::enable_if< can_memcpy<Endianness, InputValueBits, OutputValueBits, InputType, OutputType>::value>::type nil::crypto3::detail::real_packer< Endianness, Endianness, ValueBits, ValueBits, InputType, OutputType, true, false, false >::pack_n ( InputType const *  in,
std::size_t  n,
OutputType *  out 
)
inlinestatic

Packs n InputType elements pointed by constant pointer in (which, hence, cannot be iterated) into OutType elements pointed by out. This function is invoked only if memcpy call is possible.

Parameters
in
n
out
Returns

◆ pack_to() [1/2]

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 
)
inline

Packs elements from range [first, last) represented in machine-dependent endianness into elements starting from out represented in OutputEndianness endianness.

Template Parameters
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
out
Returns

◆ pack_to() [2/2]

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 
)
inline

Packs elements from range [first, last) represented in machine-dependent endianness into elements starting from out represented in OutputEndianness endianness.

Template Parameters
OutputEndianness
InputValueBits
OutputValueBits
InputIterator
OutputIterator
Parameters
first
last
out
Returns