#include <RawFileUtil.h>
Public Member Functions | |
DataSeparatorRecord () | |
DataSeparatorRecord () | |
void | dump (std::ostream &os=std::cout) const |
void | dump (std::ostream &os=std::cout) const |
const data_separator_record & | getRecord () const |
const data_separator_record & | getRecord () const |
void | setDataBlockNumber (uint32_t dn) |
void | setDataBlockNumber (uint32_t dn) |
void | setDataBlockSize (uint32_t ds) |
void | setDataBlockSize (uint32_t ds) |
Private Attributes | |
data_separator_record | m_record |
Friends | |
raw_ofstream & | operator<< (raw_ofstream &os, DataSeparatorRecord &record) |
raw_ofstream & | operator<< (raw_ofstream &os, DataSeparatorRecord &record) |
raw_ifstream & | operator>> (raw_ifstream &is, DataSeparatorRecord &record) |
raw_ifstream & | operator>> (raw_ifstream &is, DataSeparatorRecord &record) |
|
00269 { 00270 m_record.marker = 0x1234cccc; 00271 m_record.record_size = 4; 00272 //m_record.data_block_number; //set manually 00273 //m_record.data_block_size; //set manually 00274 }
|
|
|
|
|
|
00328 { 00329 os << "[RawFile] DataSeparatorRecord:" << std::endl << std::hex 00330 << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl 00331 << "[RawFile] \trecord_size : 0x" << m_record.record_size << std::endl 00332 << "[RawFile] \tdata_block_number : 0x" << m_record.data_block_number << std::endl 00333 << "[RawFile] \tdata_block_size : 0x" << m_record.data_block_size 00334 << std::dec << std::endl; 00335 }
|
|
00132 { return m_record; }
|
|
00132 { return m_record; }
|
|
00135 { m_record.data_block_number = dn; }
|
|
00135 { m_record.data_block_number = dn; }
|
|
00136 { m_record.data_block_size = ds; }
|
|
00136 { m_record.data_block_size = ds; }
|
|
00212 { 00213 // write data block 00214 if (os.write((char*)(&record.m_record), sizeof(data_separator_record)).fail()) { 00215 std::cerr << "[RawFile] Error occurred while writing file" << std::endl; 00216 throw FailedToWrite("DataSeparatorRecord"); 00217 } 00218 00219 return os; 00220 }
|
|
00212 { 00213 // write data block 00214 if (os.write((char*)(&record.m_record), sizeof(data_separator_record)).fail()) { 00215 std::cerr << "[RawFile] Error occurred while writing file" << std::endl; 00216 throw FailedToWrite("DataSeparatorRecord"); 00217 } 00218 00219 return os; 00220 }
|
|
00096 { 00097 // read data block 00098 if (is.read((char*)(&record.m_record), sizeof(data_separator_record)).fail()) { 00099 //std::cerr << "[RawFile] Error occurred while reading file" << std::endl; 00100 throw BadInputStream("DataSeparatorRecord"); 00101 //throw ReachEndOfFile(); 00102 } 00103 00104 // data validation checks 00105 if (record.m_record.marker != 0x1234cccc) { 00106 if (record.m_record.marker == 0x1234dddd) { 00107 throw ReachEndOfFile(is.currentFile().c_str()); 00108 } 00109 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl; 00110 throw WrongMarker(0x1234cccc, record.m_record.marker); 00111 } 00112 00113 if (record.m_record.record_size != 4) { 00114 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl; 00115 throw UnexpectedRecordSize("DataSeparatorRecord", 4, record.m_record.record_size); 00116 } 00117 00118 return is; 00119 }
|
|
00096 { 00097 // read data block 00098 if (is.read((char*)(&record.m_record), sizeof(data_separator_record)).fail()) { 00099 //std::cerr << "[RawFile] Error occurred while reading file" << std::endl; 00100 throw BadInputStream("DataSeparatorRecord"); 00101 //throw ReachEndOfFile(); 00102 } 00103 00104 // data validation checks 00105 if (record.m_record.marker != 0x1234cccc) { 00106 if (record.m_record.marker == 0x1234dddd) { 00107 throw ReachEndOfFile(is.currentFile().c_str()); 00108 } 00109 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl; 00110 throw WrongMarker(0x1234cccc, record.m_record.marker); 00111 } 00112 00113 if (record.m_record.record_size != 4) { 00114 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl; 00115 throw UnexpectedRecordSize("DataSeparatorRecord", 4, record.m_record.record_size); 00116 } 00117 00118 return is; 00119 }
|
|
|