General Utility Library for C++14  2.12
Public Member Functions | Public Attributes | Friends | List of all members
gul14::HexdumpParameterForward< IteratorT, ContainerT > Class Template Reference

Detailed Description

template<typename IteratorT, typename ContainerT = void*>
class gul14::HexdumpParameterForward< IteratorT, ContainerT >

Helper object used to enable a convenient syntax to dump things to a stream.

std::cerr << hexdump_stream(mydata.begin(), mydata.end()) << "\n";
HexdumpParameterForward< const IteratorT > hexdump_stream(const IteratorT &begin, const IteratorT &end, std::string prompt="")
Generate a hexdump of a data range that can be efficiently written to a stream using operator<<.
Definition: hexdump.h:423

It just forwards the parameters to hexdump_stream() to the appropriate operator<<. Member cont_ holds the container if a temporary has been used for dumping.

#include <hexdump.h>

Public Member Functions

 HexdumpParameterForward (IteratorT begin_it, IteratorT end_it, std::string prompt, ContainerT &&cont)
 Construct a hexdump parameter forwarder object. More...
 
 HexdumpParameterForward (const HexdumpParameterForward &other)
 Copy constructor (automatically updates the begin_ and end_ interator members if the copied object holds a container).
 
 HexdumpParameterForward (HexdumpParameterForward &&other) noexcept
 Move constructor (automatically updates the begin_ and end_ interator members if the moved-from object holds a container).
 
HexdumpParameterForwardoperator= (const HexdumpParameterForward &other)
 Copy assignment (automatically updates the begin_ and end_ interator members if the copied object holds a container).
 
HexdumpParameterForwardoperator= (HexdumpParameterForward &&other) noexcept
 Move assignment (automatically updates the begin_ and end_ interator members if the moved-from object holds a container).
 

Public Attributes

IteratorT begin_
 Iterator to begin of elements to be dumped (in iterator mode)
 
IteratorT end_
 Iterator past end of elements to be dumped (in iterator mode)
 
std::string prompt_
 Possible prompt to prepend to the dump.
 
ContainerT cont_
 A container with the elements to be dumped (in container/temporary mode)
 

Friends

std::ostream & operator<< (std::ostream &os, const HexdumpParameterForward< IteratorT, ContainerT > &hdp)
 Overload of std::ostream's operator<< to enable a convenient syntax to dump things to a stream. More...
 

Constructor & Destructor Documentation

◆ HexdumpParameterForward()

template<typename IteratorT , typename ContainerT = void*>
gul14::HexdumpParameterForward< IteratorT, ContainerT >::HexdumpParameterForward ( IteratorT  begin_it,
IteratorT  end_it,
std::string  prompt,
ContainerT &&  cont 
)
inline

Construct a hexdump parameter forwarder object.

Parameters
begin_itStart iterator (meaningless if a container is passed).
end_itEnd iterator (meaningless if a container is passed).
promptA string to be printed alongside the hexdump output.
contThe container to be hexdumped (can be nullptr if iterators are used).

Friends And Related Function Documentation

◆ operator<<

template<typename IteratorT , typename ContainerT = void*>
std::ostream& operator<< ( std::ostream &  os,
const HexdumpParameterForward< IteratorT, ContainerT > &  hdp 
)
friend

Overload of std::ostream's operator<< to enable a convenient syntax to dump things to a stream.

Can also be used for ofstreams or stringstreams.

std::cerr << hexdump_stream(mydata.data(), mydata.size()) << "\n";

The stream is filled successively with the dumped data, no internal representation of the dump is generated.


The documentation for this class was generated from the following file: