Updated documentation

This commit is contained in:
Jeffrey Walton 2016-04-21 04:08:06 -04:00
parent 8ac5c499c2
commit c82f0a0d6a
2 changed files with 55 additions and 1 deletions

54
misc.h
View File

@ -2002,13 +2002,35 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, c
#endif
}
//! \class GetBlock
//! \brief Access a block of memory
//! \tparam T class or type
//! \tparam B enumeration indicating endianess
//! \tparam A flag indicating alignment
//! \details GetBlock() provides alternate read access to a block of memory. The enumeration B is
//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T.
//! Repeatedly applying \ref GetBlock::operator() "operator()" results in advancing in the block of memory.
//! \details An example of reading two word32 values from a block of memory is shown below. <tt>w1</tt>
//! will be <tt>0x03020100</tt> and <tt>w1</tt> will be <tt>0x07060504</tt>.
//! <pre>
//! word32 w1, w2;
//! byte buffer[8] = {0,1,2,3,4,5,6,7};
//! GetBlock<word32, LittleEndian> block(buffer);
//! block(w1)(w2);
//! </pre>
template <class T, class B, bool A=false>
class GetBlock
{
public:
//! \brief Construct a GetBlock
//! \param block the memory block
GetBlock(const void *block)
: m_block((const byte *)block) {}
//! \brief Access a block of memory
//! \tparam U class or type
//! \param x the value to read
//! \returns pointer to the remainder of the block after reading x
template <class U>
inline GetBlock<T, B, A> & operator()(U &x)
{
@ -2022,13 +2044,36 @@ private:
const byte *m_block;
};
//! \class PutBlock
//! \brief Access a block of memory
//! \tparam T class or type
//! \tparam B enumeration indicating endianess
//! \tparam A flag indicating alignment
//! \details GetBlock() provides alternate write access to a block of memory. The enumeration B is
//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T.
//! Repeatedly applying \ref PutBlock::operator() "operator()" results in advancing in the block of memory.
//! \details An example of reading two word32 values from a block of memory is shown below. <tt>w1</tt>
//! will be <tt>0x03020100</tt> and <tt>w1</tt> will be <tt>0x07060504</tt>.
//! <pre>
//! word32 w1, w2;
//! byte buffer[8] = {0,1,2,3,4,5,6,7};
//! GetBlock<word32, LittleEndian> block(buffer);
//! block(w1)(w2);
//! </pre>
template <class T, class B, bool A=false>
class PutBlock
{
public:
//! \brief Construct a PutBlock
//! \param block the memory block
//! \param xorBlock optional mask
PutBlock(const void *xorBlock, void *block)
: m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {}
//! \brief Access a block of memory
//! \tparam U class or type
//! \param x the value to write
//! \returns pointer to the remainder of the block after writing x
template <class U>
inline PutBlock<T, B, A> & operator()(U x)
{
@ -2044,6 +2089,15 @@ private:
byte *m_block;
};
//! \class BlockGetAndPut
//! \brief Access a block of memory
//! \tparam T class or type
//! \tparam B enumeration indicating endianess
//! \tparam GA flag indicating alignment for the Get operation
//! \tparam PA flag indicating alignment for the Put operation
//! \details GetBlock() provides alternate write access to a block of memory. The enumeration B is
//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T.
//! \sa GetBlock() and PutBlock().
template <class T, class B, bool GA=false, bool PA=false>
struct BlockGetAndPut
{

View File

@ -44,7 +44,7 @@ protected:
//! \class Salsa20
//! \brief Salsa20 stream cipher information
//! \details XSalsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20.
//! \details Salsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20.
//! \sa <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>
struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
{