evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CompositeData.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_COMPOSITEDATA_H
12 #define EVIO_6_0_COMPOSITEDATA_H
13 
14 
15 #include <vector>
16 #include <cstring>
17 #include <string>
18 #include <cstdint>
19 #include <cstdio>
20 #include <cstdlib>
21 #include <climits>
22 #include <ios>
23 #include <iomanip>
24 #include <exception>
25 #include <stdexcept>
26 #include <sstream>
27 #include <memory>
28 #include <algorithm>
29 
30 
31 #include "ByteOrder.h"
32 #include "ByteBuffer.h"
33 #include "DataType.h"
34 #include "BankHeader.h"
35 #include "SegmentHeader.h"
36 #include "TagSegmentHeader.h"
37 #include "EventHeaderParser.h"
38 #include "EvioNode.h"
39 
40 
41 #undef COMPOSITE_DEBUG
42 #undef COMPOSITE_PRINT
43 
44 // /////////////////////
45 // Doxygen:
46 // For some reason doxygen does NOT extract the documentation for the methods of CompositeData class.
47 // To get around this, just copied the doxygen doc from .cpp to this file.
48 // ////////////////////
49 
50 namespace evio {
51 
97  class CompositeData {
98 
99 
101  typedef struct {
103  int left;
105  int nrepeat;
106  /* Right parenthesis counter, or how many times format in parenthesis already repeated. */
107  int irepeat;
108  } LV;
109 
110 
111  public:
112 
114  union SingleMember {
115 
116  public:
117 
118  // Data being stored
119 
121  float flt;
123  double dbl;
125  uint64_t ul64;
127  int64_t l64;
129  uint32_t ui32;
131  int32_t i32;
133  uint16_t us16;
135  int16_t s16;
137  uint8_t ub8;
139  int8_t b8;
141  bool str;
142  };
143 
144 
153  class DataItem {
154 
155  public:
156 
160  std::vector<std::string> strVec {};
161 
163  DataItem() = default;
164 
169  DataItem(DataItem const &other) {
170  item = other.item;
171  strVec = other.strVec;
172  };
173 
174  };
175 
176 
177 
182  class Data {
183 
184  private:
185 
187  friend class CompositeData;
188 
192  uint32_t dataBytes = 0;
193 
195  uint32_t paddingBytes = 0;
196 
198  uint32_t pads[4] = {0,3,2,1};
199 
201  std::vector<DataItem> dataItems;
202 
204  std::vector<DataType> dataTypes;
205 
208  std::vector<int32_t> Nlist;
209 
212  std::vector<int16_t> nlist;
213 
216  std::vector<int8_t> mlist;
217 
219  uint16_t formatTag = 0;
220 
222  uint16_t dataTag = 0;
223 
225  uint8_t dataNum = 0;
226 
227  public:
228 
230  Data() {
231  dataItems.reserve(200);
232  dataTypes.reserve(200);
233  Nlist.reserve(100);
234  nlist.reserve(100);
235  mlist.reserve(100);
236  }
237 
238  private:
239 
245  void addBytesToData(uint32_t bytes) {
246  dataBytes += bytes;
247  // Pad to 4 byte boundaries.
248  paddingBytes = pads[dataBytes%4];
249  }
250 
251  public:
256  void setFormatTag(uint16_t tag) {formatTag = tag;}
257 
262  void setDataTag(uint16_t tag) {dataTag = tag;}
263 
268  void setDataNum(uint8_t num) {dataNum = num;}
269 
274  uint16_t getFormatTag() const {return formatTag;}
275 
280  uint16_t getDataTag() const {return dataTag;}
281 
286  uint8_t getDataNum() const {return dataNum;}
287 
292  uint32_t getDataSize() const {return (dataBytes + paddingBytes);}
293 
298  uint32_t getPadding() const {return paddingBytes;}
299 
305  void addN(uint32_t N) {
306  Nlist.push_back(N);
307  DataItem mem;
308  mem.item.ui32 = N;
309  dataItems.push_back(mem);
310  dataTypes.push_back(DataType::UINT32);
311  addBytesToData(4);
312  }
313 
319  void addn(uint16_t n) {
320  nlist.push_back(n);
321  DataItem mem;
322  mem.item.us16 = n;
323  dataItems.push_back(mem);
324  dataTypes.push_back(DataType::USHORT16);
325  addBytesToData(2);
326  }
327 
333  void addm(uint8_t m) {
334  mlist.push_back(m);
335  DataItem mem;
336  mem.item.ub8 = m;
337  dataItems.push_back(mem);
338  dataTypes.push_back(DataType::UCHAR8);
339  addBytesToData(1);
340  }
341 
342  //-----------------------------------------------------
343 
348  void addInt(int32_t i) {
349  DataItem mem;
350  mem.item.i32 = i;
351  dataItems.push_back(mem);
352  dataTypes.push_back(DataType::INT32);
353  addBytesToData(4);
354  }
355 
360  void addInt(std::vector<int32_t> const & i) {
361  for (auto ii : i) {
362  DataItem mem;
363  mem.item.i32 = ii;
364  dataItems.push_back(mem);
365  dataTypes.push_back(DataType::INT32);
366  }
367  addBytesToData(4 * i.size());
368  }
369 
374  void addUint(uint32_t i) {
375  DataItem mem;
376  mem.item.ui32 = i;
377  dataItems.push_back(mem);
378  dataTypes.push_back(DataType::UINT32);
379  addBytesToData(4);
380  }
381 
386  void addUint(std::vector<uint32_t> const & i) {
387  for (auto ii : i) {
388  DataItem mem;
389  mem.item.ui32 = ii;
390  dataItems.push_back(mem);
391  dataTypes.push_back(DataType::UINT32);
392  }
393  addBytesToData(4 * i.size());
394  }
395 
396  //-----------------------------------------------------
397 
402  void addShort(int16_t s) {
403  DataItem mem;
404  mem.item.s16 = s;
405  dataItems.push_back(mem);
406  dataTypes.push_back(DataType::SHORT16);
407  addBytesToData(2);
408  }
409 
414  void addShort(std::vector<int16_t> const & s) {
415  for (auto ii : s) {
416  DataItem mem;
417  mem.item.s16 = ii;
418  dataItems.push_back(mem);
419  dataTypes.push_back(DataType::SHORT16);
420  }
421  addBytesToData(2 * s.size());
422  }
423 
428  void addUShort(uint16_t s) {
429  DataItem mem;
430  mem.item.us16 = s;
431  dataItems.push_back(mem);
432  dataTypes.push_back(DataType::USHORT16);
433  addBytesToData(2);
434  }
435 
440  void addUShort(std::vector<uint16_t> const & s) {
441  for (auto ii : s) {
442  DataItem mem;
443  mem.item.us16 = ii;
444  dataItems.push_back(mem);
445  dataTypes.push_back(DataType::USHORT16);
446  }
447  addBytesToData(2 * s.size());
448  }
449 
450  //-----------------------------------------------------
451 
456  void addLong(int64_t l) {
457  DataItem mem;
458  mem.item.l64 = l;
459  dataItems.push_back(mem);
460  dataTypes.push_back(DataType::LONG64);
461  addBytesToData(8);
462  }
463 
468  void addLong(std::vector<int64_t> const & l) {
469  for (auto ii : l) {
470  DataItem mem;
471  mem.item.l64 = ii;
472  dataItems.push_back(mem);
473  dataTypes.push_back(DataType::LONG64);
474  }
475  addBytesToData(8 * l.size());
476  }
477 
482  void addULong(uint64_t l) {
483  DataItem mem;
484  mem.item.ul64 = l;
485  dataItems.push_back(mem);
486  dataTypes.push_back(DataType::ULONG64);
487  addBytesToData(8);
488  }
489 
494  void addULong(std::vector<uint64_t> const & l) {
495  for (auto ii : l) {
496  DataItem mem;
497  mem.item.ul64 = ii;
498  dataItems.push_back(mem);
499  dataTypes.push_back(DataType::ULONG64);
500  }
501  addBytesToData(8 * l.size());
502  }
503 
504  //-----------------------------------------------------
505 
510  void addChar(int8_t b) {
511  DataItem mem;
512  mem.item.b8 = b;
513  dataItems.push_back(mem);
514  dataTypes.push_back(DataType::CHAR8);
515  addBytesToData(1);
516  }
517 
522  void addChar(std::vector<int8_t> const & b) {
523  for (auto ii : b) {
524  DataItem mem;
525  mem.item.b8 = ii;
526  dataItems.push_back(mem);
527  dataTypes.push_back(DataType::CHAR8);
528  }
529  addBytesToData(b.size());
530 
531  }
532 
537  void addUChar(uint8_t b) {
538  DataItem mem;
539  mem.item.ub8 = b;
540  dataItems.push_back(mem);
541  dataTypes.push_back(DataType::UCHAR8);
542  addBytesToData(1);
543  }
544 
549  void addUChar(std::vector<uint8_t> const & b) {
550  for (auto ii : b) {
551  DataItem mem;
552  mem.item.ub8 = ii;
553  dataItems.push_back(mem);
554  dataTypes.push_back(DataType::UCHAR8);
555  }
556  addBytesToData(b.size());
557  }
558 
559  //-----------------------------------------------------
560 
565  void addFloat(float f) {
566  DataItem mem;
567  mem.item.flt = f;
568  dataItems.push_back(mem);
569  dataTypes.push_back(DataType::FLOAT32);
570  addBytesToData(4);
571  }
572 
577  void addFloat(std::vector<float> const & f) {
578  for (auto ff : f) {
579  DataItem mem;
580  mem.item.flt = ff;
581  dataItems.push_back(mem);
582  dataTypes.push_back(DataType::FLOAT32);
583  }
584  addBytesToData(4 * f.size());
585  }
586 
591  void addDouble(double d) {
592  DataItem mem;
593  mem.item.dbl = d;
594  dataItems.push_back(mem);
595  dataTypes.push_back(DataType::DOUBLE64);
596  addBytesToData(8);
597  }
598 
603  void addDouble(std::vector<double> const & d) {
604  for (auto dd : d) {
605  DataItem mem;
606  mem.item.dbl = dd;
607  dataItems.push_back(mem);
608  dataTypes.push_back(DataType::DOUBLE64);
609  }
610  addBytesToData(8 * d.size());
611  }
612 
613  //-----------------------------------------------------
614 
619  void addString(std::string const & s) {
620  std::vector<std::string> v {s};
621  DataItem mem;
622  mem.item.str = true;
623  mem.strVec = v;
624  dataItems.push_back(mem);
625  dataTypes.push_back(DataType::CHARSTAR8);
626  addBytesToData(Util::stringsToRawSize(v));
627  }
628 
633  void addString(std::vector<std::string> const & s) {
634  DataItem mem;
635  mem.item.str = true;
636  mem.strVec = s;
637  dataItems.push_back(mem);
638  dataTypes.push_back(DataType::CHARSTAR8);
639  addBytesToData(Util::stringsToRawSize(s));
640  }
641  };
642 
643 
644  private:
645 
647  std::string format;
648 
650  std::vector<uint16_t> formatInts;
651 
653  std::vector<DataItem> items;
654 
656  std::vector<DataType> types;
657 
659  std::vector<int32_t> NList;
660 
662  std::vector<int16_t> nList;
663 
665  std::vector<int8_t> mList;
666 
668  std::shared_ptr<TagSegmentHeader> tsHeader;
669 
671  std::shared_ptr<BankHeader> bHeader;
672 
674  std::vector<uint8_t> rawBytes;
675 
677  uint32_t dataBytes = 0;
678 
680  uint32_t dataPadding = 0;
681 
683  uint32_t dataOffset = 0;
684 
687 
689  /* mutable ? */
690  uint32_t getIndex = 0;
691 
692 
693 // // Only constructors with raw data or a vector of Data as an arg
694 // // are used. That way there is never an "empty" CompositeData object.
695 // // Thus, each object will have a raw byte representation generated.
696 
697  CompositeData() = default;
698 
699  CompositeData(std::string const & format, const Data & data);
700 
701  CompositeData(std::string const & format,
702  const Data & data,
703  uint16_t formatTag,
704  uint16_t dataTag, uint8_t dataNum,
705  ByteOrder const & order = ByteOrder::ENDIAN_LOCAL);
706 
707  CompositeData(uint8_t *bytes, ByteOrder const & byteOrder);
708 
709  CompositeData(ByteBuffer & bytes);
710 
711  static std::shared_ptr<CompositeData> getInstance();
712 
713 
714  public:
715 
716 
717  static std::shared_ptr<CompositeData> getInstance(std::string & format, const Data & data);
718 
719  static std::shared_ptr<CompositeData> getInstance(std::string & format,
720  const Data & data,
721  uint16_t formatTag,
722  uint16_t dataTag, uint8_t dataNum,
723  ByteOrder const & order = ByteOrder::ENDIAN_LOCAL);
724 
725  static std::shared_ptr<CompositeData> getInstance(uint8_t *bytes,
726  ByteOrder const & order = ByteOrder::ENDIAN_LOCAL);
727 
728  static std::shared_ptr<CompositeData> getInstance(ByteBuffer & bytes);
729 
730  static void parse(uint8_t *bytes, size_t bytesSize, ByteOrder const & order,
731  std::vector<std::shared_ptr<CompositeData>> & list);
732 
733  static void generateRawBytes(std::vector<std::shared_ptr<CompositeData>> & data,
734  std::vector<uint8_t> & rawBytes, ByteOrder & order);
735 
736  static std::string stringsToFormat(std::vector<std::string> strings);
737 
738 
739  static int compositeFormatToInt(const std::string & formatStr, std::vector<uint16_t> & ifmt);
740 
741 
742 
743  uint32_t getPadding() const;
744  std::string getFormat() const;
745  ByteOrder getByteOrder() const;
746 
747 
748  std::vector<uint8_t> & getRawBytes();
749  std::vector<DataItem> & getItems();
750 
751 
752  std::vector<DataType> & getTypes();
753  std::vector<int32_t> & getNValues();
754  std::vector<int16_t> & getnValues();
755  std::vector<int8_t> & getmValues();
756 
757 
758  uint32_t index() const;
759  void index(uint32_t index);
760 
761 
762  int32_t getNValue();
763  int16_t getnValue();
764  int8_t getmValue();
765  int32_t getHollerit();
766 
767 
768  int8_t getChar();
769  uint8_t getUChar();
770 
771 
772  int16_t getShort();
773  uint16_t getUShort();
774  int32_t getInt();
775  uint32_t getUInt();
776 
777 
778  int64_t getLong();
779  uint64_t getULong();
780 
781 
782  float getFloat();
783  double getDouble();
784 
785 
786  std::vector<std::string> & getStrings();
787 
788 
789  void swap();
790 
791 
792  static void swapAll(uint8_t *src, uint8_t *dest, size_t length, bool srcIsLocal);
793 
794 
795  // Swap in place
796  static void swapAll(ByteBuffer & buf, uint32_t srcPos, uint32_t len);
797  static void swapAll(std::shared_ptr<ByteBuffer> & buf, uint32_t srcPos, uint32_t len);
798 
799 
800  // Swap elsewhere
801 
802  static void swapAll(std::shared_ptr<ByteBuffer> & srcBuf,
803  std::shared_ptr<ByteBuffer> & destBuf,
804  uint32_t srcPos, uint32_t destPos, uint32_t len);
805  static void swapAll(ByteBuffer & srcBuffer, ByteBuffer & destBuffer,
806  uint32_t srcPos, uint32_t destPos, uint32_t len);
807 
808 
809 
810  static void swapData(ByteBuffer & srcBuf, ByteBuffer & destBuf,
811  size_t nBytes, const std::vector<uint16_t> & ifmt);
812  static void swapData(std::shared_ptr<ByteBuffer> & srcBuf,
813  std::shared_ptr<ByteBuffer> & destBuf,
814  size_t srcPos, size_t destPos, size_t nBytes,
815  const std::vector<uint16_t> & ifmt);
816  static void swapData(ByteBuffer & srcBuf, ByteBuffer & destBuf,
817  size_t srcPos, size_t destPos, size_t nBytes,
818  const std::vector<uint16_t> & ifmt);
819  static void swapData(int32_t *src, int32_t *dest, size_t nwrd,
820  const std::vector<uint16_t> & ifmt,
821  uint32_t padding, bool srcIsLocal);
822 
823  // This is an in-place swap
824 
825  static void swapData(int32_t *iarr, int nwrd, const std::vector<uint16_t> & ifmt,
826  uint32_t padding);
827 
828 
829  static void dataToRawBytes(ByteBuffer & rawBuf, Data const & data,
830  std::vector<uint16_t> & ifmt);
831 
832 
833  void process();
834 
835 
836  std::string toString() const;
837  std::string toString(const std::string & indent, bool hex);
838  std::string toString(bool hex) const;
839  };
840 
841 
842 }
843 
844 
845 #endif //EVIO_6_0_COMPOSITEDATA_H
int32_t getNValue()
This method gets the next N value data item if it&#39;s the correct type.
Definition: CompositeData.cpp:576
uint32_t getPadding() const
Get the data padding (0, 1, 2, or 3 bytes).
Definition: CompositeData.cpp:491
void addLong(int64_t l)
Add a 64 bit long to the data.
Definition: CompositeData.h:456
static const DataType LONG64
64 bit int.
Definition: DataType.h:45
uint8_t getUChar()
This method gets the next data item as an unsigned byte/char if it&#39;s the correct type.
Definition: CompositeData.cpp:641
uint16_t getDataTag() const
This method gets the tag in the bank containing the data.
Definition: CompositeData.h:280
int32_t getInt()
This method gets the next data item as an int if it&#39;s the correct type.
Definition: CompositeData.cpp:680
static const DataType UCHAR8
Unsigned 8 bit int.
Definition: DataType.h:43
std::vector< uint8_t > & getRawBytes()
This method gets a vector of the raw byte representation of this object&#39;s data.
Definition: CompositeData.cpp:513
static const DataType INT32
32 bit int.
Definition: DataType.h:47
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...
Definition: CompositeData.cpp:1345
uint32_t ui32
Unsigned int value.
Definition: CompositeData.h:129
void addChar(std::vector< int8_t > const &b)
Add an vector of 8 bit bytes (chars) to the data.
Definition: CompositeData.h:522
uint32_t getDataSize() const
This method gets the raw data size in bytes.
Definition: CompositeData.h:292
void addFloat(std::vector< float > const &f)
Add an vector of 32 bit floats to the data.
Definition: CompositeData.h:577
double dbl
Double value.
Definition: CompositeData.h:123
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 &amp; little endian...
Definition: CompositeData.cpp:1018
uint32_t getUInt()
This method gets the next data item as an unsigned int if it&#39;s the correct type.
Definition: CompositeData.cpp:693
DataItem(DataItem const &other)
Copy constructor.
Definition: CompositeData.h:169
static uint32_t stringsToRawSize(std::vector< std::string > const &strings)
This method returns the number of bytes in a raw evio format of the given string array, not including header.
Definition: Util.h:729
void addUShort(std::vector< uint16_t > const &s)
Add an vector of unsigned 16 bit shorts to the data.
Definition: CompositeData.h:440
void addLong(std::vector< int64_t > const &l)
Add an vector of 64 bit longs to the data.
Definition: CompositeData.h:468
uint64_t getULong()
This method gets the next data item as an unsigned long if it&#39;s the correct type. ...
Definition: CompositeData.cpp:719
void addUChar(uint8_t b)
Add an unsigned 8 bit byte (uchar) to the data.
Definition: CompositeData.h:537
void addN(uint32_t N)
This method adds an &quot;N&quot; or multiplier value to the data.
Definition: CompositeData.h:305
void addInt(int32_t i)
Add a signed 32 bit integer to the data.
Definition: CompositeData.h:348
void addUint(uint32_t i)
Add an unsigned 32 bit integer to the data.
Definition: CompositeData.h:374
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 ...
Definition: CompositeData.cpp:2480
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
void addShort(std::vector< int16_t > const &s)
Add an vector of 16 bit shorts to the data.
Definition: CompositeData.h:414
static const DataType CHARSTAR8
ASCII characters.
Definition: DataType.h:39
uint64_t ul64
Unsigned long value.
Definition: CompositeData.h:125
void setFormatTag(uint16_t tag)
This method sets the tag in the segment containing the format string.
Definition: CompositeData.h:256
uint16_t getFormatTag() const
This method gets the tag in the segment containing the format string.
Definition: CompositeData.h:274
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&lt;Typ...
Definition: CompositeData.cpp:558
std::vector< std::string > & getStrings()
This method gets the next data item as a vector of strings if it&#39;s the correct type.
Definition: CompositeData.cpp:758
void swap()
This method swaps the data of this composite type between big &amp; little endian.
Definition: CompositeData.cpp:998
std::vector< DataType > & getTypes()
This method gets a vector of all the types of the data items inside the composite.
Definition: CompositeData.cpp:528
void addn(uint16_t n)
This method adds an &quot;n&quot; or multiplier value to the data.
Definition: CompositeData.h:319
static const DataType DOUBLE64
64 bit double.
Definition: DataType.h:44
void addString(std::string const &s)
Add a single string to the data.
Definition: CompositeData.h:619
void setDataNum(uint8_t num)
This method sets the num in the bank containing the data.
Definition: CompositeData.h:268
void addm(uint8_t m)
This method adds an &quot;m&quot; or multiplier value to the data.
Definition: CompositeData.h:333
This class defines an individual data item.
Definition: CompositeData.h:153
std::vector< DataItem > & getItems()
This method gets a vector of all the data items inside the composite.
Definition: CompositeData.cpp:521
void setDataTag(uint16_t tag)
This method sets the tag in the bank containing the data.
Definition: CompositeData.h:262
static const DataType FLOAT32
32 bit float.
Definition: DataType.h:38
void addDouble(double d)
Add a 64 bit double to the data.
Definition: CompositeData.h:591
std::vector< int16_t > & getnValues()
This method gets a vector of all the n values of the data items inside the composite.
Definition: CompositeData.cpp:542
int16_t getnValue()
This method gets the next n value data item if it&#39;s the correct type.
Definition: CompositeData.cpp:589
uint8_t getDataNum() const
This method gets the num in the bank containing the data.
Definition: CompositeData.h:286
int16_t s16
Signed int value.
Definition: CompositeData.h:135
static std::string stringsToFormat(std::vector< std::string > strings)
This method helps the CompositeData object creator by finding the proper format string parameter for ...
Definition: CompositeData.cpp:475
std::string getFormat() const
This method gets the format string.
Definition: CompositeData.cpp:498
static const DataType SHORT16
16 bit int.
Definition: DataType.h:40
Definition: CompositeData.h:97
void addChar(int8_t b)
Add an 8 bit byte (char) to the data.
Definition: CompositeData.h:510
static const DataType UINT32
Unsigned 32 bit int.
Definition: DataType.h:37
void addULong(std::vector< uint64_t > const &l)
Add an vector of unsigned 64 bit longs to the data.
Definition: CompositeData.h:494
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.
Definition: CompositeData.cpp:426
uint16_t us16
Unsigned short value.
Definition: CompositeData.h:133
Data()
Constructor.
Definition: CompositeData.h:230
static int compositeFormatToInt(const std::string &formatStr, std::vector< uint16_t > &ifmt)
Definition: CompositeData.cpp:814
void addUint(std::vector< uint32_t > const &i)
Add an vector of unsigned 32 bit integers to the data.
Definition: CompositeData.h:386
uint16_t getUShort()
This method gets the next data item as an unsigned short if it&#39;s the correct type.
Definition: CompositeData.cpp:667
static const DataType CHAR8
8 bit int.
Definition: DataType.h:42
int8_t getmValue()
This method gets the next m value data item if it&#39;s the correct type.
Definition: CompositeData.cpp:602
std::string toString() const
Obtain a string representation of the composite data.
Definition: CompositeData.cpp:3137
float flt
Float value.
Definition: CompositeData.h:121
int8_t b8
Signed byte value.
Definition: CompositeData.h:139
void addFloat(float f)
Add a 32 bit float to the data.
Definition: CompositeData.h:565
int32_t i32
Signed int value.
Definition: CompositeData.h:131
bool str
Are we storing strings?
Definition: CompositeData.h:141
double getDouble()
This method gets the next data item as a double if it&#39;s the correct type.
Definition: CompositeData.cpp:745
This class holds a single, primitive type data item.
Definition: CompositeData.h:114
DataItem()=default
No arg constructor.
int8_t getChar()
This method gets the next data item as a byte/char if it&#39;s the correct type.
Definition: CompositeData.cpp:628
int64_t getLong()
This method gets the next data item as a long if it&#39;s the correct type.
Definition: CompositeData.cpp:706
uint32_t getPadding() const
This method gets the padding (in bytes).
Definition: CompositeData.h:298
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. ...
Definition: CompositeData.cpp:299
SingleMember item
Place for holding a primitive type.
Definition: CompositeData.h:158
uint8_t ub8
Unsigned byte value.
Definition: CompositeData.h:137
int64_t l64
Long value.
Definition: CompositeData.h:127
void addShort(int16_t s)
Add a 16 bit short to the data.
Definition: CompositeData.h:402
void addString(std::vector< std::string > const &s)
Add an vector of strings to the data.
Definition: CompositeData.h:633
float getFloat()
This method gets the next data item as a float if it&#39;s the correct type.
Definition: CompositeData.cpp:732
std::vector< int32_t > & getNValues()
This method gets a vector of all the N values of the data items inside the composite.
Definition: CompositeData.cpp:535
void process()
This method extracts and stores all the data items and their types in various lists.
Definition: CompositeData.cpp:2823
void addInt(std::vector< int32_t > const &i)
Add an vector of signed 32 bit integers to the data.
Definition: CompositeData.h:360
int32_t getHollerit()
This method gets the next HOLLERIT data item if it&#39;s the correct type.
Definition: CompositeData.cpp:615
static const DataType USHORT16
Unsigned 16 bit int.
Definition: DataType.h:41
std::vector< std::string > strVec
Place for holding strings, NOT a primitive type.
Definition: CompositeData.h:160
void addULong(uint64_t l)
Add an unsigned 64 bit long to the data.
Definition: CompositeData.h:482
This class is used to provide all data when constructing a CompositeData object.
Definition: CompositeData.h:182
void addUShort(uint16_t s)
Add an unsigned 16 bit short to the data.
Definition: CompositeData.h:428
void addDouble(std::vector< double > const &d)
Add an vector of 64 bit doubles to the data.
Definition: CompositeData.h:603
static const DataType ULONG64
Unsigned 64 bit int.
Definition: DataType.h:46
void addUChar(std::vector< uint8_t > const &b)
Add an vector of unsigned 8 bit bytes (uchars) to the data.
Definition: CompositeData.h:549
int16_t getShort()
This method gets the next data item as a short if it&#39;s the correct type.
Definition: CompositeData.cpp:654
ByteOrder getByteOrder() const
This method gets the raw data byte order.
Definition: CompositeData.cpp:505
std::vector< int8_t > & getmValues()
This method gets a vector of all the m values of the data items inside the composite.
Definition: CompositeData.cpp:549
static const ByteOrder ENDIAN_LOCAL
Local host&#39;s byte order.
Definition: ByteOrder.h:61