LDMX Software
|
This class is a helper class for reading the buffer stored in the raw data format. More...
#include <BufferReader.h>
Public Member Functions | |
BufferReader (const std::vector< uint8_t > &b) | |
Initialize a reader by wrapping a buffer to read. | |
operator bool () | |
Return state of buffer. | |
BufferReader & | operator>> (WordType &w) |
Streaming operator We get the next word if we are still in the buffer. | |
Private Member Functions | |
WordType | next () |
Go to next word in buffer. | |
Private Attributes | |
const std::vector< uint8_t > & | buffer_ |
std::size_t | i_word_ |
Static Private Attributes | |
static const std::size_t | n_bytes_ {sizeof(WordType)} |
This class is a helper class for reading the buffer stored in the raw data format.
The raw data format specifies that the buffer for all data is a specific type (vector of bytes), but the users in different subsystems/translators may want the buffer to be read in different size words than single bytes. This class helps in that translation.
A basic idea for using this reader is provided in the Ecal/Hcal raw decoders.
BufferReader<uint32_t> r{buffer_}; while (r >> head1 >> head2) { // do decoding, using r >> w; // to get next word in buffer }
in] WordType type of word user wants to read out from buffer
Definition at line 34 of file BufferReader.h.
|
inline |
Initialize a reader by wrapping a buffer to read.
Definition at line 39 of file BufferReader.h.
|
inlineprivate |
Go to next word in buffer.
std::out_of_range | if try to go past end of buffer |
Definition at line 74 of file BufferReader.h.
Referenced by packing::utility::BufferReader< WordType >::operator>>().
|
inline |
Return state of buffer.
false if buffer is done being read, true otherwise.
Definition at line 46 of file BufferReader.h.
|
inline |
Streaming operator We get the next word if we are still in the buffer.
We always return ourselves so statements like
if (reader >> word1 >> word2)
can correctly fail on the first or second word.
[in] | w | reference to word to put data into |
Definition at line 61 of file BufferReader.h.
References packing::utility::BufferReader< WordType >::next().
|
private |
Definition at line 87 of file BufferReader.h.
|
private |
Definition at line 89 of file BufferReader.h.
|
staticprivate |
Definition at line 85 of file BufferReader.h.