OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ErsSarRecordHeader.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
13 
14 
15 namespace ossimplugins
16 {
17 
19 {
20 }
21 
23 {
24 }
25 
27 {
28  os << "record_sequence_number:" << data._rec_seq << std::endl;
29  os << "first_record_sub-type:" << (int)data._rec_sub1 << std::endl;
30  os << "record_type_code:" << (int)data._rec_type << std::endl;
31  os << "second_record_sub-type:" << (int)data._rec_sub2 << std::endl;
32  os << "third_record_sub-type:" << (int)data._rec_sub3 << std::endl;
33  os << "length:" << data._length << std::endl;
34  return os;
35 }
36 
38 {
39  is.read((char*)&(data._rec_seq), 4);
40  data.SwitchEndian(data._rec_seq);
41  is.read((char*)&(data._rec_sub1), 1);
42  is.read((char*)&(data._rec_type), 1);
43  is.read((char*)&(data._rec_sub2), 1);
44  is.read((char*)&(data._rec_sub3), 1);
45  is.read((char*)&(data._length), 4);
46  data.SwitchEndian(data._length);
47  return is;
48 }
49 
51  _rec_seq(rhs._rec_seq),
52  _rec_sub1(rhs._rec_sub1),
53  _rec_type(rhs._rec_type),
54  _rec_sub2(rhs._rec_sub2),
55  _rec_sub3(rhs._rec_sub3)
56 {
57 }
58 
60 {
61  _rec_seq = rhs._rec_seq;
62  _rec_sub1 = rhs._rec_sub1;
63  _rec_type = rhs._rec_type;
64  _rec_sub2 = rhs._rec_sub2;
65  _rec_sub3 = rhs._rec_sub3;
66  return *this;
67 }
68 
69 void ErsSarRecordHeader::SwitchEndian(unsigned int& value)
70 {
71  char buffer[4];
72  char res[4];
73 
74  memcpy(buffer, &value, 4);
75  res[0] = buffer[3];
76  res[1] = buffer[2];
77  res[2] = buffer[1];
78  res[3] = buffer[0];
79 
80  memcpy(&value, res, 4);
81 }
82 }
unsigned char _rec_type
Record type code.
unsigned int _rec_seq
Record sequence number.
std::ostream & operator<<(std::ostream &os, const AlosPalsarData &data)
unsigned int _length
Length of this record (in bytes)
virtual ~ErsSarRecordHeader()
Destructor.
ErsSarRecordHeader & operator=(const ErsSarRecordHeader &rhs)
Copy operator.
This class is able to read a record header.
std::istream & operator>>(std::istream &is, AlosPalsarData &data)
unsigned char _rec_sub1
First record sub-type code.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
unsigned char _rec_sub3
Third record sub-type code.
unsigned char _rec_sub2
Second record sub-type code.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
void SwitchEndian(unsigned int &value)
This function switch the LSB value and the MSB value of the parameter.