Pol  Revision:3cfda13
uop.cpp
Go to the documentation of this file.
1 // This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2 
3 #include "uop.h"
4 
5 
6 
7 uop_t::uop_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent,
8  uop_t* p__root) : kaitai::kstruct(p__io) {
9  m__parent = p__parent;
10  m__root = this;
11  _read();
12 }
13 
14 void uop_t::_read() {
15  m_header = new header_t(m__io, this, m__root);
16 }
17 
19  delete m_header;
20 }
21 
22 uop_t::block_addr_t::block_addr_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent,
23  uop_t* p__root) : kaitai::kstruct(p__io) {
24  m__parent = p__parent;
25  m__root = p__root;
26  f_block_body = false;
27  _read();
28 }
29 
31  m_blockaddr = m__io->read_u8le();
32 }
33 
35  if (f_block_body && !n_block_body) {
36  delete m_block_body;
37  }
38 }
39 
41  if (f_block_body)
42  return m_block_body;
43  n_block_body = true;
44  if (blockaddr() > 0) {
45  n_block_body = false;
46  std::streampos _pos = m__io->pos();
47  m__io->seek(blockaddr());
48  m_block_body = new block_body_t(m__io, this, m__root);
49  m__io->seek(_pos);
50  }
51  f_block_body = true;
52  return m_block_body;
53 }
54 
55 uop_t::block_body_t::block_body_t(kaitai::kstream* p__io, uop_t::block_addr_t* p__parent,
56  uop_t* p__root) : kaitai::kstruct(p__io) {
57  m__parent = p__parent;
58  m__root = p__root;
59  _read();
60 }
61 
63  m_nfiles = m__io->read_u4le();
64  m_next_addr = new block_addr_t(m__io, this, m__root);
65  int l_files = nfiles();
66  m_files = new std::vector<file_t*>();
67  m_files->reserve(l_files);
68  for (int i = 0; i < l_files; i++) {
69  m_files->push_back(new file_t(m__io, this, m__root));
70  }
71 }
72 
74  delete m_next_addr;
75  for (std::vector<file_t*>::iterator it = m_files->begin(); it != m_files->end(); ++it) {
76  delete *it;
77  }
78  delete m_files;
79 }
80 
81 uop_t::data_header_v5_t::data_header_v5_t(kaitai::kstream* p__io, uop_t::file_t* p__parent,
82  uop_t* p__root) : kaitai::kstruct(p__io) {
83  m__parent = p__parent;
84  m__root = p__root;
85  _read();
86 }
87 
89  m_bytes = m__io->read_bytes(_parent()->file_len());
90  m_filebytes = m__io->read_bytes(_parent()->compressed_size());
91 }
92 
94 }
95 
96 uop_t::header_t::header_t(kaitai::kstream* p__io, uop_t* p__parent,
97  uop_t* p__root) : kaitai::kstruct(p__io) {
98  m__parent = p__parent;
99  m__root = p__root;
100  _read();
101 }
102 
104  m_magic = m__io->ensure_fixed_contents(std::string("\x4D\x59\x50\x00", 4));
105  m_version = m__io->read_bytes(4);
106  m_signature = m__io->read_bytes(4);
107  m_firstblock = new block_addr_t(m__io, this, m__root);
108  m_maxfiles_per_block = m__io->read_u4le();
109  m_nfiles = m__io->read_u4le();
110 }
111 
113  delete m_firstblock;
114 }
115 
116 uop_t::file_t::file_t(kaitai::kstream* p__io, uop_t::block_body_t* p__parent,
117  uop_t* p__root) : kaitai::kstruct(p__io) {
118  m__parent = p__parent;
119  m__root = p__root;
120  f_data = false;
121  _read();
122 }
123 
125  m_dataaddr = m__io->read_u8le();
126  m_file_len = m__io->read_u4le();
127  m_compressed_size = m__io->read_u4le();
128  m_decompressed_size = m__io->read_u4le();
129  m_filehash = m__io->read_u8le();
130  m_adler32 = m__io->read_u4le();
131  m_compression_type = static_cast<uop_t::compression_type_t>(m__io->read_u2le());
132 }
133 
135  if (f_data && !n_data) {
136  delete m__io__raw_data;
137  delete m_data;
138  }
139 }
140 
142  if (f_data)
143  return m_data;
144  n_data = true;
145  if (dataaddr() > 0) {
146  n_data = false;
147  std::streampos _pos = m__io->pos();
148  m__io->seek(dataaddr());
149  m__raw_data = m__io->read_bytes((file_len() + compressed_size()));
150  m__io__raw_data = new kaitai::kstream(m__raw_data);
152  m__io->seek(_pos);
153  }
154  f_data = true;
155  return m_data;
156 }
uint32_t m_decompressed_size
Definition: uop.h:188
uint32_t m_compressed_size
Definition: uop.h:187
uint32_t compressed_size() const
Definition: uop.h:200
void _read()
Definition: uop.cpp:14
Definition: uop.h:15
uop_t * m__root
Definition: uop.h:90
bool f_data
Definition: uop.h:172
uop_t::file_t * m__parent
Definition: uop.h:117
kaitai::kstruct * m__parent
Definition: uop.h:214
std::vector< file_t * > * m_files
Definition: uop.h:89
uop_t(kaitai::kstream *p__io, kaitai::kstruct *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:7
bool n_block_body
Definition: uop.h:52
uop_t::block_addr_t * m__parent
Definition: uop.h:91
uop_t::block_body_t * m__parent
Definition: uop.h:193
compression_type_t
Definition: uop.h:24
std::string m__raw_data
Definition: uop.h:194
uop_t::file_t * _parent() const
Definition: uop.h:123
std::string m_filebytes
Definition: uop.h:115
void _read()
Definition: uop.cpp:103
uint32_t file_len() const
Definition: uop.h:199
compression_type_t m_compression_type
Definition: uop.h:191
block_addr_t(kaitai::kstream *p__io, kaitai::kstruct *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:22
uint32_t nfiles() const
Definition: uop.h:94
file_t(kaitai::kstream *p__io, uop_t::block_body_t *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:116
std::string m_magic
Definition: uop.h:139
uint64_t m_blockaddr
Definition: uop.h:63
uint32_t m_file_len
Definition: uop.h:186
uop_t * m__root
Definition: uop.h:213
void _read()
Definition: uop.cpp:30
uint32_t m_nfiles
Definition: uop.h:144
block_addr_t * m_firstblock
Definition: uop.h:142
uint64_t m_dataaddr
Definition: uop.h:185
uop_t * m__root
Definition: uop.h:192
header_t * m_header
Definition: uop.h:212
void _read()
Definition: uop.cpp:62
uint32_t m_maxfiles_per_block
Definition: uop.h:143
data_header_v5_t(kaitai::kstream *p__io, uop_t::file_t *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:81
uop_t * m__root
Definition: uop.h:145
uop_t * m__parent
Definition: uop.h:146
uint32_t m_adler32
Definition: uop.h:190
std::string m_signature
Definition: uop.h:141
std::string m_version
Definition: uop.h:140
block_addr_t * m_next_addr
Definition: uop.h:88
~uop_t()
Definition: uop.cpp:18
kaitai::kstruct * m__parent
Definition: uop.h:65
uint64_t dataaddr() const
Definition: uop.h:198
uint64_t blockaddr() const
Definition: uop.h:68
std::string m_bytes
Definition: uop.h:114
block_body_t * block_body()
Definition: uop.cpp:40
void _read()
Definition: uop.cpp:124
bool f_block_body
Definition: uop.h:50
bool n_data
Definition: uop.h:174
uop_t * m__root
Definition: uop.h:64
data_header_v5_t * data()
Definition: uop.cpp:141
uint64_t m_filehash
Definition: uop.h:189
header_t(kaitai::kstream *p__io, uop_t *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:96
block_body_t * m_block_body
Definition: uop.h:51
data_header_v5_t * m_data
Definition: uop.h:173
kaitai::kstream * m__io__raw_data
Definition: uop.h:195
uint32_t m_nfiles
Definition: uop.h:87
block_body_t(kaitai::kstream *p__io, uop_t::block_addr_t *p__parent=0, uop_t *p__root=0)
Definition: uop.cpp:55