evio
6.0
|
Class to hold static methods used to swap evio data. More...
#include <EvioSwap.h>
Static Public Member Functions | |
static void | swapArray32 (uint8_t *data, uint32_t dataLen) |
Swap byte array in place assuming bytes are 32 bit ints. More... | |
static void | swapEvent (std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, std::vector< std::shared_ptr< EvioNode >> &nodeList, bool storeNodes=false, bool swapData=true, size_t srcPos=0, size_t destPos=0) |
This method swaps the byte order of an entire evio event or bank. More... | |
static void | swapBankHeader (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, size_t srcPos=0, size_t destPos=0) |
static void | swapSegmentHeader (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, size_t srcPos=0, size_t destPos=0) |
static void | swapTagSegmentHeader (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, size_t srcPos=0, size_t destPos=0) |
static void | swapData (DataType const &type, std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, uint32_t len, bool inPlace=false, size_t srcPos=0, size_t destPos=0) |
This method swaps the data of an evio leaf structure. More... | |
static void | swapStructure (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &srcBuffer, std::shared_ptr< ByteBuffer > &destBuffer, std::vector< std::shared_ptr< EvioNode >> &nodeList, bool storeNodes=false, bool swapData=true, bool inPlace=false, size_t srcPos=0, size_t destPos=0) |
Swap an evio structure. More... | |
static void | swapEvent (uint32_t *buf, int tolocal, uint32_t *dest) |
Method to swap the endianness of an evio event (bank). More... | |
static void | swapEvent (ByteBuffer &buf, ByteBuffer &dest) |
Method to swap the endianness of an evio event (bank). More... | |
static void | swapEvent (std::shared_ptr< ByteBuffer > &buf, std::shared_ptr< ByteBuffer > &dest) |
Method to swap the endianness of an evio event (bank). More... | |
static void | swapBank (uint32_t *buf, bool toLocal, uint32_t *dest) |
Routine to swap the endianness of an evio bank. More... | |
static void | swapSegment (uint32_t *buf, bool toLocal, uint32_t *dest) |
Routine to swap the endianness of an evio segment. More... | |
static void | swapTagsegment (uint32_t *buf, bool toLocal, uint32_t *dest) |
Routine to swap the endianness of an evio tagsegment. More... | |
static void | swapLeafData (DataType const &type, std::shared_ptr< ByteBuffer > &srcBuf, std::shared_ptr< ByteBuffer > &destBuf, size_t srcPos, size_t destPos, size_t len) |
This method swaps the data of an evio leaf structure. More... | |
static void | swapLeafData (DataType const &type, ByteBuffer &srcBuf, ByteBuffer &destBuf, size_t srcPos, size_t destPos, size_t len) |
This method swaps the data of an evio leaf structure. More... | |
static void | swapData (uint32_t *src, uint32_t type, uint32_t length, bool toLocal, uint32_t *dst) |
Routine to swap any type of evio data. More... | |
static void | swapData (std::shared_ptr< BaseStructure > strc) |
Routine to swap the endianness of an evio structure's (bank, seg, tagseg) data in place, including descendants' data. More... | |
Class to hold static methods used to swap evio data.
|
inlinestatic |
Swap byte array in place assuming bytes are 32 bit ints.
Number of array elements must be multiple of 4.
data | byte array to convert. |
dataLen | number of bytes to convert. |
EvioException | if data is null; dataLen is not a multiple of 4. |
|
inlinestatic |
Routine to swap the endianness of an evio bank.
Null buf argument does nothing.
buf | buffer of evio bank data to be swapped. |
toLocal | if false buf contains data of same endian as local host, else buf has data of opposite endian. |
dest | buffer to place swapped data into. If this is null, then dest = buf. |
References evio::ByteOrder::byteSwap32(), and swapData().
Referenced by swapData(), and swapEvent().
|
inlinestatic |
This method reads and swaps an evio bank header. It can also return information about the bank. Position and limit of neither buffer argument is changed.
This only swaps data if buffer arguments have opposite byte order!
node | object in which to store data about the bank in destBuffer after swap; may be null |
srcBuffer | buffer containing bank header to be swapped |
destBuffer | buffer in which to place swapped bank header |
srcPos | position in srcBuffer to start reading bank header |
destPos | position in destBuffer to start writing swapped bank header |
EvioException | if srcBuffer too little data; if destBuffer is too small to contain swapped data |
Referenced by swapEvent(), and swapStructure().
|
inlinestatic |
This method swaps the data of an evio leaf structure.
In other words the structure being swapped does not contain evio structures.
type | type of data being swapped |
srcBuffer | buffer containing data to be swapped |
destBuffer | buffer in which to place swapped data |
srcPos | position in srcBuffer to start reading data |
destPos | position in destBuffer to start writing swapped data |
len | length of data in 32 bit words |
inPlace | if true, data is swapped in srcBuffer |
EvioException | if srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos; |
References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::DataType::INT32, evio::DataType::LONG64, evio::DataType::SHORT16, evio::CompositeData::swapAll(), evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, evio::DataType::UNKNOWN32, and evio::DataType::USHORT16.
Referenced by swapBank(), swapData(), swapEvent(), swapSegment(), swapStructure(), and swapTagsegment().
|
inlinestatic |
Routine to swap the endianness of an evio structure's (bank, seg, tagseg) data in place, including descendants' data.
The endianness of the given structure, obtained through BaseStructure#getByteOrder(), does NOT change. The caller must explicitly call BaseStructure#setByteOrder() to do that.
If this structure contains Composite data, and since it is stored as a vector of shared pointers to CompositeData objects, it is only serialized into bytes when written out. Thus the only way to switch it's endianness is for the user to call BaseStructure#setByteOrder() before writing it out as bytes. In other words, this method does NOT swap Composite data.
strc | evio structure in which to swap all data. |
References evio::ByteOrder::byteSwap16(), evio::ByteOrder::byteSwap32(), evio::ByteOrder::byteSwap64(), evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::DataType::INT32, evio::DataType::LONG64, evio::DataType::SHORT16, swapData(), evio::DataType::UINT32, evio::DataType::ULONG64, and evio::DataType::USHORT16.
|
inlinestatic |
Routine to swap any type of evio data.
This only swaps data associated with an evio structure; i.e. it completely ignores the header associated with it. If this data consists of structures like banks & segments, it will swap them completely. Null src argument does nothing.
src | source of evio data to be swapped (after evio header). |
type | type of evio data. |
length | length of evio data in 32 bit words |
toLocal | if false data is of same endian as local host, else data is of opposite endian. |
dst | destination of swapped data. If this is null, then dst = src. |
References evio::ByteOrder::byteNoSwap32(), evio::ByteOrder::byteSwap16(), evio::ByteOrder::byteSwap32(), evio::ByteOrder::byteSwap64(), evio::CompositeData::swapAll(), swapBank(), swapSegment(), and swapTagsegment().
|
inlinestatic |
Method to swap the endianness of an evio event (bank).
buf | buffer of evio event data to be swapped |
dest | buffer to place swapped data into. If this is null, then dest = buf. |
References evio::ByteBuffer::array(), evio::ByteOrder::nativeOrder(), evio::ByteBuffer::order(), and swapBank().
|
inlinestatic |
Method to swap the endianness of an evio event (bank).
buf | buffer of evio event data to be swapped |
dest | buffer to place swapped data into. If this is null, then dest = buf. |
References evio::ByteOrder::nativeOrder(), and swapBank().
|
inlinestatic |
This method swaps the byte order of an entire evio event or bank.
The byte order of the swapped buffer will be opposite to the byte order of the source buffer argument. If the swap is done in place, the byte order of the source buffer will be switched upon completion and the destPos arg will be set equal to the srcPos arg. The positions of the source and destination buffers are not changed. A ByteBuffer's current byte order can be found by calling java.nio.ByteBuffer#order().
The data to be swapped must not be in the evio file format (with record headers). Data must only consist of bytes representing a single event/bank. Position and limit of neither buffer is changed.
srcBuffer | buffer containing event to swap. |
destBuffer | buffer in which to place the swapped event. If null, or identical to srcBuffer, the data is swapped in place. |
nodeList | if not null, generate and store node objects here - one for each swapped evio structure in destBuffer. |
storeNodes | if true, store generated EvioNodes in nodeList. |
swapData | if false, do NOT swap data, else swap data too. |
srcPos | position in srcBuffer to start reading event. |
destPos | position in destBuffer to start writing swapped event. |
EvioException | if srcBuffer arg is null; if any buffer position is not zero |
References evio::DataType::BANK, evio::EvioNode::createEvioNode(), evio::ByteOrder::getOppositeEndian(), evio::DataType::getValue(), swapBankHeader(), swapData(), and swapStructure().
|
inlinestatic |
Method to swap the endianness of an evio event (bank).
buf | buffer of evio event data to be swapped |
tolocal | if 0 buf contains data of same endian as local host, else buf has data of opposite endian. |
dest | buffer to place swapped data into. If this is null, then dest = buf. |
References swapBank().
|
inlinestatic |
This method swaps the data of an evio leaf structure.
In other words the structure being swapped does not contain evio structures. It does nothing for container types.
type | type of data being swapped |
srcBuf | buffer containing data to be swapped |
destBuf | buffer in which to place swapped data |
srcPos | position in srcBuffer to start reading data |
destPos | position in destBuffer to start writing swapped data |
len | length of data in 32 bit words |
EvioException | if srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos; |
References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::ByteBuffer::getByte(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::getShort(), evio::DataType::INT32, evio::DataType::LONG64, evio::ByteBuffer::put(), evio::ByteBuffer::putInt(), evio::ByteBuffer::putLong(), evio::ByteBuffer::putShort(), evio::DataType::SHORT16, evio::CompositeData::swapAll(), evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, evio::DataType::UNKNOWN32, and evio::DataType::USHORT16.
|
inlinestatic |
This method swaps the data of an evio leaf structure.
In other words the structure being swapped does not contain evio structures. It does nothing for container types.
type | type of data being swapped |
srcBuf | buffer containing data to be swapped |
destBuf | buffer in which to place swapped data |
srcPos | position in srcBuffer to start reading data |
destPos | position in destBuffer to start writing swapped data |
len | length of data in 32 bit words |
EvioException | if srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos; |
|
inlinestatic |
Routine to swap the endianness of an evio segment.
Null buf argument does nothing.
buf | buffer of evio segment data to be swapped |
toLocal | if false buf contains data of same endian as local host, else buf has data of opposite endian |
dest | buffer to place swapped data into. If this is NULL, then dest = buf. |
References evio::ByteOrder::byteSwap32(), and swapData().
Referenced by swapData().
|
inlinestatic |
This method reads and swaps an evio segment header. It can also return information about the segment. Position and limit of neither buffer argument is changed.
This only swaps data if buffer arguments have opposite byte order!
node | object in which to store data about the segment in destBuffer after swap; may be null |
srcBuffer | buffer containing segment header to be swapped |
destBuffer | buffer in which to place swapped segment header |
srcPos | position in srcBuffer to start reading segment header |
destPos | position in destBuffer to start writing swapped segment header |
EvioException | if srcBuffer too little data; if destBuffer is too small to contain swapped data |
Referenced by swapStructure().
|
inlinestatic |
Swap an evio structure.
If it is a structure of structures, such as a bank of banks, swap recursively.
node | info from parsed header |
srcBuffer | buffer containing structure to swap. |
destBuffer | buffer in which to place the swapped structure. |
nodeList | if not null, store all node objects here - one for each swapped evio structure in destBuffer. |
storeNodes | if true, store generated EvioNodes in nodeList. |
swapData | if false, do NOT swap data, else swap data too. |
inPlace | if true, data is swapped in srcBuffer |
srcPos | position in srcBuffer to start reading structure |
destPos | position in destBuffer to start writing swapped structure |
EvioException | if args are null; IF srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos and/or destPos; |
References evio::DataType::BANK, evio::EvioNode::createEvioNode(), evio::DataType::getValue(), evio::DataType::isBank(), evio::DataType::isSegment(), evio::DataType::isStructure(), evio::DataType::isTagSegment(), evio::DataType::SEGMENT, swapBankHeader(), swapData(), swapSegmentHeader(), swapTagSegmentHeader(), and evio::DataType::TAGSEGMENT.
Referenced by swapEvent().
|
inlinestatic |
Routine to swap the endianness of an evio tagsegment.
Null buf argument does nothing.
buf | buffer of evio tagsegment data to be swapped |
toLocal | if false buf contains data of same endian as local host, else buf has data of opposite endian |
dest | buffer to place swapped data into. If this is NULL, then dest = buf. |
References evio::ByteOrder::byteSwap32(), and swapData().
Referenced by swapData().
|
inlinestatic |
This method reads and swaps an evio tagsegment header. It can also return information about the tagsegment. Position and limit of neither buffer argument is changed.
This only swaps data if buffer arguments have opposite byte order!
node | object in which to store data about the tagsegment in destBuffer after swap; may be null |
srcBuffer | buffer containing tagsegment header to be swapped |
destBuffer | buffer in which to place swapped tagsegment header |
srcPos | position in srcBuffer to start reading tagsegment header |
destPos | position in destBuffer to start writing swapped tagsegment header |
EvioException | if srcBuffer too little data; if destBuffer is too small to contain swapped data |
Referenced by swapStructure().