From 092c481934c573a5978cc8a2097b6601ba35d792 Mon Sep 17 00:00:00 2001 From: Carl Timmer Date: Fri, 8 Nov 2024 21:19:58 +0000 Subject: [PATCH] Update docs --- .../CC/html/d3/d87/classevio_1_1_util.html | 23 +- .../CC/html/d3/d87/classevio_1_1_util.js | 2 +- .../d6/d36/_composite_data_8h_source.html | 2 +- ...o_compact_structure_handler_8h_source.html | 18 +- .../CC/html/dd/d90/_util_8h_source.html | 1402 ++++++++--------- .../de/d60/classevio_1_1_util-members.html | 2 +- doc-6.0/doxygen/CC/html/functions_func_p.html | 2 +- doc-6.0/doxygen/CC/html/navtreeindex1.js | 2 +- doc-6.0/doxygen/CC/html/search/all_e.js | 2 +- doc-6.0/doxygen/CC/html/search/functions_d.js | 2 +- doc-6.0/javadoc/index-all.html | 5 + .../org/jlab/coda/jevio/Utilities.html | 42 +- .../jlab/coda/jevio/class-use/EvioNode.html | 39 +- 13 files changed, 788 insertions(+), 755 deletions(-) diff --git a/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.html b/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.html index cc4a8c57..6f59f142 100644 --- a/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.html +++ b/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.html @@ -145,9 +145,9 @@ static void printBytes (std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)  This method takes a byte buffer and prints out the desired number of bytes from the given position, in hex. More...
  -static void printBytes (std::shared_ptr< EvioNode > node, uint32_t position, uint32_t bytes, const std::string &label) - This method takes an EvioNode and prints out the desired number of bytes from the backing array from the given position, in hex. More...
-  +static void printBytes (std::shared_ptr< EvioNode > node, uint32_t bytes, const std::string &label) + This method takes an EvioNode and prints out the desired number of bytes from the backing array at the given node's position, in hex. More...
+  static void printBytes (const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)  This method takes a byte buffer and prints out the desired number of bytes from the given position, in hex. More...
  @@ -1009,12 +1009,12 @@

Referenced by printBytes(), and evio::EventWriterV4::writeEventToFile().

+

Referenced by printBytes(), and evio::EventWriterV4::writeEventToFile().

- -

◆ printBytes() [4/5]

+ +

◆ printBytes() [4/5]

@@ -1028,12 +1028,6 @@

std::shared_ptr< EvioNodenode, - - - - uint32_t  - position, - @@ -1059,12 +1053,11 @@

-

This method takes an EvioNode and prints out the desired number of bytes from the backing array from the given position, in hex.

+

This method takes an EvioNode and prints out the desired number of bytes from the backing array at the given node's position, in hex.

Prints all bytes.

Parameters
- - +
bufnode with backing buffer to print out
positionposition of data (bytes) in buffer to start printing
nodenode with backing buffer to print out
bytesnumber of bytes to print in hex
labela label to print as header
diff --git a/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.js b/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.js index 3d645813..d862743b 100644 --- a/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.js +++ b/doc-6.0/doxygen/CC/html/d3/d87/classevio_1_1_util.js @@ -14,7 +14,7 @@ var classevio_1_1_util = [ "printBytes", "d3/d87/classevio_1_1_util.html#a66847f39ab5cf153f005866eb5332fce", null ], [ "printBytes", "d3/d87/classevio_1_1_util.html#af69bace572e57dd144399015a87bcaef", null ], [ "printBytes", "d3/d87/classevio_1_1_util.html#a010e647b8553d03811f1c48a9908904a", null ], - [ "printBytes", "d3/d87/classevio_1_1_util.html#a25563cae3636dbc8de2fba2452e45260", null ], + [ "printBytes", "d3/d87/classevio_1_1_util.html#ac3f1f3596d09f90c15ec49b17964c180", null ], [ "printBytes", "d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0", null ], [ "readBytes", "d3/d87/classevio_1_1_util.html#a8a0fcfe01a261f79b571a12dba7faee4", null ], [ "stringBuilderToStrings", "d3/d87/classevio_1_1_util.html#a3533bfa3ba79b476ba13485657fb89e6", null ], diff --git a/doc-6.0/doxygen/CC/html/d6/d36/_composite_data_8h_source.html b/doc-6.0/doxygen/CC/html/d6/d36/_composite_data_8h_source.html index 1487e4d7..46b86798 100644 --- a/doc-6.0/doxygen/CC/html/d6/d36/_composite_data_8h_source.html +++ b/doc-6.0/doxygen/CC/html/d6/d36/_composite_data_8h_source.html @@ -781,7 +781,7 @@
static const DataType USHORT16
Unsigned 16 bit int.
Definition: DataType.h:41
static const DataType UINT32
Unsigned 32 bit int.
Definition: DataType.h:37
static const DataType INT32
32 bit int.
Definition: DataType.h:47
-
static size_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,...
Definition: Util.h:745
+
static size_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,...
Definition: Util.h:742
Copyright (c) 2019, Jefferson Science Associates.
Definition: BankHeader.cpp:14
This class holds a single, primitive type data item.
Definition: CompositeData.h:117
uint32_t ui32
Unsigned int value.
Definition: CompositeData.h:132
diff --git a/doc-6.0/doxygen/CC/html/dc/d1e/_evio_compact_structure_handler_8h_source.html b/doc-6.0/doxygen/CC/html/dc/d1e/_evio_compact_structure_handler_8h_source.html index 020b23bc..2608c1b2 100644 --- a/doc-6.0/doxygen/CC/html/dc/d1e/_evio_compact_structure_handler_8h_source.html +++ b/doc-6.0/doxygen/CC/html/dc/d1e/_evio_compact_structure_handler_8h_source.html @@ -191,20 +191,20 @@
Numerical values associated with evio data types.
Definition: DataType.h:32
This class is used to read the bytes of just an evio structure (NOT a full evio formatted file or buf...
Definition: EvioCompactStructureHandler.h:43
std::shared_ptr< EvioNode > getStructure()
Get the EvioNode object associated with the structure.
Definition: EvioCompactStructureHandler.cpp:228
-
std::shared_ptr< ByteBuffer > removeStructure(std::shared_ptr< EvioNode > removeNode)
This method removes the data, represented by the given node, from the buffer.
Definition: EvioCompactStructureHandler.cpp:588
+
std::shared_ptr< ByteBuffer > removeStructure(std::shared_ptr< EvioNode > removeNode)
This method removes the data, represented by the given node, from the buffer.
Definition: EvioCompactStructureHandler.cpp:587
std::shared_ptr< ByteBuffer > getByteBuffer()
Get the byte buffer being read.
Definition: EvioCompactStructureHandler.cpp:221
void setBuffer(std::shared_ptr< ByteBuffer > buf, const DataType &type)
This method can be used to avoid creating additional EvioCompactStructureHandler objects by reusing t...
Definition: EvioCompactStructureHandler.cpp:76
-
std::vector< std::shared_ptr< EvioNode > > getNodes()
This method returns a vector of all evio structures in buffer as EvioNode objects.
Definition: EvioCompactStructureHandler.cpp:866
-
std::vector< std::shared_ptr< EvioNode > > getChildNodes()
This method returns a vector of all child evio structures in buffer as EvioNode objects.
Definition: EvioCompactStructureHandler.cpp:882
+
std::vector< std::shared_ptr< EvioNode > > getNodes()
This method returns a vector of all evio structures in buffer as EvioNode objects.
Definition: EvioCompactStructureHandler.cpp:865
+
std::vector< std::shared_ptr< EvioNode > > getChildNodes()
This method returns a vector of all child evio structures in buffer as EvioNode objects.
Definition: EvioCompactStructureHandler.cpp:881
EvioCompactStructureHandler(std::shared_ptr< EvioNode > node)
Constructor for reading an EvioNode object.
Definition: EvioCompactStructureHandler.cpp:27
-
std::vector< std::shared_ptr< EvioNode > > searchStructure(uint16_t tag, uint8_t num)
This method searches the event and returns a vector of objects each of which contain information abou...
Definition: EvioCompactStructureHandler.cpp:379
+
std::vector< std::shared_ptr< EvioNode > > searchStructure(uint16_t tag, uint8_t num)
This method searches the event and returns a vector of objects each of which contain information abou...
Definition: EvioCompactStructureHandler.cpp:378
bool isClosed()
Has close() been called (without reopening by calling setBuffer)?
Definition: EvioCompactStructureHandler.cpp:204
std::shared_ptr< EvioNode > getScannedStructure()
Get the EvioNode object associated with the structure which has been scanned so all substructures are...
Definition: EvioCompactStructureHandler.cpp:238
-
std::shared_ptr< ByteBuffer > addStructure(std::shared_ptr< ByteBuffer > addBuffer)
This method adds a bank, segment, or tagsegment onto the end of a structure which contains banks,...
Definition: EvioCompactStructureHandler.cpp:472
-
void close()
This only sets the position to its initial value.
Definition: EvioCompactStructureHandler.cpp:895
-
std::shared_ptr< ByteBuffer > getData(std::shared_ptr< EvioNode > node)
Get the data associated with an evio structure in ByteBuffer form.
Definition: EvioCompactStructureHandler.cpp:751
-
std::shared_ptr< ByteBuffer > getStructureBuffer(std::shared_ptr< EvioNode > node)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
Definition: EvioCompactStructureHandler.cpp:807
-
std::vector< std::shared_ptr< EvioNode > > scanStructure()
This method scans the event in the buffer.
Definition: EvioCompactStructureHandler.cpp:352
+
std::shared_ptr< ByteBuffer > addStructure(std::shared_ptr< ByteBuffer > addBuffer)
This method adds a bank, segment, or tagsegment onto the end of a structure which contains banks,...
Definition: EvioCompactStructureHandler.cpp:471
+
void close()
This only sets the position to its initial value.
Definition: EvioCompactStructureHandler.cpp:894
+
std::shared_ptr< ByteBuffer > getData(std::shared_ptr< EvioNode > node)
Get the data associated with an evio structure in ByteBuffer form.
Definition: EvioCompactStructureHandler.cpp:750
+
std::shared_ptr< ByteBuffer > getStructureBuffer(std::shared_ptr< EvioNode > node)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
Definition: EvioCompactStructureHandler.cpp:806
+
std::vector< std::shared_ptr< EvioNode > > scanStructure()
This method scans the event in the buffer.
Definition: EvioCompactStructureHandler.cpp:351
ByteOrder getByteOrder()
Get the byte order of buffer being read.
Definition: EvioCompactStructureHandler.cpp:214
Copyright (c) 2019, Jefferson Science Associates.
Definition: BankHeader.cpp:14

diff --git a/doc-6.0/doxygen/CC/html/dd/d90/_util_8h_source.html b/doc-6.0/doxygen/CC/html/dd/d90/_util_8h_source.html index 9c8ee2b4..d0f075a2 100644 --- a/doc-6.0/doxygen/CC/html/dd/d90/_util_8h_source.html +++ b/doc-6.0/doxygen/CC/html/dd/d90/_util_8h_source.html @@ -416,704 +416,702 @@
460  printBytes(*buf, position, bytes, label);
461  }
462 
-
472  static void printBytes(std::shared_ptr<EvioNode> node, uint32_t position, uint32_t bytes,
-
473  const std::string & label) {
-
474  auto buf = node->getBuffer();
-
475  printBytes(*buf, position, bytes, label);
-
476  }
-
477 
-
487  static void printBytes(const ByteBuffer & buf, uint32_t position, uint32_t bytes, const std::string & label) {
-
488 
-
489  // Make sure we stay in bounds
-
490  bytes = bytes + position > buf.capacity() ? (buf.capacity() - position) : bytes;
+
471  static void printBytes(std::shared_ptr<EvioNode> node, uint32_t bytes, const std::string & label) {
+
472  auto buf = node->getBuffer();
+
473  printBytes(*buf, node->getPosition(), bytes, label);
+
474  }
+
475 
+
485  static void printBytes(const ByteBuffer & buf, uint32_t position, uint32_t bytes, const std::string & label) {
+
486 
+
487  // Make sure we stay in bounds
+
488  bytes = bytes + position > buf.capacity() ? (buf.capacity() - position) : bytes;
+
489 
+
490  if (!label.empty()) std::cout << label << ":" << std::endl;
491 
-
492  if (!label.empty()) std::cout << label << ":" << std::endl;
-
493 
-
494  if (bytes < 1) {
-
495  std::cout << " no data in buf from position = " << position << std::endl;
-
496  return;
-
497  }
-
498 
-
499  for (uint32_t i=0; i < bytes; i++) {
-
500  if (i%20 == 0) {
-
501  std::cout << std::endl << std::dec << std::right << std::setfill(' ') <<
-
502  " Buf(" << std::setw(3) << (i + 1) <<
-
503  " - "<< std::setw(3) << (i + 20) << ") = ";
-
504  }
-
505  else if (i%4 == 0) {
-
506  std::cout << " ";
-
507  }
-
508  // Accessing buf in this way does not change position or limit of buffer
-
509  std::cout << std::hex << std::noshowbase << std::internal << std::setfill('0') <<
-
510  std::setw(2) << (int)(buf[i + position]) << " ";
-
511  }
-
512 
-
513  std::cout << std::dec << std::endl << std::endl << std::setfill(' ');
-
514  std::cout << "DONE WITH printBytes" << std::endl;
-
515  }
-
516 
-
517 
-
526  static void printBytes(uint8_t const * data, uint32_t bytes, const std::string & label) {
-
527 
-
528  if (!label.empty()) std::cout << label << ":" << std::endl;
-
529 
-
530  if (bytes < 1) {
-
531  return;
-
532  }
-
533 
-
534  for (uint32_t i=0; i < bytes; i++) {
-
535  if (i%20 == 0) {
-
536  std::cout << std::endl << std::dec << std::right << std::setfill(' ') <<
-
537  " Buf(" << std::setw(3) << (i + 1) <<
-
538  " - "<< std::setw(3) << (i + 20) << ") = ";
+
492  if (bytes < 1) {
+
493  std::cout << " no data in buf from position = " << position << std::endl;
+
494  return;
+
495  }
+
496 
+
497  for (uint32_t i=0; i < bytes; i++) {
+
498  if (i%20 == 0) {
+
499  std::cout << std::endl << std::dec << std::right << std::setfill(' ') <<
+
500  " Buf(" << std::setw(3) << (i + 1) <<
+
501  " - "<< std::setw(3) << (i + 20) << ") = ";
+
502  }
+
503  else if (i%4 == 0) {
+
504  std::cout << " ";
+
505  }
+
506  // Accessing buf in this way does not change position or limit of buffer
+
507  std::cout << std::hex << std::noshowbase << std::internal << std::setfill('0') <<
+
508  std::setw(2) << (int)(buf[i + position]) << " ";
+
509  }
+
510 
+
511  std::cout << std::dec << std::endl << std::endl << std::setfill(' ');
+
512  }
+
513 
+
514 
+
523  static void printBytes(uint8_t const * data, uint32_t bytes, const std::string & label) {
+
524 
+
525  if (!label.empty()) std::cout << label << ":" << std::endl;
+
526 
+
527  if (bytes < 1) {
+
528  return;
+
529  }
+
530 
+
531  for (uint32_t i=0; i < bytes; i++) {
+
532  if (i%20 == 0) {
+
533  std::cout << std::endl << std::dec << std::right << std::setfill(' ') <<
+
534  " Buf(" << std::setw(3) << (i + 1) <<
+
535  " - "<< std::setw(3) << (i + 20) << ") = ";
+
536  }
+
537  else if (i%4 == 0) {
+
538  std::cout << " ";
539  }
-
540  else if (i%4 == 0) {
-
541  std::cout << " ";
-
542  }
-
543  // Accessing buf in this way does not change position or limit of buffer
-
544  std::cout << std::hex << std::noshowbase << std::internal << std::setfill('0') <<
-
545  std::setw(2) << (int)(*((data + i))) << " ";
-
546  }
+
540  // Accessing buf in this way does not change position or limit of buffer
+
541  std::cout << std::hex << std::noshowbase << std::internal << std::setfill('0') <<
+
542  std::setw(2) << (int)(*((data + i))) << " ";
+
543  }
+
544 
+
545  std::cout << std::dec << std::endl << std::endl << std::setfill(' ');
+
546  }
547 
-
548  std::cout << std::dec << std::endl << std::endl << std::setfill(' ');
-
549  }
-
550 
-
551 
-
561  static void printBytes(const std::string & fileName, uint64_t offset,
-
562  uint32_t bytes, const std::string & label) {
-
563 
-
564  if (fileName.empty()) {
-
565  std::cout << "Util::printBytes: fileName arg is invalid" << std::endl;
-
566  return;
-
567  }
+
548 
+
558  static void printBytes(const std::string & fileName, uint64_t offset,
+
559  uint32_t bytes, const std::string & label) {
+
560 
+
561  if (fileName.empty()) {
+
562  std::cout << "Util::printBytes: fileName arg is invalid" << std::endl;
+
563  return;
+
564  }
+
565 
+
566  try {
+
567  std::ifstream inStreamRandom;
568 
-
569  try {
-
570  std::ifstream inStreamRandom;
-
571 
-
572  // "ate" mode flag will go immediately to file's end (do this to get its size)
-
573  inStreamRandom.open(fileName, std::ios::in | std::ios::ate);
-
574  size_t fileSize = inStreamRandom.tellg();
-
575  // Go back to beginning of file
-
576  inStreamRandom.seekg(0);
-
577 
-
578  // read data
-
579  uint64_t limit = bytes + offset > fileSize ? fileSize : bytes + offset;
-
580  auto dataLen = (uint32_t)(limit - offset);
-
581  ByteBuffer buf(dataLen);
-
582  uint8_t * array = buf.array();
-
583  inStreamRandom.read(reinterpret_cast<char *>(array), dataLen);
-
584 
-
585  printBytes(buf, 0, dataLen, label);
-
586  }
-
587  catch (std::exception & e) {
-
588  // e.what() does not give any useful information...
-
589  std::cout << "Util::printBytes: " << strerror(errno) << std::endl;
-
590  }
-
591  }
-
592 
-
593 
-
601  static void writeBytes(const std::string & fileName, ByteBuffer & buf) {
-
602 
-
603  if (fileName.empty()) {
-
604  std::cout << "Util::writeBytes: fileName arg is invalid" << std::endl;
-
605  throw EvioException("fileName arg is invalid");
-
606  }
-
607 
-
608  std::fstream file;
-
609  file.open(fileName, std::ios::binary | std::ios::out);
-
610  if (file.fail()) {
-
611  std::cout << "error opening file " << fileName << std::endl;
-
612  throw EvioException("error opening file " + fileName);
-
613  }
-
614 
-
615  // Write this into a file
-
616  file.write(reinterpret_cast<char *>(buf.array() + buf.arrayOffset() + buf.position()),
-
617  buf.remaining());
-
618 
-
619  if (file.fail()) {
-
620  std::cout << "error writing to file " << fileName << std::endl;
-
621  throw EvioException("error writing to file " + fileName);
-
622  }
-
623  file.close();
-
624  }
-
625 
-
626 
-
636  static void readBytes(const std::string & fileName, ByteBuffer & buf) {
-
637 
-
638  if (fileName.empty()) {
-
639  std::cout << "Util::writeBytes: fileName arg is invalid" << std::endl;
-
640  throw EvioException("fileName arg is invalid");
-
641  }
-
642 
-
643  std::fstream file;
-
644  file.open(fileName, std::ios::binary | std::ios::in);
-
645  if (file.fail()) {
-
646  std::cout << "error opening file " << fileName << std::endl;
-
647  throw EvioException("error opening file " + fileName);
-
648  }
-
649 
-
650  // Write this into a file
-
651  file.read(reinterpret_cast<char *>(buf.array() + buf.arrayOffset() + buf.position()),
-
652  buf.remaining());
-
653 
-
654  if (file.fail()) {
-
655  std::cout << "error reading from file " << fileName << std::endl;
-
656  throw EvioException("error reading from file " + fileName);
-
657  }
-
658  file.close();
-
659  buf.position(buf.limit());
-
660  }
-
661 
-
662 
-
670  static int powerOfTwo(int x, bool roundUp) {
-
671  if (x < 0) return -1;
+
569  // "ate" mode flag will go immediately to file's end (do this to get its size)
+
570  inStreamRandom.open(fileName, std::ios::in | std::ios::ate);
+
571  size_t fileSize = inStreamRandom.tellg();
+
572  // Go back to beginning of file
+
573  inStreamRandom.seekg(0);
+
574 
+
575  // read data
+
576  uint64_t limit = bytes + offset > fileSize ? fileSize : bytes + offset;
+
577  auto dataLen = (uint32_t)(limit - offset);
+
578  ByteBuffer buf(dataLen);
+
579  uint8_t * array = buf.array();
+
580  inStreamRandom.read(reinterpret_cast<char *>(array), dataLen);
+
581 
+
582  printBytes(buf, 0, dataLen, label);
+
583  }
+
584  catch (std::exception & e) {
+
585  // e.what() does not give any useful information...
+
586  std::cout << "Util::printBytes: " << strerror(errno) << std::endl;
+
587  }
+
588  }
+
589 
+
590 
+
598  static void writeBytes(const std::string & fileName, ByteBuffer & buf) {
+
599 
+
600  if (fileName.empty()) {
+
601  std::cout << "Util::writeBytes: fileName arg is invalid" << std::endl;
+
602  throw EvioException("fileName arg is invalid");
+
603  }
+
604 
+
605  std::fstream file;
+
606  file.open(fileName, std::ios::binary | std::ios::out);
+
607  if (file.fail()) {
+
608  std::cout << "error opening file " << fileName << std::endl;
+
609  throw EvioException("error opening file " + fileName);
+
610  }
+
611 
+
612  // Write this into a file
+
613  file.write(reinterpret_cast<char *>(buf.array() + buf.arrayOffset() + buf.position()),
+
614  buf.remaining());
+
615 
+
616  if (file.fail()) {
+
617  std::cout << "error writing to file " << fileName << std::endl;
+
618  throw EvioException("error writing to file " + fileName);
+
619  }
+
620  file.close();
+
621  }
+
622 
+
623 
+
633  static void readBytes(const std::string & fileName, ByteBuffer & buf) {
+
634 
+
635  if (fileName.empty()) {
+
636  std::cout << "Util::writeBytes: fileName arg is invalid" << std::endl;
+
637  throw EvioException("fileName arg is invalid");
+
638  }
+
639 
+
640  std::fstream file;
+
641  file.open(fileName, std::ios::binary | std::ios::in);
+
642  if (file.fail()) {
+
643  std::cout << "error opening file " << fileName << std::endl;
+
644  throw EvioException("error opening file " + fileName);
+
645  }
+
646 
+
647  // Write this into a file
+
648  file.read(reinterpret_cast<char *>(buf.array() + buf.arrayOffset() + buf.position()),
+
649  buf.remaining());
+
650 
+
651  if (file.fail()) {
+
652  std::cout << "error reading from file " << fileName << std::endl;
+
653  throw EvioException("error reading from file " + fileName);
+
654  }
+
655  file.close();
+
656  buf.position(buf.limit());
+
657  }
+
658 
+
659 
+
667  static int powerOfTwo(int x, bool roundUp) {
+
668  if (x < 0) return -1;
+
669 
+
670  // The following algorithm is found in
+
671  // "Hacker's Delight" by Henry Warren Jr.
672 
-
673  // The following algorithm is found in
-
674  // "Hacker's Delight" by Henry Warren Jr.
-
675 
-
676  if (roundUp) {
-
677  x = x - 1;
-
678  x |= (x>>1);
-
679  x |= (x>>2);
-
680  x |= (x>>4);
-
681  x |= (x>>8);
-
682  x |= (x>>16);
-
683  return x + 1;
-
684  }
-
685 
-
686  int y;
-
687  do {
-
688  y = x;
-
689  x &= (x - 1);
-
690  } while (x != 0);
-
691  return y;
-
692  }
-
693 
-
694 
-
700  static void stringToASCII(const std::string & input, std::vector<uint8_t> & array) {
-
701  size_t inputSize = input.size();
-
702  array.clear();
-
703  array.reserve(inputSize);
-
704 
-
705  for (size_t i=0; i < inputSize; i++) {
-
706  array.push_back((uint8_t) input[i]);
-
707  }
-
708  }
-
709 
-
710 
-
717  static void stringToASCII(const std::string & input, ByteBuffer & buf) {
-
718  size_t inputSize = input.size();
-
719  buf.clear();
-
720  buf.expand(inputSize);
-
721 
-
722  for (size_t i=0; i < inputSize; i++) {
-
723  buf.put(i, input[i]);
-
724  }
-
725  }
-
726 
-
727 
-
729  //
-
730  // Methods for parsing strings in evio format.
-
731  // These are placed here to break the circular dependency between
-
732  // BaseStructure and CompositeData.
-
733  //
-
735 
-
736 
-
745  static size_t stringsToRawSize(std::vector<std::string> const & strings) {
-
746 
-
747  if (strings.empty()) {
-
748  return 0;
-
749  }
-
750 
-
751  size_t dataLen = 0;
-
752  for (std::string const & s : strings) {
-
753  dataLen += s.length() + 1; // don't forget the null char after each string
-
754  }
-
755 
-
756  // Add any necessary padding to 4 byte boundaries.
-
757  // IMPORTANT: There must be at least one '\004'
-
758  // character at the end. This distinguishes evio
-
759  // string array version from earlier version.
-
760  int pads[] = {4,3,2,1};
-
761  dataLen += pads[dataLen%4];
+
673  if (roundUp) {
+
674  x = x - 1;
+
675  x |= (x>>1);
+
676  x |= (x>>2);
+
677  x |= (x>>4);
+
678  x |= (x>>8);
+
679  x |= (x>>16);
+
680  return x + 1;
+
681  }
+
682 
+
683  int y;
+
684  do {
+
685  y = x;
+
686  x &= (x - 1);
+
687  } while (x != 0);
+
688  return y;
+
689  }
+
690 
+
691 
+
697  static void stringToASCII(const std::string & input, std::vector<uint8_t> & array) {
+
698  size_t inputSize = input.size();
+
699  array.clear();
+
700  array.reserve(inputSize);
+
701 
+
702  for (size_t i=0; i < inputSize; i++) {
+
703  array.push_back((uint8_t) input[i]);
+
704  }
+
705  }
+
706 
+
707 
+
714  static void stringToASCII(const std::string & input, ByteBuffer & buf) {
+
715  size_t inputSize = input.size();
+
716  buf.clear();
+
717  buf.expand(inputSize);
+
718 
+
719  for (size_t i=0; i < inputSize; i++) {
+
720  buf.put(i, input[i]);
+
721  }
+
722  }
+
723 
+
724 
+
726  //
+
727  // Methods for parsing strings in evio format.
+
728  // These are placed here to break the circular dependency between
+
729  // BaseStructure and CompositeData.
+
730  //
+
732 
+
733 
+
742  static size_t stringsToRawSize(std::vector<std::string> const & strings) {
+
743 
+
744  if (strings.empty()) {
+
745  return 0;
+
746  }
+
747 
+
748  size_t dataLen = 0;
+
749  for (std::string const & s : strings) {
+
750  dataLen += s.length() + 1; // don't forget the null char after each string
+
751  }
+
752 
+
753  // Add any necessary padding to 4 byte boundaries.
+
754  // IMPORTANT: There must be at least one '\004'
+
755  // character at the end. This distinguishes evio
+
756  // string array version from earlier version.
+
757  int pads[] = {4,3,2,1};
+
758  dataLen += pads[dataLen%4];
+
759 
+
760  return dataLen;
+
761  }
762 
-
763  return dataLen;
-
764  }
-
765 
-
766 
-
774  static uint32_t stringToRawSize(const std::string & str) {
-
775 
-
776  if (str.empty()) {
-
777  return 0;
-
778  }
-
779 
-
780  uint32_t dataLen = str.length() + 1; // don't forget the null char after each string
-
781 
-
782  // Add any necessary padding to 4 byte boundaries.
-
783  // IMPORTANT: There must be at least one '\004'
-
784  // character at the end. This distinguishes evio
-
785  // string array version from earlier version.
-
786  int pads[] = {4,3,2,1};
-
787  dataLen += pads[dataLen%4];
+
763 
+
771  static uint32_t stringToRawSize(const std::string & str) {
+
772 
+
773  if (str.empty()) {
+
774  return 0;
+
775  }
+
776 
+
777  uint32_t dataLen = str.length() + 1; // don't forget the null char after each string
+
778 
+
779  // Add any necessary padding to 4 byte boundaries.
+
780  // IMPORTANT: There must be at least one '\004'
+
781  // character at the end. This distinguishes evio
+
782  // string array version from earlier version.
+
783  int pads[] = {4,3,2,1};
+
784  dataLen += pads[dataLen%4];
+
785 
+
786  return dataLen;
+
787  }
788 
-
789  return dataLen;
-
790  }
-
791 
-
792 
-
800  static void stringsToRawBytes(std::vector<std::string> & strings,
-
801  std::vector<uint8_t> & bytes) {
-
802 
-
803  if (strings.empty()) {
-
804  bytes.clear();
-
805  return;
-
806  }
-
807 
-
808  // create some storage
-
809  size_t dataLen = stringsToRawSize(strings);
-
810  std::string strData;
-
811  strData.reserve(dataLen);
-
812 
-
813  for (std::string const & s : strings) {
-
814  // add string
-
815  strData.append(s);
-
816  // add ending null
-
817  strData.append(1, '\000');
-
818  }
-
819 
-
820  // Add any necessary padding to 4 byte boundaries.
-
821  // IMPORTANT: There must be at least one '\004'
-
822  // character at the end. This distinguishes evio
-
823  // string array version from earlier version.
-
824  int pads[] = {4,3,2,1};
-
825  switch (pads[strData.length()%4]) {
-
826  case 4:
-
827  strData.append(4, '\004');
+
789 
+
797  static void stringsToRawBytes(std::vector<std::string> & strings,
+
798  std::vector<uint8_t> & bytes) {
+
799 
+
800  if (strings.empty()) {
+
801  bytes.clear();
+
802  return;
+
803  }
+
804 
+
805  // create some storage
+
806  size_t dataLen = stringsToRawSize(strings);
+
807  std::string strData;
+
808  strData.reserve(dataLen);
+
809 
+
810  for (std::string const & s : strings) {
+
811  // add string
+
812  strData.append(s);
+
813  // add ending null
+
814  strData.append(1, '\000');
+
815  }
+
816 
+
817  // Add any necessary padding to 4 byte boundaries.
+
818  // IMPORTANT: There must be at least one '\004'
+
819  // character at the end. This distinguishes evio
+
820  // string array version from earlier version.
+
821  int pads[] = {4,3,2,1};
+
822  switch (pads[strData.length()%4]) {
+
823  case 4:
+
824  strData.append(4, '\004');
+
825  break;
+
826  case 3:
+
827  strData.append(3, '\004');
828  break;
-
829  case 3:
-
830  strData.append(3, '\004');
+
829  case 2:
+
830  strData.append(2, '\004');
831  break;
-
832  case 2:
-
833  strData.append(2, '\004');
-
834  break;
-
835  case 1:
-
836  strData.append(1, '\004');
-
837  }
-
838 
-
839  // Transform to ASCII
-
840  bytes.resize(dataLen);
-
841  for (size_t i=0; i < strData.length(); i++) {
-
842  bytes[i] = strData[i];
-
843  }
-
844  }
-
845 
-
846 
-
854  static void unpackRawBytesToStrings(std::vector<uint8_t> & bytes, size_t offset,
-
855  std::vector<std::string> & strData) {
-
856  unpackRawBytesToStrings(bytes, offset, bytes.size(), strData);
-
857  }
-
858 
-
859 
-
870  static void unpackRawBytesToStrings(std::vector<uint8_t> & bytes,
-
871  size_t offset, size_t maxLength,
-
872  std::vector<std::string> & strData) {
-
873  size_t length = bytes.size() - offset;
-
874  if (bytes.empty() || (length < 4)) return;
+
832  case 1:
+
833  strData.append(1, '\004');
+
834  }
+
835 
+
836  // Transform to ASCII
+
837  bytes.resize(dataLen);
+
838  for (size_t i=0; i < strData.length(); i++) {
+
839  bytes[i] = strData[i];
+
840  }
+
841  }
+
842 
+
843 
+
851  static void unpackRawBytesToStrings(std::vector<uint8_t> & bytes, size_t offset,
+
852  std::vector<std::string> & strData) {
+
853  unpackRawBytesToStrings(bytes, offset, bytes.size(), strData);
+
854  }
+
855 
+
856 
+
867  static void unpackRawBytesToStrings(std::vector<uint8_t> & bytes,
+
868  size_t offset, size_t maxLength,
+
869  std::vector<std::string> & strData) {
+
870  size_t length = bytes.size() - offset;
+
871  if (bytes.empty() || (length < 4)) return;
+
872 
+
873  // Don't read read more than maxLength ASCII characters
+
874  length = length > maxLength ? maxLength : length;
875 
-
876  // Don't read read more than maxLength ASCII characters
-
877  length = length > maxLength ? maxLength : length;
-
878 
-
879  std::string sData(reinterpret_cast<const char *>(bytes.data()) + offset, length);
-
880  return stringBuilderToStrings(sData, true, strData);
-
881  }
-
882 
-
883 
-
893  static void unpackRawBytesToStrings(uint8_t *bytes, size_t length,
-
894  std::vector<std::string> & strData) {
-
895  if (bytes == nullptr) return;
-
896 
-
897  std::string sData(reinterpret_cast<const char *>(bytes), length);
-
898  // std::cout << "unpackRawBytesToStrings: string = " << sData << std::endl;
-
899  return stringBuilderToStrings(sData, true, strData);
-
900  }
-
901 
-
902 
-
911  static void unpackRawBytesToStrings(ByteBuffer & buffer,
-
912  size_t pos, size_t length,
-
913  std::vector<std::string> & strData) {
-
914 
-
915  if (length < 4) return;
-
916 
-
917  std::string sData(reinterpret_cast<const char *>(buffer.array() + buffer.arrayOffset()) + pos, length);
-
918  return stringBuilderToStrings(sData, false, strData);
-
919  }
-
920 
-
921 
-
937  static void stringBuilderToStrings(std::string const & strData, bool onlyGoodChars,
-
938  std::vector<std::string> & strings) {
-
939 
-
940  // Each string is terminated with a null (char val = 0)
-
941  // and in addition, the end is padded by ASCII 4's (char val = 4).
-
942  // However, in the legacy versions of evio, there is only one
-
943  // null-terminated string and anything as padding. To accommodate legacy evio, if
-
944  // there is not an ending ASCII value 4, anything past the first null is ignored.
-
945  // After doing so, split at the nulls. Do not use the String
-
946  // method "split" as any empty trailing strings are unfortunately discarded.
-
947 
-
948  char c;
-
949  std::vector<int> nullIndexList;
-
950  nullIndexList.reserve(10);
-
951  uint32_t nullCount = 0, goodChars = 0;
-
952  bool badFormat = true;
-
953 
-
954  size_t length = strData.length();
-
955  bool noEnding4 = false;
-
956  if (strData[length - 1] != '\004') {
-
957  noEnding4 = true;
-
958  }
+
876  std::string sData(reinterpret_cast<const char *>(bytes.data()) + offset, length);
+
877  return stringBuilderToStrings(sData, true, strData);
+
878  }
+
879 
+
880 
+
890  static void unpackRawBytesToStrings(uint8_t *bytes, size_t length,
+
891  std::vector<std::string> & strData) {
+
892  if (bytes == nullptr) return;
+
893 
+
894  std::string sData(reinterpret_cast<const char *>(bytes), length);
+
895  // std::cout << "unpackRawBytesToStrings: string = " << sData << std::endl;
+
896  return stringBuilderToStrings(sData, true, strData);
+
897  }
+
898 
+
899 
+
908  static void unpackRawBytesToStrings(ByteBuffer & buffer,
+
909  size_t pos, size_t length,
+
910  std::vector<std::string> & strData) {
+
911 
+
912  if (length < 4) return;
+
913 
+
914  std::string sData(reinterpret_cast<const char *>(buffer.array() + buffer.arrayOffset()) + pos, length);
+
915  return stringBuilderToStrings(sData, false, strData);
+
916  }
+
917 
+
918 
+
934  static void stringBuilderToStrings(std::string const & strData, bool onlyGoodChars,
+
935  std::vector<std::string> & strings) {
+
936 
+
937  // Each string is terminated with a null (char val = 0)
+
938  // and in addition, the end is padded by ASCII 4's (char val = 4).
+
939  // However, in the legacy versions of evio, there is only one
+
940  // null-terminated string and anything as padding. To accommodate legacy evio, if
+
941  // there is not an ending ASCII value 4, anything past the first null is ignored.
+
942  // After doing so, split at the nulls. Do not use the String
+
943  // method "split" as any empty trailing strings are unfortunately discarded.
+
944 
+
945  char c;
+
946  std::vector<int> nullIndexList;
+
947  nullIndexList.reserve(10);
+
948  uint32_t nullCount = 0, goodChars = 0;
+
949  bool badFormat = true;
+
950 
+
951  size_t length = strData.length();
+
952  bool noEnding4 = false;
+
953  if (strData[length - 1] != '\004') {
+
954  noEnding4 = true;
+
955  }
+
956 
+
957  for (size_t i=0; i < length; i++) {
+
958  c = strData[i];
959 
-
960  for (size_t i=0; i < length; i++) {
-
961  c = strData[i];
-
962 
-
963  // If char is a null
-
964  if (c == 0) {
-
965  nullCount++;
-
966  nullIndexList.push_back(i);
-
967  // If evio v2 or 3, only 1 null terminated string exists
-
968  // and padding is just junk or nonexistent.
-
969  if (noEnding4) {
-
970  badFormat = false;
-
971  break;
-
972  }
-
973  }
-
974  // Look for any non-printing/control characters (not including null)
-
975  // and end the string there. Allow tab & newline.
-
976  else if ((c < 32 || c > 126) && c != 9 && c != 10) {
-
977  if (nullCount < 1) {
-
978  badFormat = true;
-
979  // Getting garbage before first null.
-
980  break;
-
981  }
-
982 
-
983  // Already have at least one null & therefore a String.
-
984  // Now we have junk or non-printing ascii which is
-
985  // possibly the ending 4.
-
986 
-
987  // If we have a 4, investigate further to see if format
-
988  // is entirely valid.
-
989  if (c == '\004') {
-
990  // How many more chars are there?
-
991  size_t charsLeft = length - (i+1);
-
992 
-
993  // Should be no more than 3 additional 4's before the end
-
994  if (charsLeft > 3) {
-
995  badFormat = true;
-
996  break;
-
997  }
-
998  else {
-
999  // Check to see if remaining chars are all 4's. If not, bad.
-
1000  for (size_t j=1; j <= charsLeft; j++) {
-
1001  c = strData[i+j];
-
1002  if (c != '\004') {
-
1003  badFormat = true;
-
1004  goto pastOuterLoop;
-
1005  }
-
1006  }
-
1007  badFormat = false;
-
1008  break;
-
1009  }
-
1010  }
-
1011  else {
-
1012  badFormat = true;
-
1013  break;
-
1014  }
-
1015  }
-
1016 
-
1017  pastOuterLoop:
-
1018 
-
1019  // Number of good ASCII chars we have
-
1020  goodChars++;
-
1021  }
-
1022 
-
1023  strings.clear();
-
1024 
-
1025  if (badFormat) {
-
1026  if (onlyGoodChars) {
-
1027  // Return everything in one String WITHOUT garbage
-
1028  std::string goodStr(strData.data(), goodChars);
-
1029  strings.push_back(goodStr);
-
1030  return;
-
1031  }
-
1032  // Return everything in one String including possible garbage
-
1033  strings.push_back(strData);
-
1034  return;
-
1035  }
-
1036 
-
1037  // If here, raw bytes are in the proper format
-
1038 
-
1039  int firstIndex = 0;
-
1040  for (int nullIndex : nullIndexList) {
-
1041  std::string str(strData.data() + firstIndex, (nullIndex - firstIndex));
-
1042  strings.push_back(str);
-
1043  firstIndex = nullIndex + 1;
-
1044  }
-
1045  }
-
1046 
+
960  // If char is a null
+
961  if (c == 0) {
+
962  nullCount++;
+
963  nullIndexList.push_back(i);
+
964  // If evio v2 or 3, only 1 null terminated string exists
+
965  // and padding is just junk or nonexistent.
+
966  if (noEnding4) {
+
967  badFormat = false;
+
968  break;
+
969  }
+
970  }
+
971  // Look for any non-printing/control characters (not including null)
+
972  // and end the string there. Allow tab & newline.
+
973  else if ((c < 32 || c > 126) && c != 9 && c != 10) {
+
974  if (nullCount < 1) {
+
975  badFormat = true;
+
976  // Getting garbage before first null.
+
977  break;
+
978  }
+
979 
+
980  // Already have at least one null & therefore a String.
+
981  // Now we have junk or non-printing ascii which is
+
982  // possibly the ending 4.
+
983 
+
984  // If we have a 4, investigate further to see if format
+
985  // is entirely valid.
+
986  if (c == '\004') {
+
987  // How many more chars are there?
+
988  size_t charsLeft = length - (i+1);
+
989 
+
990  // Should be no more than 3 additional 4's before the end
+
991  if (charsLeft > 3) {
+
992  badFormat = true;
+
993  break;
+
994  }
+
995  else {
+
996  // Check to see if remaining chars are all 4's. If not, bad.
+
997  for (size_t j=1; j <= charsLeft; j++) {
+
998  c = strData[i+j];
+
999  if (c != '\004') {
+
1000  badFormat = true;
+
1001  goto pastOuterLoop;
+
1002  }
+
1003  }
+
1004  badFormat = false;
+
1005  break;
+
1006  }
+
1007  }
+
1008  else {
+
1009  badFormat = true;
+
1010  break;
+
1011  }
+
1012  }
+
1013 
+
1014  pastOuterLoop:
+
1015 
+
1016  // Number of good ASCII chars we have
+
1017  goodChars++;
+
1018  }
+
1019 
+
1020  strings.clear();
+
1021 
+
1022  if (badFormat) {
+
1023  if (onlyGoodChars) {
+
1024  // Return everything in one String WITHOUT garbage
+
1025  std::string goodStr(strData.data(), goodChars);
+
1026  strings.push_back(goodStr);
+
1027  return;
+
1028  }
+
1029  // Return everything in one String including possible garbage
+
1030  strings.push_back(strData);
+
1031  return;
+
1032  }
+
1033 
+
1034  // If here, raw bytes are in the proper format
+
1035 
+
1036  int firstIndex = 0;
+
1037  for (int nullIndex : nullIndexList) {
+
1038  std::string str(strData.data() + firstIndex, (nullIndex - firstIndex));
+
1039  strings.push_back(str);
+
1040  firstIndex = nullIndex + 1;
+
1041  }
+
1042  }
+
1043 
+
1044 
1047 
-
1050 
-
1051 
-
1058  static void expandEnvironmentalVariables(std::string & text) {
-
1059  static std::regex env("\\$\\(([^)]+)\\)");
-
1060  std::smatch match;
-
1061  while ( std::regex_search(text, match, env) ) {
-
1062  char * s = getenv(match[1].str().c_str());
-
1063  std::string var(s == nullptr ? "" : s);
-
1064  // Next line doesn't compile on linux gcc
-
1065  //text.replace(match[0].first, match[0].second, var);
-
1066  text.replace( match.position(0), match.length(0), var );
-
1067  }
-
1068  }
-
1069 
-
1070 
-
1080  static uint32_t countAndFixIntSpecifiers(std::string & text) {
-
1081  static std::regex specifier("%(\\d*)([xd])");
-
1082 
-
1083  auto begin = std::sregex_iterator(text.begin(), text.end(), specifier);
-
1084  auto end = std::sregex_iterator();
-
1085  uint32_t specifierCount = std::distance(begin, end);
-
1086 
-
1087  std::sregex_iterator i = begin;
-
1088 
-
1089  // Go thru all specifiers in text, only once
-
1090  for (uint32_t j = 0; j < specifierCount; j++) {
-
1091  if (j > 0) {
-
1092  // skip over specifiers previously dealt with (text can change each loop)
-
1093  i = std::sregex_iterator(text.begin(), text.end(), specifier);
-
1094  int k=j;
-
1095  while (k-- > 0) i++;
-
1096  }
+
1048 
+
1055  static void expandEnvironmentalVariables(std::string & text) {
+
1056  static std::regex env("\\$\\(([^)]+)\\)");
+
1057  std::smatch match;
+
1058  while ( std::regex_search(text, match, env) ) {
+
1059  char * s = getenv(match[1].str().c_str());
+
1060  std::string var(s == nullptr ? "" : s);
+
1061  // Next line doesn't compile on linux gcc
+
1062  //text.replace(match[0].first, match[0].second, var);
+
1063  text.replace( match.position(0), match.length(0), var );
+
1064  }
+
1065  }
+
1066 
+
1067 
+
1077  static uint32_t countAndFixIntSpecifiers(std::string & text) {
+
1078  static std::regex specifier("%(\\d*)([xd])");
+
1079 
+
1080  auto begin = std::sregex_iterator(text.begin(), text.end(), specifier);
+
1081  auto end = std::sregex_iterator();
+
1082  uint32_t specifierCount = std::distance(begin, end);
+
1083 
+
1084  std::sregex_iterator i = begin;
+
1085 
+
1086  // Go thru all specifiers in text, only once
+
1087  for (uint32_t j = 0; j < specifierCount; j++) {
+
1088  if (j > 0) {
+
1089  // skip over specifiers previously dealt with (text can change each loop)
+
1090  i = std::sregex_iterator(text.begin(), text.end(), specifier);
+
1091  int k=j;
+
1092  while (k-- > 0) i++;
+
1093  }
+
1094 
+
1095  std::smatch match = *i;
+
1096  std::string specWidth = match[1].str();
1097 
-
1098  std::smatch match = *i;
-
1099  std::string specWidth = match[1].str();
-
1100 
-
1101  // Make sure any number preceding "x" or "d" starts with a 0 or else
-
1102  // there will be empty spaces in the resulting string (i.e. file name).
-
1103  if (specWidth.length() > 0 && specWidth[0] != '0') {
-
1104  // Does not compile on linux gcc
-
1105  // text.replace(match[1].first, match[1].second, "0" + specWidth);
-
1106 
-
1107  // So try this:
-
1108  // This first sub match occurs at the beginning of the match
-
1109  auto pos = match.position();
-
1110  auto len = specWidth.length();
-
1111 
-
1112  text.replace(pos, len, "0" + specWidth);
-
1113  }
-
1114  }
+
1098  // Make sure any number preceding "x" or "d" starts with a 0 or else
+
1099  // there will be empty spaces in the resulting string (i.e. file name).
+
1100  if (specWidth.length() > 0 && specWidth[0] != '0') {
+
1101  // Does not compile on linux gcc
+
1102  // text.replace(match[1].first, match[1].second, "0" + specWidth);
+
1103 
+
1104  // So try this:
+
1105  // This first sub match occurs at the beginning of the match
+
1106  auto pos = match.position();
+
1107  auto len = specWidth.length();
+
1108 
+
1109  text.replace(pos, len, "0" + specWidth);
+
1110  }
+
1111  }
+
1112 
+
1113  return specifierCount;
+
1114  }
1115 
-
1116  return specifierCount;
-
1117  }
-
1118 
-
1119 
-
1145  static int generateBaseFileName(const std::string & baseName, const std::string & runType,
-
1146  std::string & modifiedBaseName) {
+
1116 
+
1142  static int generateBaseFileName(const std::string & baseName, const std::string & runType,
+
1143  std::string & modifiedBaseName) {
+
1144 
+
1145  // Return the modified base file name
+
1146  modifiedBaseName = baseName;
1147 
-
1148  // Return the modified base file name
-
1149  modifiedBaseName = baseName;
-
1150 
-
1151  if (modifiedBaseName.length() < 1) {
-
1152  throw EvioException("empty string arg");
-
1153  }
-
1154 
-
1155  // Replace all %s occurrences with runType
-
1156  std::string::size_type pos;
-
1157  while ((pos = modifiedBaseName.find("%s")) != std::string::npos) {
-
1158  modifiedBaseName = (runType.length() < 1) ? modifiedBaseName.replace(pos, 2, "") :
-
1159  modifiedBaseName.replace(pos, 2, runType);
-
1160  }
-
1161 
-
1162  // Scan for environmental variables of the form $(xxx)
-
1163  // and substitute the values for them (blank string if not found)
-
1164  expandEnvironmentalVariables(modifiedBaseName);
-
1165 
-
1166  // Count # of int specifiers, making sure any number preceding
-
1167  // "x" or "d" starts with a 0 or else there will be empty spaces
-
1168  // in the file name (%3x --> %03x).
-
1169  int specifierCount = (int)countAndFixIntSpecifiers(modifiedBaseName);
-
1170 
-
1171  if (specifierCount > 3) {
-
1172  throw EvioException("baseName arg is improperly formatted");
-
1173  }
-
1174 
-
1175  // Return # of C-style int format specifiers
-
1176  return specifierCount;
-
1177  }
-
1178 
-
1179 
-
1263  static std::string generateFileName(std::string fileName, uint32_t specifierCount,
-
1264  uint32_t runNumber, uint64_t split, uint32_t splitNumber,
-
1265  uint32_t streamId, uint32_t streamCount) {
-
1266 
-
1267  if (streamCount < 1) streamCount = 1;
-
1268  if (splitNumber < 1) splitNumber = 0;
-
1269  bool oneStream = streamCount < 2;
-
1270 
-
1271  if (fileName.length() < 1) {
-
1272  fileName = "file";
-
1273  }
-
1274 
-
1275  //cout << "generateFileName: split# = " << splitNumber << ", start with " << fileName <<
-
1276  //", streamId = " << streamId << ", stream count = " << streamCount << ", one stream = " <<
-
1277  //oneStream << endl;
-
1278  // NOTE: no run #s are tacked on the end!
-
1279 
-
1280  // If we're splitting files which is always the case of CODA users ...
-
1281  if (split > 0L) {
-
1282  // For no specifiers: tack stream id and split # onto end of file name
-
1283  if (specifierCount < 1) {
-
1284  if (oneStream) {
-
1285  fileName += "." + std::to_string(splitNumber);
-
1286  }
-
1287  else {
-
1288  fileName += "." + std::to_string(streamId) +
-
1289  "." + std::to_string(splitNumber);
-
1290  }
-
1291  }
-
1292  // For 1 specifier: insert run # at specified location,
-
1293  // then tack stream id and split # onto end of file name
-
1294  else if (specifierCount == 1) {
-
1295  char tempChar[fileName.length() + 1024];
-
1296  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
-
1297  if (err < 0) throw EvioException("badly formatted file name");
-
1298  std::string temp(tempChar);
-
1299  fileName = temp;
-
1300 
-
1301  if (oneStream) {
-
1302  fileName += "." + std::to_string(splitNumber);
-
1303  }
-
1304  else {
-
1305  fileName += "." + std::to_string(streamId) +
-
1306  "." + std::to_string(splitNumber);
-
1307  }
-
1308  }
-
1309  // For 2 specifiers: insert run # and split # at specified locations
-
1310  // and place stream id immediately before split #.
-
1311  else if (specifierCount == 2) {
-
1312  if (!oneStream) {
-
1313  // In order to place streamId before split#, place a %d in the filename
-
1314  // immediately before 2nd specifier.
-
1315  static std::regex specifier("(%\\d*[xd])");
-
1316  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
-
1317 
-
1318  // Go to 2nd match
-
1319  it++;
-
1320  std::smatch match = *it;
-
1321  auto pos = match.position();
-
1322  auto len = match.length();
-
1323  fileName.replace(pos, len, "%." + match.str());
-
1324  // won't compile in linux gcc
-
1325  //fileName.replace(match[0].first, match[0].second, "%d." + match.str());
-
1326 
-
1327  char tempChar[fileName.length() + 1024];
-
1328  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId, splitNumber);
-
1329  if (err < 0) throw EvioException("badly formatted file name");
-
1330  std::string temp(tempChar);
-
1331  fileName = temp;
-
1332  }
-
1333  else {
-
1334  char tempChar[fileName.length() + 1024];
-
1335  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, splitNumber);
-
1336  if (err < 0) throw EvioException("badly formatted file name");
-
1337  std::string temp(tempChar);
-
1338  fileName = temp;
-
1339  }
-
1340  }
-
1341  // For 3 specifiers: insert run #, stream id, and split # at specified locations
-
1342  else if (specifierCount == 3) {
-
1343  char tempChar[fileName.length() + 1024];
-
1344  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId, splitNumber);
-
1345  if (err < 0) throw EvioException("badly formatted file name");
-
1346  std::string temp(tempChar);
-
1347  fileName = temp;
-
1348  }
-
1349 
-
1350  }
-
1351  // If we're not splitting files, then CODA isn't being used and stream id is
-
1352  // probably meaningless.
-
1353  else {
-
1354  // For no specifiers: tack stream id onto end of file name
-
1355  if (specifierCount < 1) {
-
1356  if (!oneStream) {
-
1357  fileName += "." + std::to_string(streamId);
-
1358  }
-
1359  }
-
1360  else if (specifierCount == 1) {
-
1361  // Insert runNumber
-
1362  char tempChar[fileName.length() + 1024];
-
1363  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
-
1364  if (err < 0) throw EvioException("badly formatted file name");
-
1365  std::string temp(tempChar);
-
1366  fileName = temp;
-
1367 
-
1368  if (!oneStream) {
-
1369  fileName += "." + std::to_string(streamId);
-
1370  }
-
1371  }
-
1372  else if (specifierCount == 2) {
-
1373  // First get rid of the extra (2nd) int format specifier as no split # exists
-
1374  static std::regex specifier("(%\\d*[xd])");
-
1375  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
-
1376  // Go to 2nd match
-
1377  it++;
-
1378  std::smatch match = *it;
-
1379  auto pos = match.position();
-
1380  auto len = match.length();
-
1381  fileName.replace(pos, len, "");
-
1382  // won't compile in linux gcc
-
1383  // fileName.replace(match[0].first, match[0].second, "");
-
1384 
-
1385  // Insert runNumber into first specifier
-
1386  char tempChar[fileName.length() + 1024];
-
1387  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
-
1388  if (err < 0) throw EvioException("badly formatted file name");
-
1389  std::string temp(tempChar);
-
1390  fileName = temp;
-
1391 
-
1392  if (!oneStream) {
-
1393  fileName += "." + std::to_string(streamId);
-
1394  }
-
1395  }
-
1396  else if (specifierCount == 3) {
-
1397  // Get rid of extra (3rd) int format specifier as no split # exists
-
1398  static std::regex specifier("(%\\d*[xd])");
-
1399  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
-
1400  // Go to 3rd match
-
1401  it++; it++;
-
1402  std::smatch match = *it;
-
1403  auto pos = match.position();
-
1404  auto len = match.length();
-
1405  fileName.replace(pos, len, "");
-
1406  // won't compile in linux gcc
-
1407  // fileName.replace(match[0].first, match[0].second, "");
-
1408 
-
1409  // Insert runNumber into first specifier, stream id into 2nd
-
1410  char tempChar[fileName.length() + 1024];
-
1411  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId);
-
1412  if (err < 0) throw EvioException("badly formatted file name");
-
1413  std::string temp(tempChar);
-
1414  fileName = temp;
-
1415  }
-
1416  }
-
1417  //cout << "generateFileName: end with " << fileName << endl;
+
1148  if (modifiedBaseName.length() < 1) {
+
1149  throw EvioException("empty string arg");
+
1150  }
+
1151 
+
1152  // Replace all %s occurrences with runType
+
1153  std::string::size_type pos;
+
1154  while ((pos = modifiedBaseName.find("%s")) != std::string::npos) {
+
1155  modifiedBaseName = (runType.length() < 1) ? modifiedBaseName.replace(pos, 2, "") :
+
1156  modifiedBaseName.replace(pos, 2, runType);
+
1157  }
+
1158 
+
1159  // Scan for environmental variables of the form $(xxx)
+
1160  // and substitute the values for them (blank string if not found)
+
1161  expandEnvironmentalVariables(modifiedBaseName);
+
1162 
+
1163  // Count # of int specifiers, making sure any number preceding
+
1164  // "x" or "d" starts with a 0 or else there will be empty spaces
+
1165  // in the file name (%3x --> %03x).
+
1166  int specifierCount = (int)countAndFixIntSpecifiers(modifiedBaseName);
+
1167 
+
1168  if (specifierCount > 3) {
+
1169  throw EvioException("baseName arg is improperly formatted");
+
1170  }
+
1171 
+
1172  // Return # of C-style int format specifiers
+
1173  return specifierCount;
+
1174  }
+
1175 
+
1176 
+
1260  static std::string generateFileName(std::string fileName, uint32_t specifierCount,
+
1261  uint32_t runNumber, uint64_t split, uint32_t splitNumber,
+
1262  uint32_t streamId, uint32_t streamCount) {
+
1263 
+
1264  if (streamCount < 1) streamCount = 1;
+
1265  if (splitNumber < 1) splitNumber = 0;
+
1266  bool oneStream = streamCount < 2;
+
1267 
+
1268  if (fileName.length() < 1) {
+
1269  fileName = "file";
+
1270  }
+
1271 
+
1272  //cout << "generateFileName: split# = " << splitNumber << ", start with " << fileName <<
+
1273  //", streamId = " << streamId << ", stream count = " << streamCount << ", one stream = " <<
+
1274  //oneStream << endl;
+
1275  // NOTE: no run #s are tacked on the end!
+
1276 
+
1277  // If we're splitting files which is always the case of CODA users ...
+
1278  if (split > 0L) {
+
1279  // For no specifiers: tack stream id and split # onto end of file name
+
1280  if (specifierCount < 1) {
+
1281  if (oneStream) {
+
1282  fileName += "." + std::to_string(splitNumber);
+
1283  }
+
1284  else {
+
1285  fileName += "." + std::to_string(streamId) +
+
1286  "." + std::to_string(splitNumber);
+
1287  }
+
1288  }
+
1289  // For 1 specifier: insert run # at specified location,
+
1290  // then tack stream id and split # onto end of file name
+
1291  else if (specifierCount == 1) {
+
1292  char tempChar[fileName.length() + 1024];
+
1293  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
+
1294  if (err < 0) throw EvioException("badly formatted file name");
+
1295  std::string temp(tempChar);
+
1296  fileName = temp;
+
1297 
+
1298  if (oneStream) {
+
1299  fileName += "." + std::to_string(splitNumber);
+
1300  }
+
1301  else {
+
1302  fileName += "." + std::to_string(streamId) +
+
1303  "." + std::to_string(splitNumber);
+
1304  }
+
1305  }
+
1306  // For 2 specifiers: insert run # and split # at specified locations
+
1307  // and place stream id immediately before split #.
+
1308  else if (specifierCount == 2) {
+
1309  if (!oneStream) {
+
1310  // In order to place streamId before split#, place a %d in the filename
+
1311  // immediately before 2nd specifier.
+
1312  static std::regex specifier("(%\\d*[xd])");
+
1313  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
+
1314 
+
1315  // Go to 2nd match
+
1316  it++;
+
1317  std::smatch match = *it;
+
1318  auto pos = match.position();
+
1319  auto len = match.length();
+
1320  fileName.replace(pos, len, "%." + match.str());
+
1321  // won't compile in linux gcc
+
1322  //fileName.replace(match[0].first, match[0].second, "%d." + match.str());
+
1323 
+
1324  char tempChar[fileName.length() + 1024];
+
1325  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId, splitNumber);
+
1326  if (err < 0) throw EvioException("badly formatted file name");
+
1327  std::string temp(tempChar);
+
1328  fileName = temp;
+
1329  }
+
1330  else {
+
1331  char tempChar[fileName.length() + 1024];
+
1332  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, splitNumber);
+
1333  if (err < 0) throw EvioException("badly formatted file name");
+
1334  std::string temp(tempChar);
+
1335  fileName = temp;
+
1336  }
+
1337  }
+
1338  // For 3 specifiers: insert run #, stream id, and split # at specified locations
+
1339  else if (specifierCount == 3) {
+
1340  char tempChar[fileName.length() + 1024];
+
1341  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId, splitNumber);
+
1342  if (err < 0) throw EvioException("badly formatted file name");
+
1343  std::string temp(tempChar);
+
1344  fileName = temp;
+
1345  }
+
1346 
+
1347  }
+
1348  // If we're not splitting files, then CODA isn't being used and stream id is
+
1349  // probably meaningless.
+
1350  else {
+
1351  // For no specifiers: tack stream id onto end of file name
+
1352  if (specifierCount < 1) {
+
1353  if (!oneStream) {
+
1354  fileName += "." + std::to_string(streamId);
+
1355  }
+
1356  }
+
1357  else if (specifierCount == 1) {
+
1358  // Insert runNumber
+
1359  char tempChar[fileName.length() + 1024];
+
1360  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
+
1361  if (err < 0) throw EvioException("badly formatted file name");
+
1362  std::string temp(tempChar);
+
1363  fileName = temp;
+
1364 
+
1365  if (!oneStream) {
+
1366  fileName += "." + std::to_string(streamId);
+
1367  }
+
1368  }
+
1369  else if (specifierCount == 2) {
+
1370  // First get rid of the extra (2nd) int format specifier as no split # exists
+
1371  static std::regex specifier("(%\\d*[xd])");
+
1372  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
+
1373  // Go to 2nd match
+
1374  it++;
+
1375  std::smatch match = *it;
+
1376  auto pos = match.position();
+
1377  auto len = match.length();
+
1378  fileName.replace(pos, len, "");
+
1379  // won't compile in linux gcc
+
1380  // fileName.replace(match[0].first, match[0].second, "");
+
1381 
+
1382  // Insert runNumber into first specifier
+
1383  char tempChar[fileName.length() + 1024];
+
1384  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber);
+
1385  if (err < 0) throw EvioException("badly formatted file name");
+
1386  std::string temp(tempChar);
+
1387  fileName = temp;
+
1388 
+
1389  if (!oneStream) {
+
1390  fileName += "." + std::to_string(streamId);
+
1391  }
+
1392  }
+
1393  else if (specifierCount == 3) {
+
1394  // Get rid of extra (3rd) int format specifier as no split # exists
+
1395  static std::regex specifier("(%\\d*[xd])");
+
1396  auto it = std::sregex_iterator(fileName.begin(), fileName.end(), specifier);
+
1397  // Go to 3rd match
+
1398  it++; it++;
+
1399  std::smatch match = *it;
+
1400  auto pos = match.position();
+
1401  auto len = match.length();
+
1402  fileName.replace(pos, len, "");
+
1403  // won't compile in linux gcc
+
1404  // fileName.replace(match[0].first, match[0].second, "");
+
1405 
+
1406  // Insert runNumber into first specifier, stream id into 2nd
+
1407  char tempChar[fileName.length() + 1024];
+
1408  int err = std::snprintf(tempChar, fileName.length() + 1024, fileName.c_str(), runNumber, (int)streamId);
+
1409  if (err < 0) throw EvioException("badly formatted file name");
+
1410  std::string temp(tempChar);
+
1411  fileName = temp;
+
1412  }
+
1413  }
+
1414  //cout << "generateFileName: end with " << fileName << endl;
+
1415 
+
1416  return fileName;
+
1417  }
1418 
-
1419  return fileName;
-
1420  }
-
1421 
-
1422  };
+
1419  };
+
1420 
+
1421 }
+
1422 
1423 
-
1424 }
-
1425 
-
1426 
-
1427 #endif //EVIO_6_0_UTIL_H
+
1424 #endif //EVIO_6_0_UTIL_H
@@ -1162,40 +1160,40 @@
Class containing static methods of general purpose.
Definition: Util.h:41
static void printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)
This method takes a byte buffer and prints out the desired number of bytes from the given position,...
Definition: Util.h:458
static uint32_t getWords(uint32_t length)
Returns length padded to 4-byte boundary for given length in bytes.
Definition: Util.h:52
-
static void unpackRawBytesToStrings(uint8_t *bytes, size_t length, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:893
+
static void unpackRawBytesToStrings(uint8_t *bytes, size_t length, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:890
static uint32_t toInt(char b1, char b2, char b3, char b4, const ByteOrder &byteOrder)
Turn 4 bytes into an unsigned 32 bit int.
Definition: Util.h:156
-
static size_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,...
Definition: Util.h:745
-
static void printBytes(std::shared_ptr< EvioNode > node, uint32_t position, uint32_t bytes, const std::string &label)
This method takes an EvioNode and prints out the desired number of bytes from the backing array from ...
Definition: Util.h:472
-
static uint32_t stringToRawSize(const std::string &str)
This method returns the number of bytes in a raw evio format of the given string array (with a single...
Definition: Util.h:774
+
static size_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,...
Definition: Util.h:742
+
static uint32_t stringToRawSize(const std::string &str)
This method returns the number of bytes in a raw evio format of the given string array (with a single...
Definition: Util.h:771
static const DataType & getDataType(const std::string &type)
This method returns an XML element name given an evio data type.
Definition: Util.h:96
-
static void stringBuilderToStrings(std::string const &strData, bool onlyGoodChars, std::vector< std::string > &strings)
This method extracts an array of strings from a string containing evio string data.
Definition: Util.h:937
+
static void stringBuilderToStrings(std::string const &strData, bool onlyGoodChars, std::vector< std::string > &strings)
This method extracts an array of strings from a string containing evio string data.
Definition: Util.h:934
static const std::string & NO_NAME_STRING()
Get a string used to indicate that no name can be determined.
Definition: Util.h:392
-
static void unpackRawBytesToStrings(ByteBuffer &buffer, size_t pos, size_t length, std::vector< std::string > &strData)
This method extracts an array of strings from buffer containing raw evio string data.
Definition: Util.h:911
+
static void unpackRawBytesToStrings(ByteBuffer &buffer, size_t pos, size_t length, std::vector< std::string > &strData)
This method extracts an array of strings from buffer containing raw evio string data.
Definition: Util.h:908
static uint32_t findEvioVersion(ByteBuffer &bb, size_t initialPos)
Reads a couple things in a block/record header in order to determine the evio version and endianness ...
Definition: Util.h:412
static uint64_t toLong(uint8_t const *data, ByteOrder const &byteOrder)
Turn 4 bytes into an unsigned 32 bit int.
Definition: Util.h:217
static void toBytes(uint32_t data, const ByteOrder &byteOrder, std::vector< uint8_t > &dest, size_t off)
Write int into byte vector.
Definition: Util.h:323
static bool iStrEquals(const std::string &a, const std::string &b)
Case insensitive compare for 2 strings.
Definition: Util.h:80
-
static int generateBaseFileName(const std::string &baseName, const std::string &runType, std::string &modifiedBaseName)
Definition: Util.h:1145
-
static void unpackRawBytesToStrings(std::vector< uint8_t > &bytes, size_t offset, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:854
+
static int generateBaseFileName(const std::string &baseName, const std::string &runType, std::string &modifiedBaseName)
Definition: Util.h:1142
+
static void unpackRawBytesToStrings(std::vector< uint8_t > &bytes, size_t offset, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:851
static uint32_t toInt(uint8_t const *data, ByteOrder const &byteOrder)
Turn 4 bytes into an unsigned 32 bit int.
Definition: Util.h:185
static void toIntArray(char const *data, uint32_t dataLen, const ByteOrder &byteOrder, uint32_t *dest)
Turn byte array into an int array.
Definition: Util.h:133
-
static void printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)
This method takes a byte buffer and prints out the desired number of bytes from the given position,...
Definition: Util.h:487
-
static void unpackRawBytesToStrings(std::vector< uint8_t > &bytes, size_t offset, size_t maxLength, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:870
-
static uint32_t countAndFixIntSpecifiers(std::string &text)
Count the number of integer specifiers (e.g.
Definition: Util.h:1080
-
static std::string generateFileName(std::string fileName, uint32_t specifierCount, uint32_t runNumber, uint64_t split, uint32_t splitNumber, uint32_t streamId, uint32_t streamCount)
Definition: Util.h:1263
-
static void readBytes(const std::string &fileName, ByteBuffer &buf)
This method reads part of a file into a ByteBuffer.
Definition: Util.h:636
-
static void stringToASCII(const std::string &input, std::vector< uint8_t > &array)
Return an input string as ASCII in which each character is one byte.
Definition: Util.h:700
-
static void expandEnvironmentalVariables(std::string &text)
Substitute environmental variables in a given string when they come in the form, .
Definition: Util.h:1058
-
static void stringsToRawBytes(std::vector< std::string > &strings, std::vector< uint8_t > &bytes)
This method transforms an array/vector of strings into raw evio format data, not including header.
Definition: Util.h:800
+
static void printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)
This method takes a byte buffer and prints out the desired number of bytes from the given position,...
Definition: Util.h:485
+
static void unpackRawBytesToStrings(std::vector< uint8_t > &bytes, size_t offset, size_t maxLength, std::vector< std::string > &strData)
This method extracts an array of strings from byte array of raw evio string data.
Definition: Util.h:867
+
static uint32_t countAndFixIntSpecifiers(std::string &text)
Count the number of integer specifiers (e.g.
Definition: Util.h:1077
+
static std::string generateFileName(std::string fileName, uint32_t specifierCount, uint32_t runNumber, uint64_t split, uint32_t splitNumber, uint32_t streamId, uint32_t streamCount)
Definition: Util.h:1260
+
static void readBytes(const std::string &fileName, ByteBuffer &buf)
This method reads part of a file into a ByteBuffer.
Definition: Util.h:633
+
static void stringToASCII(const std::string &input, std::vector< uint8_t > &array)
Return an input string as ASCII in which each character is one byte.
Definition: Util.h:697
+
static void expandEnvironmentalVariables(std::string &text)
Substitute environmental variables in a given string when they come in the form, .
Definition: Util.h:1055
+
static void stringsToRawBytes(std::vector< std::string > &strings, std::vector< uint8_t > &bytes)
This method transforms an array/vector of strings into raw evio format data, not including header.
Definition: Util.h:797
static void toBytes(uint16_t data, const ByteOrder &byteOrder, std::vector< uint8_t > &dest, size_t off)
Write short into byte vector.
Definition: Util.h:374
-
static void printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)
This method takes a pointer and prints out the desired number of bytes from the given position,...
Definition: Util.h:526
+
static void printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)
This method takes a pointer and prints out the desired number of bytes from the given position,...
Definition: Util.h:523
static void toBytes(uint32_t data, const ByteOrder &byteOrder, uint8_t *dest)
Write int into byte array.
Definition: Util.h:257
-
static void stringToASCII(const std::string &input, ByteBuffer &buf)
Return an input string as ASCII in which each character is one byte.
Definition: Util.h:717
-
static void writeBytes(const std::string &fileName, ByteBuffer &buf)
This method takes a ByteBuffer and writes its data to a file.
Definition: Util.h:601
+
static void printBytes(std::shared_ptr< EvioNode > node, uint32_t bytes, const std::string &label)
This method takes an EvioNode and prints out the desired number of bytes from the backing array at th...
Definition: Util.h:471
+
static void stringToASCII(const std::string &input, ByteBuffer &buf)
Return an input string as ASCII in which each character is one byte.
Definition: Util.h:714
+
static void writeBytes(const std::string &fileName, ByteBuffer &buf)
This method takes a ByteBuffer and writes its data to a file.
Definition: Util.h:598
static void toBytes(uint16_t data, const ByteOrder &byteOrder, uint8_t *dest)
Write short into byte array.
Definition: Util.h:349
-
static int powerOfTwo(int x, bool roundUp)
Return the power of 2 closest to the given argument.
Definition: Util.h:670
+
static int powerOfTwo(int x, bool roundUp)
Return the power of 2 closest to the given argument.
Definition: Util.h:667
static uint32_t getPadding(uint32_t length)
Returns number of bytes needed to pad to 4-byte boundary for the given length.
Definition: Util.h:64
-
static void printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)
This method takes a file and prints out the desired number of bytes from the given offset,...
Definition: Util.h:561
+
static void printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)
This method takes a file and prints out the desired number of bytes from the given offset,...
Definition: Util.h:558
static void toBytes(uint64_t data, const ByteOrder &byteOrder, uint8_t *dest)
Turn long into byte array.
Definition: Util.h:286
Copyright (c) 2019, Jefferson Science Associates.
Definition: BankHeader.cpp:14
diff --git a/doc-6.0/doxygen/CC/html/de/d60/classevio_1_1_util-members.html b/doc-6.0/doxygen/CC/html/de/d60/classevio_1_1_util-members.html index 7fc754c2..b03214ed 100644 --- a/doc-6.0/doxygen/CC/html/de/d60/classevio_1_1_util-members.html +++ b/doc-6.0/doxygen/CC/html/de/d60/classevio_1_1_util-members.html @@ -101,7 +101,7 @@ NO_NAME_STRING()evio::Utilinlinestatic powerOfTwo(int x, bool roundUp)evio::Utilinlinestatic printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)evio::Utilinlinestatic - printBytes(std::shared_ptr< EvioNode > node, uint32_t position, uint32_t bytes, const std::string &label)evio::Utilinlinestatic + printBytes(std::shared_ptr< EvioNode > node, uint32_t bytes, const std::string &label)evio::Utilinlinestatic printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)evio::Utilinlinestatic printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)evio::Utilinlinestatic printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)evio::Utilinlinestatic diff --git a/doc-6.0/doxygen/CC/html/functions_func_p.html b/doc-6.0/doxygen/CC/html/functions_func_p.html index f301355a..773add6a 100644 --- a/doc-6.0/doxygen/CC/html/functions_func_p.html +++ b/doc-6.0/doxygen/CC/html/functions_func_p.html @@ -125,7 +125,7 @@

- p -

  • printBytes() : evio::ByteBuffer -, evio::Util +, evio::Util
  • process() : evio::CompositeData diff --git a/doc-6.0/doxygen/CC/html/navtreeindex1.js b/doc-6.0/doxygen/CC/html/navtreeindex1.js index 627cf96e..42551d9d 100644 --- a/doc-6.0/doxygen/CC/html/navtreeindex1.js +++ b/doc-6.0/doxygen/CC/html/navtreeindex1.js @@ -183,7 +183,6 @@ var NAVTREEINDEX1 = "d3/d87/classevio_1_1_util.html#a0dabe5e1409c9f9791b74442901715da":[2,0,0,57,35], "d3/d87/classevio_1_1_util.html#a107bf333efeb2bb3d65104ce9d2edbf9":[2,0,0,57,28], "d3/d87/classevio_1_1_util.html#a24d84643c924c770e58cc088888e16fd":[2,0,0,57,19], -"d3/d87/classevio_1_1_util.html#a25563cae3636dbc8de2fba2452e45260":[2,0,0,57,14], "d3/d87/classevio_1_1_util.html#a29a1f64bd5ff18c187625eb2d7c684a0":[2,0,0,57,22], "d3/d87/classevio_1_1_util.html#a2e0841939d9ccc701e4b69c58c148355":[2,0,0,57,5], "d3/d87/classevio_1_1_util.html#a3533bfa3ba79b476ba13485657fb89e6":[2,0,0,57,17], @@ -208,6 +207,7 @@ var NAVTREEINDEX1 = "d3/d87/classevio_1_1_util.html#aa61875b5df6961b5c8398d0156389d35":[2,0,0,57,23], "d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0":[2,0,0,57,15], "d3/d87/classevio_1_1_util.html#ab69d28ab3f58cc5457f5b39439937b10":[2,0,0,57,26], +"d3/d87/classevio_1_1_util.html#ac3f1f3596d09f90c15ec49b17964c180":[2,0,0,57,14], "d3/d87/classevio_1_1_util.html#ac66a3b2b14b36d08d9b9fac4555e15fe":[2,0,0,57,20], "d3/d87/classevio_1_1_util.html#ad24c479c35a111fa7b43c9a05a409336":[2,0,0,57,36], "d3/d87/classevio_1_1_util.html#ad930d1a274b50b4a1fe53dd7d81b95ee":[2,0,0,57,24], diff --git a/doc-6.0/doxygen/CC/html/search/all_e.js b/doc-6.0/doxygen/CC/html/search/all_e.js index 3261ebf7..6df49b01 100644 --- a/doc-6.0/doxygen/CC/html/search/all_e.js +++ b/doc-6.0/doxygen/CC/html/search/all_e.js @@ -13,7 +13,7 @@ var searchData= ['pointer_696',['pointer',['../d9/ddd/classevio_1_1_base_structure.html#a6c36c12ffe61cb8ebe8c5bf402f3087b',1,'evio::BaseStructure']]], ['position_697',['position',['../de/d97/classevio_1_1_i_evio_reader.html#a3a3c4a46ffffbd0d090e8ee04a5b54f2',1,'evio::IEvioReader::position()'],['../db/d34/classevio_1_1_evio_reader_v6.html#a1ee5892d045c14faeec288341f005288',1,'evio::EvioReaderV6::position()'],['../dd/db3/classevio_1_1_evio_reader_v4.html#a788f6442710ea217855ba4c70787b5d5',1,'evio::EvioReaderV4::position()'],['../dc/d30/classevio_1_1_byte_buffer.html#a8d6c9a521a64e6fb5ee3eef3b4288abd',1,'evio::ByteBuffer::position(size_t p)'],['../dc/d30/classevio_1_1_byte_buffer.html#a88f84e6b1757db70542eac13294fc80e',1,'evio::ByteBuffer::position() const'],['../df/dbd/classevio_1_1_evio_reader.html#a22dbfd15bd8796cb6d4e969ee6237c53',1,'evio::EvioReader::position()']]], ['poweroftwo_698',['powerOfTwo',['../d3/d87/classevio_1_1_util.html#aecf01b40cf83fcdd27115f66b67e848c',1,'evio::Util']]], - ['printbytes_699',['printBytes',['../dc/d30/classevio_1_1_byte_buffer.html#a080cb49cb33238fe74d54b0fc33f9990',1,'evio::ByteBuffer::printBytes()'],['../d3/d87/classevio_1_1_util.html#a010e647b8553d03811f1c48a9908904a',1,'evio::Util::printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a25563cae3636dbc8de2fba2452e45260',1,'evio::Util::printBytes(std::shared_ptr< EvioNode > node, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a66847f39ab5cf153f005866eb5332fce',1,'evio::Util::printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0',1,'evio::Util::printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#af69bace572e57dd144399015a87bcaef',1,'evio::Util::printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)']]], + ['printbytes_699',['printBytes',['../dc/d30/classevio_1_1_byte_buffer.html#a080cb49cb33238fe74d54b0fc33f9990',1,'evio::ByteBuffer::printBytes()'],['../d3/d87/classevio_1_1_util.html#a010e647b8553d03811f1c48a9908904a',1,'evio::Util::printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ac3f1f3596d09f90c15ec49b17964c180',1,'evio::Util::printBytes(std::shared_ptr< EvioNode > node, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a66847f39ab5cf153f005866eb5332fce',1,'evio::Util::printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0',1,'evio::Util::printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#af69bace572e57dd144399015a87bcaef',1,'evio::Util::printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)']]], ['process_700',['process',['../d5/d4b/classevio_1_1_composite_data.html#ac4acdf0c61154d716ddafccf90d99fc7',1,'evio::CompositeData']]], ['processnextblock_701',['processNextBlock',['../dd/db3/classevio_1_1_evio_reader_v4.html#a8767111bda74f2c5b994aeeee4c2cefa',1,'evio::EvioReaderV4']]], ['publish_702',['publish',['../dc/de8/classevio_1_1_record_supply.html#a519d162434d4aaf88afc8c47913436eb',1,'evio::RecordSupply']]], diff --git a/doc-6.0/doxygen/CC/html/search/functions_d.js b/doc-6.0/doxygen/CC/html/search/functions_d.js index 01dc352c..c879a43c 100644 --- a/doc-6.0/doxygen/CC/html/search/functions_d.js +++ b/doc-6.0/doxygen/CC/html/search/functions_d.js @@ -9,7 +9,7 @@ var searchData= ['peek_1657',['peek',['../dc/d30/classevio_1_1_byte_buffer.html#a59b9183ed5119a8cf8051bf01ea91734',1,'evio::ByteBuffer']]], ['position_1658',['position',['../dc/d30/classevio_1_1_byte_buffer.html#a88f84e6b1757db70542eac13294fc80e',1,'evio::ByteBuffer::position() const'],['../dc/d30/classevio_1_1_byte_buffer.html#a8d6c9a521a64e6fb5ee3eef3b4288abd',1,'evio::ByteBuffer::position(size_t p)'],['../df/dbd/classevio_1_1_evio_reader.html#a22dbfd15bd8796cb6d4e969ee6237c53',1,'evio::EvioReader::position()'],['../dd/db3/classevio_1_1_evio_reader_v4.html#a788f6442710ea217855ba4c70787b5d5',1,'evio::EvioReaderV4::position()'],['../db/d34/classevio_1_1_evio_reader_v6.html#a1ee5892d045c14faeec288341f005288',1,'evio::EvioReaderV6::position()'],['../de/d97/classevio_1_1_i_evio_reader.html#a3a3c4a46ffffbd0d090e8ee04a5b54f2',1,'evio::IEvioReader::position()']]], ['poweroftwo_1659',['powerOfTwo',['../d3/d87/classevio_1_1_util.html#aecf01b40cf83fcdd27115f66b67e848c',1,'evio::Util']]], - ['printbytes_1660',['printBytes',['../dc/d30/classevio_1_1_byte_buffer.html#a080cb49cb33238fe74d54b0fc33f9990',1,'evio::ByteBuffer::printBytes()'],['../d3/d87/classevio_1_1_util.html#af69bace572e57dd144399015a87bcaef',1,'evio::Util::printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0',1,'evio::Util::printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a25563cae3636dbc8de2fba2452e45260',1,'evio::Util::printBytes(std::shared_ptr< EvioNode > node, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a010e647b8553d03811f1c48a9908904a',1,'evio::Util::printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a66847f39ab5cf153f005866eb5332fce',1,'evio::Util::printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)']]], + ['printbytes_1660',['printBytes',['../dc/d30/classevio_1_1_byte_buffer.html#a080cb49cb33238fe74d54b0fc33f9990',1,'evio::ByteBuffer::printBytes()'],['../d3/d87/classevio_1_1_util.html#af69bace572e57dd144399015a87bcaef',1,'evio::Util::printBytes(const std::string &fileName, uint64_t offset, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ab164e1302d6850315d45c0be6f1a8df0',1,'evio::Util::printBytes(uint8_t const *data, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#ac3f1f3596d09f90c15ec49b17964c180',1,'evio::Util::printBytes(std::shared_ptr< EvioNode > node, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a010e647b8553d03811f1c48a9908904a',1,'evio::Util::printBytes(std::shared_ptr< ByteBuffer > buf, uint32_t position, uint32_t bytes, const std::string &label)'],['../d3/d87/classevio_1_1_util.html#a66847f39ab5cf153f005866eb5332fce',1,'evio::Util::printBytes(const ByteBuffer &buf, uint32_t position, uint32_t bytes, const std::string &label)']]], ['process_1661',['process',['../d5/d4b/classevio_1_1_composite_data.html#ac4acdf0c61154d716ddafccf90d99fc7',1,'evio::CompositeData']]], ['processnextblock_1662',['processNextBlock',['../dd/db3/classevio_1_1_evio_reader_v4.html#a8767111bda74f2c5b994aeeee4c2cefa',1,'evio::EvioReaderV4']]], ['publish_1663',['publish',['../dc/de8/classevio_1_1_record_supply.html#a519d162434d4aaf88afc8c47913436eb',1,'evio::RecordSupply']]], diff --git a/doc-6.0/javadoc/index-all.html b/doc-6.0/javadoc/index-all.html index ae6f24e8..3fcebf45 100644 --- a/doc-6.0/javadoc/index-all.html +++ b/doc-6.0/javadoc/index-all.html @@ -5185,6 +5185,11 @@

    P

    This method takes a byte buffer and prints out the desired number of bytes from the given position.
    +
    printBytes(EvioNode, int, String) - Static method in class org.jlab.coda.jevio.Utilities
    +
    +
    This method takes an EvioNode and prints out the desired number of bytes + from the backing array at the given node's position, in hex.
    +
    printBytes(byte[], int, int, String) - Static method in class org.jlab.coda.jevio.Utilities
    This method takes a byte array and prints out the desired number of bytes diff --git a/doc-6.0/javadoc/org/jlab/coda/jevio/Utilities.html b/doc-6.0/javadoc/org/jlab/coda/jevio/Utilities.html index ccf388cb..a63354ae 100644 --- a/doc-6.0/javadoc/org/jlab/coda/jevio/Utilities.html +++ b/doc-6.0/javadoc/org/jlab/coda/jevio/Utilities.html @@ -21,7 +21,7 @@ catch(err) { } //--> -var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9}; +var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9,"i21":9}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; @@ -289,6 +289,15 @@

    Method Summary

    static void +printBytes(EvioNode node, + int bytes, + java.lang.String label) +
    This method takes an EvioNode and prints out the desired number of bytes + from the backing array at the given node's position, in hex.
    + + + +static void printBytes(java.lang.String fileName, long offset, int bytes, @@ -297,20 +306,20 @@

    Method Summary

    from the given offset.
    - + static void printStackTrace()
    This method prints out the current stack trace.
    - + static void readBytes(java.lang.String fileName, java.nio.ByteBuffer buf)
    This method reads part of a file into a ByteBuffer.
    - + static byte[] stringToBank(java.lang.String text, short tag, @@ -319,7 +328,7 @@

    Method Summary

    Method to create a byte array representing a bank with one string as data.
    - + static java.util.List<EvioEvent> toEvents(java.lang.String xmlString)
    This method takes a string representation of evio events @@ -327,7 +336,7 @@

    Method Summary

    and converts them to a list of EvioEvent objects.
    - + static java.util.List<EvioEvent> toEvents(java.lang.String xmlString, int maxEvents, @@ -339,7 +348,7 @@

    Method Summary

    and converts them to a list of EvioEvent objects. - + static java.lang.String toXML(EvioNode node, boolean hex) @@ -696,6 +705,25 @@

    printBytes

+ + + +
    +
  • +

    printBytes

    +
    public static void printBytes(EvioNode node,
    +                              int bytes,
    +                              java.lang.String label)
    +
    This method takes an EvioNode and prints out the desired number of bytes + from the backing array at the given node's position, in hex. Prints all bytes.
    +
    +
    Parameters:
    +
    node - node with backing buffer to print out
    +
    bytes - number of bytes to print in hex
    +
    label - a label to print as header
    +
    +
  • +
diff --git a/doc-6.0/javadoc/org/jlab/coda/jevio/class-use/EvioNode.html b/doc-6.0/javadoc/org/jlab/coda/jevio/class-use/EvioNode.html index 32dd6b09..6bf839a2 100644 --- a/doc-6.0/javadoc/org/jlab/coda/jevio/class-use/EvioNode.html +++ b/doc-6.0/javadoc/org/jlab/coda/jevio/class-use/EvioNode.html @@ -543,24 +543,33 @@

Uses of +static void +Utilities.printBytes(EvioNode node, + int bytes, + java.lang.String label) +
This method takes an EvioNode and prints out the desired number of bytes + from the backing array at the given node's position, in hex.
+ + + java.nio.ByteBuffer IEvioCompactReader.removeStructure(EvioNode removeNode)
This method removes the data, represented by the given node, from the buffer.
- + java.nio.ByteBuffer EvioCompactStructureHandler.removeStructure(EvioNode removeNode)
This method removes the data, represented by the given node, from the buffer.
- + java.nio.ByteBuffer EvioCompactReader.removeStructure(EvioNode removeNode)
This method removes the data, represented by the given node, from the buffer.
- + void EventWriterV4.setFirstEvent(EvioNode node)
@@ -568,7 +577,7 @@

Uses of + void EventWriterUnsyncV4.setFirstEvent(EvioNode node)
@@ -576,7 +585,7 @@

Uses of + void EventWriterUnsync.setFirstEvent(EvioNode node)
@@ -584,7 +593,7 @@

Uses of + void EventWriter.setFirstEvent(EvioNode node)
@@ -592,21 +601,21 @@

Uses of + static java.lang.String Utilities.toXML(EvioNode node, boolean hex)
This method takes an EvioNode object and converts it to a readable, XML String.
- + boolean EventWriterUnsyncV4.writeEvent(EvioNode node, boolean force)
Write an event (bank) to the buffer in evio version 4 format.
- + boolean EventWriterUnsync.writeEvent(EvioNode node, boolean force) @@ -614,7 +623,7 @@

Uses of + boolean EventWriterUnsyncV4.writeEvent(EvioNode node, boolean force, @@ -622,7 +631,7 @@

Uses of Write an event (bank) to the buffer in evio version 4 format.

- + boolean EventWriterUnsync.writeEvent(EvioNode node, boolean force, @@ -631,7 +640,7 @@

Uses of + boolean EventWriterUnsync.writeEvent(EvioNode node, boolean force, @@ -641,7 +650,7 @@

Uses of + boolean EventWriterUnsyncV4.writeEventToFile(EvioNode node, boolean force, @@ -651,7 +660,7 @@

Uses of + boolean EventWriterUnsync.writeEventToFile(EvioNode node, boolean force, @@ -661,7 +670,7 @@

Uses of + boolean EventWriterUnsync.writeEventToFile(EvioNode node, boolean force,