00001 //Dear emacs, this is -*- c++ -*- 00002 00013 #include "eformat/old/ROBFragment.h" 00014 #include "eformat/old/RODFragment.h" 00015 #include "eformat/SizeCheckIssue.h" 00016 #include "eformat/HeaderMarker.h" 00017 00018 eformat::old::ROBFragment::ROBFragment (const uint32_t* it) 00019 : eformat::old::Header(it, eformat::ROB), 00020 m_start(specific_header()) 00021 { 00022 } 00023 00024 bool eformat::old::ROBFragment::check () const 00025 { 00026 eformat::old::Header::check(); //< first do a generic check 00027 if (nspecific() != 4) throw EFORMAT_SIZE_CHECK(4, nspecific()); 00028 return true; 00029 } 00030 00031 bool eformat::old::ROBFragment::check_tree () const 00032 { 00033 check(); // check myself 00034 for (size_t i=0; i<noffset(); ++i) { 00035 size_t rod_size = 0; 00036 //typical 00037 if (noffset() == 1) rod_size = fragment_size_word() - header_size_word(); 00038 else { //more atypical, have to calculate 00039 if (i != noffset() - 1) rod_size = (0xffffff & offset()[i+1]); 00040 else rod_size = fragment_size_word(); 00041 rod_size -= (0xffffff & offset()[i]); 00042 } 00043 eformat::old::RODFragment f(child(i), rod_size); 00044 f.check(); 00045 } 00046 return true; 00047 } 00048 00049 eformat::old::RODFragment eformat::old::ROBFragment::rod (size_t n) const 00050 { 00051 check(); 00052 size_t rod_size = 0; 00053 //typical 00054 if (noffset() == 1) 00055 rod_size = fragment_size_word() - header_size_word(); 00056 else { //more atypical, have to calculate 00057 if (n != noffset() - 1) rod_size = (0xffffff & offset()[n+1]); 00058 else rod_size = fragment_size_word(); 00059 rod_size -= (0xffffff & offset()[n]); 00060 } 00061 eformat::old::RODFragment f(child(n), rod_size); 00062 f.check(); 00063 return f; 00064 } 00065 00066 00067