evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::CompositeData Class Reference

#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...
 

Detailed Description

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.

Author
timmer
Date
4/17/2020

Member Function Documentation

int evio::CompositeData::compositeFormatToInt ( const std::string &  formatStr,
std::vector< uint16_t > &  ifmt 
)
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)
Parameters
formatStrcomposite data format string
ifmtunsigned short vector to hold transformed format
Returns
the number of shorts in ifmt[] (positive)
-1 to -8 for improper format string
Author
Sergey Boiarinov

Referenced by parse(), and swapAll().

void evio::CompositeData::dataToRawBytes ( ByteBuffer rawBuf,
CompositeData::Data const &  data,
std::vector< uint16_t > &  ifmt 
)
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[]

Parameters
iarrpointer to data to be swapped
nwrdnumber of data words (32-bit ints) to be swapped
ifmtunsigned short vector holding translated format
paddingnumber of bytes to ignore in last data word (starting from data end)
Returns
0 if success
-1 if nwrd < 0, or ifmt vector empty. This method takes a CompositeData object and a transformed format string and uses that to write data into a buffer/array in raw form.
Parameters
rawBufdata buffer in which to put the raw bytes
datadata to convert to raw bytes
ifmtformat list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &)
Exceptions
EvioExceptionif 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.

void evio::CompositeData::generateRawBytes ( std::vector< std::shared_ptr< CompositeData >> &  data,
std::vector< uint8_t > &  rawBytes,
ByteOrder order 
)
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.

Parameters
datavector of CompositeData objects to turn into bytes (input).
rawBytesvector of raw, evio format bytes (output).
orderbyte 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.

Returns
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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
underflow_errorif at end of data.
EvioExceptionif data is not float.

References evio::DataType::FLOAT32.

Referenced by toString().

std::string evio::CompositeData::getFormat ( ) const

This method gets the format string.

Returns
format string.
int32_t evio::CompositeData::getHollerit ( )

This method gets the next HOLLERIT data item if it's the correct type.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif data is not HOLLERIT.

References evio::DataType::HOLLERIT.

Referenced by toString().

std::shared_ptr< CompositeData > evio::CompositeData::getInstance ( std::string &  format,
const Data data 
)
static

Method to return a shared pointer to a constructed object of this class.

Parameters
formatdata format string.
dataobject containing composite data description.
Returns
shared pointer of CompositeData object.
std::shared_ptr< CompositeData > evio::CompositeData::getInstance ( std::string &  format,
const Data data,
uint16_t  formatTag,
uint16_t  dataTag,
uint8_t  dataNum,
ByteOrder const &  order = ByteOrder::ENDIAN_LOCAL 
)
static

Method to return a shared pointer to a constructed object of this class.

Parameters
formatdata format string.
dataobject containing composite data description.
formatTagtag of evio segment containing format.
dataTagtag of evio bank containing data.
dataNumnum of evio bank containing data.
orderdesired byteOrder of generated raw data. Defaults to local endian.
Returns
shared pointer of CompositeData object.
std::shared_ptr< CompositeData > evio::CompositeData::getInstance ( uint8_t *  bytes,
ByteOrder const &  order = ByteOrder::ENDIAN_LOCAL 
)
static

Method to return a shared pointer to a constructed object of this class.

Parameters
bytespointer to raw data.
orderbyte order of raw data.
Returns
shared pointer of CompositeData object.
std::shared_ptr< CompositeData > evio::CompositeData::getInstance ( ByteBuffer bytes)
static

Method to return a shared pointer to a constructed object of this class.

Parameters
bytesByteBuffer of raw data.
Returns
shared pointer of CompositeData object.
int32_t evio::CompositeData::getInt ( )

This method gets the next data item as an int if it's the correct type.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
reference to vector of all the data items inside the composite.
int64_t evio::CompositeData::getLong ( )

This method gets the next data item as a long if it's the correct type.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
reference to 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
reference to 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.

Returns
reference to 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).

Returns
data padding.
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.

Returns
reference to vector of raw bytes representing of this object's data.
int16_t evio::CompositeData::getShort ( )

This method gets the next data item as a short if it's the correct type.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
reference to vector of strings in data item.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
reference to 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif 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.

Returns
data item value.
Exceptions
std::underflow_errorif at end of data.
EvioExceptionif data is not uint16_t.

References evio::DataType::USHORT16.

Referenced by toString().

uint32_t evio::CompositeData::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.

getInt().

Returns
returns the index of the data item to be returned

Referenced by index().

void evio::CompositeData::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.

getInt().

Parameters
indexthe index of the next data item to be returned

References index().

void evio::CompositeData::parse ( uint8_t *  bytes,
size_t  bytesSize,
ByteOrder const &  order,
std::vector< std::shared_ptr< CompositeData >> &  list 
)
static

This method parses an array of raw bytes into an vector of CompositeData objects.

Vector is initially cleared.

Parameters
bytesarray of raw bytes to parse.
bytesSizesize in bytes of bytes.
orderbyte order of raw bytes.
listvector that will hold all parsed CompositeData objects.
Exceptions
EvioExceptionif 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().

std::string evio::CompositeData::stringsToFormat ( std::vector< std::string >  strings)
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)

Parameters
stringsarray of strings to eventually put into a CompositeData object.
Returns
string representing its format to be used in the CompositeData object's format string; empty string if arg has 0 length.

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.

Exceptions
EvioExceptionif internal error

References swapAll().

void evio::CompositeData::swapAll ( uint8_t *  src,
uint8_t *  dest,
size_t  length,
bool  srcIsLocal 
)
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.

Parameters
srcsource data pointer.
destdestination data pointer.
lengthlength of data array in 32 bit words.
srcIsLocaltrue if the byte order of src data is the same as the node's.
Exceptions
EvioExceptionif 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().

void evio::CompositeData::swapAll ( ByteBuffer buf,
uint32_t  srcPos,
uint32_t  len 
)
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.

Parameters
bufsource and destination data buffer.
srcPosposition in srcBuffer to beginning swapping
lenlength of data in buf to swap in 32 bit words
Exceptions
std::out_of_rangeif srcPos or len too large; if len too small.
EvioExceptionif 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().

void evio::CompositeData::swapAll ( std::shared_ptr< ByteBuffer > &  buf,
uint32_t  srcPos,
uint32_t  len 
)
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.

Parameters
bufsource and destination data buffer.
srcPosposition in srcBuffer to beginning swapping
lenlength of data in buf to swap in 32 bit words
Exceptions
std::out_of_rangeif srcPos or len too large; if len too small.
EvioExceptionif srcBuffer not in evio format;

References swapAll().

void evio::CompositeData::swapAll ( std::shared_ptr< ByteBuffer > &  srcBuf,
std::shared_ptr< ByteBuffer > &  destBuf,
uint32_t  srcPos,
uint32_t  destPos,
uint32_t  len 
)
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!

Parameters
srcBufsource data buffer
destBufdestination data buffer
srcPosposition in srcBuffer to beginning swapping
destPosposition in destBuffer to beginning writing swapped data
lenlength of data in srcBuffer to swap in 32 bit words
Exceptions
EvioExceptionif srcBuffer not in evio format; if destBuffer too small; if bad values for srcPos/destPos/len args;

References swapAll().

void evio::CompositeData::swapAll ( ByteBuffer srcBuffer,
ByteBuffer destBuffer,
uint32_t  srcPos,
uint32_t  destPos,
uint32_t  len 
)
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!

Parameters
srcBuffersource data buffer
destBufferdestination data buffer
srcPosposition in srcBuffer to beginning swapping
destPosposition in destBuffer to beginning writing swapped data
lenlength of data in srcBuffer to swap in 32 bit words
Exceptions
EvioExceptionif 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().

void evio::CompositeData::swapData ( ByteBuffer srcBuf,
ByteBuffer destBuf,
size_t  nBytes,
const std::vector< uint16_t > &  ifmt 
)
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.

Parameters
srcBufsource data buffer.
destBufdestination data buffer.
nByteslength of data to swap in bytes
ifmtformat list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &)
Exceptions
EvioExceptionif 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().

void evio::CompositeData::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 
)
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.

Parameters
srcBufsource data buffer.
destBufdestination data buffer.
srcPosposition in srcBuf to beginning swapping
destPosposition in destBuf to beginning writing swapped data unless data is swapped in place (then set to srcPos).
nByteslength of data to swap in bytes (be sure to account for padding)
ifmtformat list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &)
Exceptions
EvioExceptionif ifmt empty or nBytes < 8; srcBuf or destBuf limit/position combo too small; if src & dest not identical but overlap.

References swapData().

void evio::CompositeData::swapData ( ByteBuffer srcBuf,
ByteBuffer destBuf,
size_t  srcPos,
size_t  destPos,
size_t  nBytes,
const std::vector< uint16_t > &  ifmt 
)
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.

Parameters
srcBufsource data buffer.
destBufdestination data buffer.
srcPosposition in srcBuf to beginning swapping
destPosposition in destBuf to beginning writing swapped data unless data is swapped in place (then set to srcPos).
nByteslength of data to swap in bytes (be sure to account for padding)
ifmtformat list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &)
Exceptions
EvioExceptionif 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().

void evio::CompositeData::swapData ( int32_t *  src,
int32_t *  dest,
size_t  nwrd,
const std::vector< uint16_t > &  ifmt,
uint32_t  padding,
bool  srcIsLocal 
)
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[]

Parameters
srcdata source data pointer.
destdestination pointer or can be null if swapping in place.
nwrdnumber of data words (32-bit ints) to be swapped.
ifmtformat list as produced by compositeFormatToInt(const std::string &, std::vector<uint16_t> &).
paddingnumber of bytes to ignore in last data word (starting from data end).
srcIsLocaltrue if src is local endian, else false.
Exceptions
EvioExceptionif ifmt empty or nwrd < 2; src pointer is null; if src & dest are not identical but overlap.

References SWAP_16, SWAP_32, and SWAP_64.

void evio::CompositeData::swapData ( int32_t *  iarr,
int  nwrd,
const std::vector< uint16_t > &  ifmt,
uint32_t  padding 
)
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[]

Parameters
iarrpointer to data to be swapped.
nwrdnumber of data words (32-bit ints) to be swapped.
ifmtunsigned short vector holding translated format.
paddingnumber of bytes to ignore in last data word (starting from data end).
Exceptions
EvioExceptionif ifmt empty or nwrd < 2.

References swapData().

std::string evio::CompositeData::toString ( ) const

Obtain a string representation of the composite data.

Returns
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.

Parameters
indenta string to insert in front of each group of 5 items
hexif true, display numbers in hexadecimal.
Returns
a string representation of the composite data.

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.

Parameters
hexif true then print integers in hexadecimal
Returns
a string representation of this CompositeData object.

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().


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