evio
6.0
|
#include <CompositeData.h>
Classes | |
class | Data |
This class is used to provide all data when constructing a CompositeData object. More... | |
class | DataItem |
This class defines an individual data item. More... | |
union | SingleMember |
This class holds a single, primitive type data item. More... | |
Public Member Functions | |
uint32_t | getPadding () const |
Get the data padding (0, 1, 2, or 3 bytes). More... | |
std::string | getFormat () const |
This method gets the format string. More... | |
ByteOrder | getByteOrder () const |
This method gets the raw data byte order. More... | |
std::vector< uint8_t > & | getRawBytes () |
This method gets a vector of the raw byte representation of this object's data. More... | |
std::vector< DataItem > & | getItems () |
This method gets a vector of all the data items inside the composite. More... | |
std::vector< DataType > & | getTypes () |
This method gets a vector of all the types of the data items inside the composite. More... | |
std::vector< int32_t > & | getNValues () |
This method gets a vector of all the N values of the data items inside the composite. More... | |
std::vector< int16_t > & | getnValues () |
This method gets a vector of all the n values of the data items inside the composite. More... | |
std::vector< int8_t > & | getmValues () |
This method gets a vector of all the m values of the data items inside the composite. More... | |
uint32_t | index () const |
This methods returns the index of the data item to be returned on the next call to one of the get<Type>() methods (e.g. More... | |
void | index (uint32_t index) |
This methods sets the index of the data item to be returned on the next call to one of the get<Type>() methods (e.g. More... | |
int32_t | getNValue () |
This method gets the next N value data item if it's the correct type. More... | |
int16_t | getnValue () |
This method gets the next n value data item if it's the correct type. More... | |
int8_t | getmValue () |
This method gets the next m value data item if it's the correct type. More... | |
int32_t | getHollerit () |
This method gets the next HOLLERIT data item if it's the correct type. More... | |
int8_t | getChar () |
This method gets the next data item as a byte/char if it's the correct type. More... | |
uint8_t | getUChar () |
This method gets the next data item as an unsigned byte/char if it's the correct type. More... | |
int16_t | getShort () |
This method gets the next data item as a short if it's the correct type. More... | |
uint16_t | getUShort () |
This method gets the next data item as an unsigned short if it's the correct type. More... | |
int32_t | getInt () |
This method gets the next data item as an int if it's the correct type. More... | |
uint32_t | getUInt () |
This method gets the next data item as an unsigned int if it's the correct type. More... | |
int64_t | getLong () |
This method gets the next data item as a long if it's the correct type. More... | |
uint64_t | getULong () |
This method gets the next data item as an unsigned long if it's the correct type. More... | |
float | getFloat () |
This method gets the next data item as a float if it's the correct type. More... | |
double | getDouble () |
This method gets the next data item as a double if it's the correct type. More... | |
std::vector< std::string > & | getStrings () |
This method gets the next data item as a vector of strings if it's the correct type. More... | |
void | swap () |
This method swaps the data of this composite type between big & little endian. More... | |
void | process () |
This method extracts and stores all the data items and their types in various lists. More... | |
std::string | toString () const |
Obtain a string representation of the composite data. More... | |
std::string | toString (const std::string &indent, bool hex) |
Obtain a string representation of the composite data. More... | |
std::string | toString (bool hex) const |
This method returns a string representation of this CompositeData object suitable for displaying in org.jlab.coda.jevio.graphics.EventTreeFrame gui. More... | |
Static Public Member Functions | |
static std::shared_ptr < CompositeData > | getInstance (std::string &format, const Data &data) |
Method to return a shared pointer to a constructed object of this class. More... | |
static std::shared_ptr < CompositeData > | getInstance (std::string &format, const Data &data, uint16_t formatTag, uint16_t dataTag, uint8_t dataNum, ByteOrder const &order=ByteOrder::ENDIAN_LOCAL) |
Method to return a shared pointer to a constructed object of this class. More... | |
static std::shared_ptr < CompositeData > | getInstance (uint8_t *bytes, ByteOrder const &order=ByteOrder::ENDIAN_LOCAL) |
Method to return a shared pointer to a constructed object of this class. More... | |
static std::shared_ptr < CompositeData > | getInstance (ByteBuffer &bytes) |
Method to return a shared pointer to a constructed object of this class. More... | |
static void | parse (uint8_t *bytes, size_t bytesSize, ByteOrder const &order, std::vector< std::shared_ptr< CompositeData >> &list) |
This method parses an array of raw bytes into an vector of CompositeData objects. More... | |
static void | generateRawBytes (std::vector< std::shared_ptr< CompositeData >> &data, std::vector< uint8_t > &rawBytes, ByteOrder &order) |
This method generates raw bytes of evio format from a vector of CompositeData objects. More... | |
static std::string | stringsToFormat (std::vector< std::string > strings) |
This method helps the CompositeData object creator by finding the proper format string parameter for putting this array of Strings into its data. More... | |
static int | compositeFormatToInt (const std::string &formatStr, std::vector< uint16_t > &ifmt) |
static void | swapAll (uint8_t *src, uint8_t *dest, size_t length, bool srcIsLocal) |
This method converts (swaps) a buffer of EVIO composite type between big & little endian. More... | |
static void | swapAll (ByteBuffer &buf, uint32_t srcPos, uint32_t len) |
This method swaps the data in a buffer, containing EVIO composite type, between big & little endian. More... | |
static void | swapAll (std::shared_ptr< ByteBuffer > &buf, uint32_t srcPos, uint32_t len) |
This method swaps the data in a buffer, containing EVIO composite type, between big & little endian. More... | |
static void | swapAll (std::shared_ptr< ByteBuffer > &srcBuf, std::shared_ptr< ByteBuffer > &destBuf, uint32_t srcPos, uint32_t destPos, uint32_t len) |
This method converts (swaps) a buffer, containing EVIO composite type, between big & little endian. More... | |
static void | swapAll (ByteBuffer &srcBuffer, ByteBuffer &destBuffer, uint32_t srcPos, uint32_t destPos, uint32_t len) |
This method converts (swaps) a buffer, containing EVIO composite type, between big & little endian. More... | |
static void | swapData (ByteBuffer &srcBuf, ByteBuffer &destBuf, size_t nBytes, const std::vector< uint16_t > &ifmt) |
This method converts (swaps) EVIO composite type data between Big endian and Little endian. More... | |
static void | swapData (std::shared_ptr< ByteBuffer > &srcBuf, std::shared_ptr< ByteBuffer > &destBuf, size_t srcPos, size_t destPos, size_t nBytes, const std::vector< uint16_t > &ifmt) |
This method converts (swaps) EVIO composite type data between Big endian and Little endian. More... | |
static void | swapData (ByteBuffer &srcBuf, ByteBuffer &destBuf, size_t srcPos, size_t destPos, size_t nBytes, const std::vector< uint16_t > &ifmt) |
This method converts (swaps) EVIO composite type data between Big endian and Little endian. More... | |
static void | swapData (int32_t *src, int32_t *dest, size_t nwrd, const std::vector< uint16_t > &ifmt, uint32_t padding, bool srcIsLocal) |
This method converts (swaps) EVIO composite type data between Big endian and Little endian. More... | |
static void | swapData (int32_t *iarr, int nwrd, const std::vector< uint16_t > &ifmt, uint32_t padding) |
This method converts (swaps) an array of EVIO composite type data between IEEE (big endian) and DECS (little endian) in place. More... | |
static void | dataToRawBytes (ByteBuffer &rawBuf, Data const &data, std::vector< uint16_t > &ifmt) |
This method converts (swaps) an array of EVIO composite type data between IEEE (big endian) and DECS (little endian) in place. More... | |
COMPOSITE DATA:
This is a new type of data (value = 0xf) which originated with Hall B. It is a composite type and allows for possible expansion in the future if there is a demand. Basically it allows the user to specify a custom format by means of a string - stored in a tagsegment. The data in that format follows in a bank. The routine to swap this data must be provided by the definer of the composite type - in this case Hall B. The swapping function is plugged into this evio library's swapping routine.
Here's what the data looks like.
MSB(31) LSB(0)
<--- 32 bits ------------------------>
_______________________________________
| tag | type | length | --> tagsegment header
|_________|______|____________________|
| Data Format String |
| |
|_____________________________________|
| length | \
|_____________________________________| \ bank header
| tag | type | num | /
|________________|_________|__________| /
| Data |
| |
|_____________________________________|
The beginning tagsegment is a normal evio tagsegment containing a string (type = 0x3). Currently its type and tag are not used - at least not for data formatting. The bank is a normal evio bank header with data following. The format string is used to read/write this data so that takes care of any padding that may exist. As with the tagsegment, the tags and type are ignored.
This is the class defining the composite data type. It is a mixture of header and raw data. This class is NOT thread safe.
|
static |
This method was originally called called "eviofmt".
It transforms a composite, format-containing
ASCII string to a vector of shorts codes. It is to be used
in conjunction with swapData to swap the endianness of
composite data.
format code bits <- format in ascii form
[15:14] [13:8] [7:0]
Nnm # 0 #'('
0 0 0 ')'
Nnm # 1 #'i' unsigned int
Nnm # 2 #'F' floating point
Nnm # 3 #'a' 8-bit char (C++)
Nnm # 4 #'S' short
Nnm # 5 #'s' unsigned short
Nnm # 6 #'C' char
Nnm # 7 #'c' unsigned char
Nnm # 8 #'D' double (64-bit float)
Nnm # 9 #'L' long long (64-bit int)
Nnm # 10 #'l' unsigned long long (64-bit int)
Nnm # 11 #'I' int
Nnm # 12 #'A' hollerit (4-byte char with int endining)
NOTES:
1. The number of repeats '#' must be the number between 2 and 63, number 1 assumed by default
2. If the number of repeats is symbol 'N' instead of the number, it will be taken from data assuming 'int32' format;
if the number of repeats is symbol 'n' instead of the number, it will be taken from data assuming 'int16' format;
if the number of repeats is symbol 'm' instead of the number, it will be taken from data assuming 'int8' format;
Two bits Nnm [15:14], if not zero, requires to take the number of repeats from data in appropriate format:
[01] means that number is integer (N),
[10] - short (n),
[11] - char (m)
3. If format ends but end of data did not reach, format in last parenthesis
will be repeated until all data processed; if there are no parenthesis
in format, data processing will be started from the beginnig of the format
(FORTRAN agreement)
formatStr | composite data format string |
ifmt | unsigned short vector to hold transformed format |
|
static |
This method converts (swaps) an array of EVIO composite type data between IEEE (big endian) and DECS (little endian) in place.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words.
Converts the data of array (iarr[i], i=0...nwrd-1) using the format code (ifmt[j], j=0...nfmt-1) .
Algorithm description:
Data processed inside while (ib < nwrd) loop, where 'ib' is iarr[] index; loop breaks when 'ib' reaches the number of elements in iarr[]
iarr | pointer to data to be swapped |
nwrd | number of data words (32-bit ints) to be swapped |
ifmt | unsigned short vector holding translated format |
padding | number of bytes to ignore in last data word (starting from data end) |
rawBuf | data buffer in which to put the raw bytes |
data | data to convert to raw bytes |
ifmt | format list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &) |
EvioException | if ifmt size <= 0; if srcBuf or destBuf is too small; not enough dataItems for the given format |
References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::DOUBLE64, evio::DataType::FLOAT32, evio::DataType::HOLLERIT, evio::DataType::INT32, evio::DataType::LONG64, evio::ByteBuffer::put(), evio::ByteBuffer::putDouble(), evio::ByteBuffer::putFloat(), evio::ByteBuffer::putInt(), evio::ByteBuffer::putLong(), evio::ByteBuffer::putShort(), evio::DataType::SHORT16, evio::Util::stringsToRawBytes(), evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, and evio::DataType::USHORT16.
|
static |
This method generates raw bytes of evio format from a vector of CompositeData objects.
The returned vector consists of gluing together all the individual objects' rawByte arrays. All CompositeData element must be of the same byte order.
data | vector of CompositeData objects to turn into bytes (input). |
rawBytes | vector of raw, evio format bytes (output). |
order | byte order of output. |
References swapAll().
Referenced by evio::CompactEventBuilder::addCompositeData(), and evio::BaseStructure::updateCompositeData().
ByteOrder evio::CompositeData::getByteOrder | ( | ) | const |
This method gets the raw data byte order.
int8_t evio::CompositeData::getChar | ( | ) |
This method gets the next data item as a byte/char if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not int8_t. |
References evio::DataType::CHAR8.
Referenced by toString().
double evio::CompositeData::getDouble | ( | ) |
This method gets the next data item as a double if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not double. |
References evio::DataType::DOUBLE64.
Referenced by toString().
float evio::CompositeData::getFloat | ( | ) |
This method gets the next data item as a float if it's the correct type.
underflow_error | if at end of data. |
EvioException | if data is not float. |
References evio::DataType::FLOAT32.
Referenced by toString().
std::string evio::CompositeData::getFormat | ( | ) | const |
This method gets the format string.
int32_t evio::CompositeData::getHollerit | ( | ) |
This method gets the next HOLLERIT data item if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not HOLLERIT. |
References evio::DataType::HOLLERIT.
Referenced by toString().
|
static |
Method to return a shared pointer to a constructed object of this class.
format | data format string. |
data | object containing composite data description. |
|
static |
Method to return a shared pointer to a constructed object of this class.
format | data format string. |
data | object containing composite data description. |
formatTag | tag of evio segment containing format. |
dataTag | tag of evio bank containing data. |
dataNum | num of evio bank containing data. |
order | desired byteOrder of generated raw data. Defaults to local endian. |
|
static |
Method to return a shared pointer to a constructed object of this class.
bytes | pointer to raw data. |
order | byte order of raw data. |
|
static |
Method to return a shared pointer to a constructed object of this class.
bytes | ByteBuffer of raw data. |
int32_t evio::CompositeData::getInt | ( | ) |
This method gets the next data item as an int if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not int32_t. |
References evio::DataType::INT32.
Referenced by toString().
std::vector< CompositeData::DataItem > & evio::CompositeData::getItems | ( | ) |
This method gets a vector of all the data items inside the composite.
Do not change the vector contents.
int64_t evio::CompositeData::getLong | ( | ) |
This method gets the next data item as a long if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not int64_t. |
References evio::DataType::LONG64.
Referenced by toString().
int8_t evio::CompositeData::getmValue | ( | ) |
This method gets the next m value data item if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not mValue. |
References evio::DataType::mVALUE.
Referenced by toString().
std::vector< int8_t > & evio::CompositeData::getmValues | ( | ) |
This method gets a vector of all the m values of the data items inside the composite.
int32_t evio::CompositeData::getNValue | ( | ) |
This method gets the next N value data item if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not NValue. |
References evio::DataType::NVALUE.
Referenced by toString().
int16_t evio::CompositeData::getnValue | ( | ) |
This method gets the next n value data item if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not nValue. |
References evio::DataType::nVALUE.
Referenced by toString().
std::vector< int32_t > & evio::CompositeData::getNValues | ( | ) |
This method gets a vector of all the N values of the data items inside the composite.
std::vector< int16_t > & evio::CompositeData::getnValues | ( | ) |
This method gets a vector of all the n values of the data items inside the composite.
uint32_t evio::CompositeData::getPadding | ( | ) | const |
Get the data padding (0, 1, 2, or 3 bytes).
std::vector< uint8_t > & evio::CompositeData::getRawBytes | ( | ) |
This method gets a vector of the raw byte representation of this object's data.
Do not change the vector contents.
int16_t evio::CompositeData::getShort | ( | ) |
This method gets the next data item as a short if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not int16_t. |
References evio::DataType::SHORT16.
Referenced by toString().
std::vector< std::string > & evio::CompositeData::getStrings | ( | ) |
This method gets the next data item as a vector of strings if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not vector of strings. |
References evio::DataType::CHARSTAR8.
Referenced by toString().
std::vector< DataType > & evio::CompositeData::getTypes | ( | ) |
This method gets a vector of all the types of the data items inside the composite.
uint8_t evio::CompositeData::getUChar | ( | ) |
This method gets the next data item as an unsigned byte/char if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not uint8_t. |
References evio::DataType::UCHAR8.
Referenced by toString().
uint32_t evio::CompositeData::getUInt | ( | ) |
This method gets the next data item as an unsigned int if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not uint32_t. |
References evio::DataType::UINT32.
Referenced by toString().
uint64_t evio::CompositeData::getULong | ( | ) |
This method gets the next data item as an unsigned long if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not uint64_t. |
References evio::DataType::ULONG64.
Referenced by toString().
uint16_t evio::CompositeData::getUShort | ( | ) |
This method gets the next data item as an unsigned short if it's the correct type.
std::underflow_error | if at end of data. |
EvioException | if data is not uint16_t. |
References evio::DataType::USHORT16.
Referenced by toString().
uint32_t evio::CompositeData::index | ( | ) | const |
void evio::CompositeData::index | ( | uint32_t | index | ) |
|
static |
This method parses an array of raw bytes into an vector of CompositeData objects.
Vector is initially cleared.
bytes | array of raw bytes to parse. |
bytesSize | size in bytes of bytes. |
order | byte order of raw bytes. |
list | vector that will hold all parsed CompositeData objects. |
EvioException | if null args or bad format of raw data. |
References compositeFormatToInt(), evio::EventHeaderParser::createBankHeader(), evio::EventHeaderParser::createTagSegmentHeader(), evio::ByteOrder::getName(), and evio::Util::unpackRawBytesToStrings().
Referenced by evio::BaseStructure::getCompositeData().
void evio::CompositeData::process | ( | ) |
This method extracts and stores all the data items and their types in various lists.
References evio::ByteBuffer::array(), evio::CompositeData::SingleMember::b8, evio::CompositeData::SingleMember::dbl, evio::CompositeData::SingleMember::flt, evio::ByteBuffer::getByte(), evio::ByteBuffer::getBytes(), evio::DataType::getDataType(), evio::ByteBuffer::getDouble(), evio::ByteBuffer::getFloat(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::getShort(), evio::ByteBuffer::getUInt(), evio::ByteBuffer::getULong(), evio::ByteBuffer::getUShort(), evio::DataType::HOLLERIT, evio::CompositeData::SingleMember::i32, evio::CompositeData::DataItem::item, evio::CompositeData::SingleMember::l64, evio::DataType::mVALUE, evio::DataType::NVALUE, evio::DataType::nVALUE, evio::ByteBuffer::order(), evio::ByteBuffer::position(), evio::CompositeData::SingleMember::s16, evio::CompositeData::SingleMember::str, evio::CompositeData::DataItem::strVec, evio::CompositeData::SingleMember::ub8, evio::CompositeData::SingleMember::ui32, evio::CompositeData::SingleMember::ul64, evio::Util::unpackRawBytesToStrings(), and evio::CompositeData::SingleMember::us16.
|
static |
This method helps the CompositeData object creator by finding the proper format string parameter for putting this array of Strings into its data.
The format is in the form "Ma" where M is an actual integer. Warning, in this case, M may not be greater than 15. If you want a longer string or array of strings, use the format "Na" with a literal N. The N value can be added through CompositeData::Data#addN(uint32_t)
strings | array of strings to eventually put into a CompositeData object. |
References evio::Util::stringsToRawBytes().
void evio::CompositeData::swap | ( | ) |
This method swaps the data of this composite type between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself.
EvioException | if internal error |
References swapAll().
|
static |
This method converts (swaps) a buffer of EVIO composite type between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself. The src array may contain an array of composite type items and all will be swapped.
src | source data pointer. |
dest | destination data pointer. |
length | length of data array in 32 bit words. |
srcIsLocal | true if the byte order of src data is the same as the node's. |
EvioException | if src = null; if len is too small |
References compositeFormatToInt(), evio::EventHeaderParser::createBankHeader(), evio::EventHeaderParser::createTagSegmentHeader(), evio::ByteOrder::ENDIAN_LOCAL, evio::ByteOrder::getOppositeEndian(), swapData(), and evio::Util::unpackRawBytesToStrings().
Referenced by generateRawBytes(), swap(), swapAll(), evio::EvioSwap::swapData(), evio::EvioSwap::swapLeafData(), and evio::BaseStructure::write().
|
static |
This method swaps the data in a buffer, containing EVIO composite type, between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself. The src buffer may contain an array of composite type items and all will be swapped.
buf | source and destination data buffer. |
srcPos | position in srcBuffer to beginning swapping |
len | length of data in buf to swap in 32 bit words |
std::out_of_range | if srcPos or len too large; if len too small. |
EvioException | if srcBuffer not in evio format; |
References evio::ByteBuffer::array(), evio::ByteBuffer::arrayOffset(), evio::ByteOrder::getOppositeEndian(), evio::ByteOrder::isLocalEndian(), evio::ByteBuffer::limit(), evio::ByteBuffer::order(), and swapAll().
|
static |
This method swaps the data in a buffer, containing EVIO composite type, between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself. The src buffer may contain an array of composite type items and all will be swapped.
buf | source and destination data buffer. |
srcPos | position in srcBuffer to beginning swapping |
len | length of data in buf to swap in 32 bit words |
std::out_of_range | if srcPos or len too large; if len too small. |
EvioException | if srcBuffer not in evio format; |
References swapAll().
|
static |
This method converts (swaps) a buffer, containing EVIO composite type, between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself. The src buffer may contain an array of composite type items and all will be swapped.
This only swaps data if buffer arguments have opposite byte order!
srcBuf | source data buffer |
destBuf | destination data buffer |
srcPos | position in srcBuffer to beginning swapping |
destPos | position in destBuffer to beginning writing swapped data |
len | length of data in srcBuffer to swap in 32 bit words |
EvioException | if srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos/destPos/len args; |
References swapAll().
|
static |
This method converts (swaps) a buffer, containing EVIO composite type, between big & little endian.
It swaps the entire type including the beginning tagsegment header, the following format string it contains, the data's bank header, and finally the data itself. The src buffer may contain an array of composite type items and all will be swapped.
This only swaps data if buffer arguments have opposite byte order!
srcBuffer | source data buffer |
destBuffer | destination data buffer |
srcPos | position in srcBuffer to beginning swapping |
destPos | position in destBuffer to beginning writing swapped data |
len | length of data in srcBuffer to swap in 32 bit words |
EvioException | if srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos/destPos/len args; |
References compositeFormatToInt(), evio::ByteBuffer::getByte(), evio::EvioNode::getDataLength(), evio::EvioNode::getPad(), evio::ByteBuffer::limit(), evio::ByteBuffer::put(), evio::EventHeaderParser::swapBankHeader(), swapData(), evio::EventHeaderParser::swapTagSegmentHeader(), and evio::Util::unpackRawBytesToStrings().
|
static |
This method converts (swaps) EVIO composite type data between Big endian and Little endian.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words. Caller must be sure the endian value of the srcBuf is set properly before the call.
The destBuf can be the same as srcBuf in which case data is swapped in place and the srcBuf byte order is switched in this method. Swap starts at srcBuf's current position. If data is swapped in place, destBuf pos is set to srcBuf pos.
srcBuf | source data buffer. |
destBuf | destination data buffer. |
nBytes | length of data to swap in bytes |
ifmt | format list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &) |
EvioException | if ifmt empty or nBytes < 8; srcBuf or destBuf limit/position combo too small; if src & dest not identical but overlap. |
References evio::ByteBuffer::position().
Referenced by swapAll(), and swapData().
|
static |
This method converts (swaps) EVIO composite type data between Big endian and Little endian.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words. Caller must be sure the endian value of the srcBuf is set properly before the call.
The destBuf can be the same as srcBuf in which case data is swapped in place and the srcBuf byte order is switched in this method.
srcBuf | source data buffer. |
destBuf | destination data buffer. |
srcPos | position in srcBuf to beginning swapping |
destPos | position in destBuf to beginning writing swapped data unless data is swapped in place (then set to srcPos). |
nBytes | length of data to swap in bytes (be sure to account for padding) |
ifmt | format list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &) |
EvioException | if ifmt empty or nBytes < 8; srcBuf or destBuf limit/position combo too small; if src & dest not identical but overlap. |
References swapData().
|
static |
This method converts (swaps) EVIO composite type data between Big endian and Little endian.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words. Caller must be sure the endian value of the srcBuf is set properly before the call.
The destBuf can be the same as srcBuf in which case data is swapped in place and the srcBuf byte order is switched in this method.
srcBuf | source data buffer. |
destBuf | destination data buffer. |
srcPos | position in srcBuf to beginning swapping |
destPos | position in destBuf to beginning writing swapped data unless data is swapped in place (then set to srcPos). |
nBytes | length of data to swap in bytes (be sure to account for padding) |
ifmt | format list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &) |
EvioException | if ifmt empty or nBytes < 8; srcBuf or destBuf limit/position combo too small; if src & dest not identical but overlap. |
References evio::ByteBuffer::array(), evio::ByteBuffer::duplicate(), evio::ByteOrder::ENDIAN_BIG, evio::ByteOrder::ENDIAN_LITTLE, evio::ByteBuffer::getByte(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::getShort(), evio::ByteBuffer::limit(), evio::ByteBuffer::order(), evio::ByteBuffer::put(), evio::ByteBuffer::putInt(), evio::ByteBuffer::putLong(), and evio::ByteBuffer::putShort().
|
static |
This method converts (swaps) EVIO composite type data between Big endian and Little endian.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words. The dest can be the same as src in which case data is swapped in place.
Converts the data of array (src[i], i=0...nwrd-1) using the format code (ifmt[j], j=0...nfmt-1) .
Algorithm description:
Data processed inside while (ib < nwrd) loop, where 'ib' is src[] index; loop breaks when 'ib' reaches the number of elements in src[]
src | data source data pointer. |
dest | destination pointer or can be null if swapping in place. |
nwrd | number of data words (32-bit ints) to be swapped. |
ifmt | format list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &). |
padding | number of bytes to ignore in last data word (starting from data end). |
srcIsLocal | true if src is local endian, else false. |
EvioException | if ifmt empty or nwrd < 2; src pointer is null; if src & dest are not identical but overlap. |
|
static |
This method converts (swaps) an array of EVIO composite type data between IEEE (big endian) and DECS (little endian) in place.
This data does NOT include the composite type's beginning tagsegment and the format string it contains. It also does NOT include the data's bank header words.
Converts the data of array (iarr[i], i=0...nwrd-1) using the format code (ifmt[j], j=0...nfmt-1) .
Algorithm description:
Data processed inside while (ib < nwrd) loop, where 'ib' is iarr[] index; loop breaks when 'ib' reaches the number of elements in iarr[]
iarr | pointer to data to be swapped. |
nwrd | number of data words (32-bit ints) to be swapped. |
ifmt | unsigned short vector holding translated format. |
padding | number of bytes to ignore in last data word (starting from data end). |
EvioException | if ifmt empty or nwrd < 2. |
References swapData().
std::string evio::CompositeData::toString | ( | ) | const |
Obtain a string representation of the composite data.
std::string evio::CompositeData::toString | ( | const std::string & | indent, |
bool | hex | ||
) |
Obtain a string representation of the composite data.
This string has an indent inserted in front of each group of 5 items. After each group of 5, a newline is inserted. Useful for writing data in xml format.
indent | a string to insert in front of each group of 5 items |
hex | if true, display numbers in hexadecimal. |
References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::DOUBLE64, evio::DataType::FLOAT32, getChar(), getDouble(), getFloat(), getHollerit(), getInt(), getLong(), getmValue(), getNValue(), getnValue(), getShort(), getStrings(), getUChar(), getUInt(), getULong(), getUShort(), evio::DataType::HOLLERIT, evio::DataType::INT32, evio::DataType::LONG64, evio::DataType::mVALUE, evio::DataType::NVALUE, evio::DataType::nVALUE, evio::DataType::SHORT16, evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, and evio::DataType::USHORT16.
std::string evio::CompositeData::toString | ( | bool | hex | ) | const |
This method returns a string representation of this CompositeData object suitable for displaying in org.jlab.coda.jevio.graphics.EventTreeFrame gui.
Each data item is separated from those before and after by a line. Non-parenthesis repeats are printed together.
hex | if true then print integers in hexadecimal |
References evio::ByteBuffer::array(), evio::ByteBuffer::getByte(), evio::ByteBuffer::getBytes(), evio::ByteBuffer::getDouble(), evio::ByteBuffer::getFloat(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::getShort(), evio::ByteBuffer::getUInt(), evio::ByteBuffer::getULong(), evio::ByteBuffer::getUShort(), evio::ByteBuffer::order(), evio::ByteBuffer::position(), and evio::Util::unpackRawBytesToStrings().