00001 //Dear emacs, this is -*- c++ -*- 00002 00013 #include "eformat/old/RODFragment.h" 00014 #include "eformat/util.h" 00015 #include "eformat/SizeCheckIssue.h" 00016 #include "eformat/BadVersionIssue.h" 00017 #include "eformat/WrongMarkerIssue.h" 00018 #include "eformat/HeaderMarker.h" 00019 #include "eformat/Version.h" 00020 #include "eformat/Status.h" 00021 00022 eformat::old::RODFragment::RODFragment (const uint32_t* it, size_t size_word) 00023 : m_start(it), 00024 m_size(size_word) 00025 { 00026 uint32_t m = marker(); 00027 if (m != eformat::ROD) throw EFORMAT_WRONG_MARKER(m, eformat::ROD); 00028 } 00029 00030 uint32_t eformat::old::RODFragment::fragment_size_word() const 00031 { 00032 return header_size_word() + trailer_size_word() + nstatus() + ndata(); 00033 } 00034 00035 const uint32_t* eformat::old::RODFragment::status (void) const 00036 { 00037 if (status_position() == eformat::STATUS_FRONT) return &m_start[9]; 00038 return &m_start[9 + ndata()]; 00039 } 00040 00041 const uint32_t* eformat::old::RODFragment::data (void) const 00042 { 00043 if (status_position() == eformat::STATUS_BACK) return &m_start[9]; 00044 return &m_start[9 + nstatus()]; 00045 } 00046 00047 bool eformat::old::RODFragment::check () const 00048 { 00049 if ( version() >> 16 != eformat::MAJOR_OLD_VERSION ) 00050 throw EFORMAT_BAD_VERSION(version() >> 16, eformat::MAJOR_OLD_VERSION); 00051 if ( header_size_word() != 9 ) 00052 throw EFORMAT_SIZE_CHECK(9, header_size_word()); 00053 if ( m_size != 12 + nstatus() + ndata() ) 00054 throw EFORMAT_SIZE_CHECK(m_size, (12 + nstatus() + ndata())); 00055 return true; 00056 } 00057 00058 00059 00060