/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/eformat/eformat-00-00-04/eformat/util.h

Go to the documentation of this file.
00001 //Dear emacs, this is -*- c++ -*-
00002 
00014 #ifndef EFORMAT_UTIL_H
00015 #define EFORMAT_UTIL_H
00016 
00017 #include <fstream>
00018 #include <stdint.h>
00019 #include <cstdlib>
00020 #include "eformat/HeaderMarker.h"
00021 #include "eformat/WrongMarkerIssue.h"
00022 
00023 namespace eformat {
00024 
00037   uint32_t* next_fragment (std::fstream& fs, uint32_t* addr=0, size_t size=0);
00038 
00061   size_t find_rods (const uint32_t* block_start, size_t block_size,
00062                     const uint32_t** rod=0, uint32_t* rod_size=0,
00063                     size_t max_count=0);
00064 
00081   template <class TPointer>
00082   size_t find_fragments (eformat::HeaderMarker marker, 
00083                          TPointer block_start, size_t block_size,
00084                          TPointer* frag=0, size_t max_count=0);
00085 
00098   size_t get_robs (const uint32_t* fragment, const uint32_t** rob,
00099                    size_t max_count);
00100 
00101 }
00102 
00106 #ifndef HEX
00107 #define HEX(m) "0x" << std::hex << (int)m  << std::dec << " (" << (int)m << ")"
00108 #endif
00109 
00110 template <class TPointer>
00111 size_t eformat::find_fragments (eformat::HeaderMarker marker, 
00112                                 TPointer block_start, size_t block_size,
00113                                 TPointer* frag, size_t max_count)
00114 {
00115   uint32_t counter = 0;
00116   TPointer next = block_start;
00117   TPointer endp = block_start;
00118   endp += block_size;
00119   while (next < endp) {
00120     if (next[0] != marker) throw EFORMAT_WRONG_MARKER(next[0], marker);
00121     if (frag && counter < max_count) frag[counter] = next;
00122     ++counter;
00123     next += next[1];
00124   }
00125   return counter;
00126 }
00127 
00128 
00129 #endif //EFORMAT_UTIL_H

Generated on Tue Nov 29 22:58:25 2016 for BOSS_7.0.2 by  doxygen 1.4.7