Regenerate cpp source files with

This commit is contained in:
chunqing286 2023-08-04 09:13:51 +08:00 committed by Nikolaj Schlej
parent b2a8952c71
commit 4a41c33596
2 changed files with 44 additions and 106 deletions

View File

@ -6,24 +6,18 @@
ami_nvar_t::ami_nvar_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::ami_nvar_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = this; m__root = this;
m_entries = 0; m_entries = nullptr;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::_read() { void ami_nvar_t::_read() {
m_entries = new std::vector<nvar_entry_t*>(); m_entries = std::unique_ptr<std::vector<std::unique_ptr<nvar_entry_t>>>(new std::vector<std::unique_ptr<nvar_entry_t>>());
{ {
int i = 0; int i = 0;
nvar_entry_t* _; nvar_entry_t* _;
do { do {
_ = new nvar_entry_t(m__io, this, m__root); _ = new nvar_entry_t(m__io, this, m__root);
m_entries->push_back(_); m_entries->push_back(std::move(std::unique_ptr<nvar_entry_t>(_)));
i++; i++;
} while (!( ((_->signature_first() != 78) || (_io()->is_eof())) )); } while (!( ((_->signature_first() != 78) || (_io()->is_eof())) ));
} }
@ -34,24 +28,12 @@ ami_nvar_t::~ami_nvar_t() {
} }
void ami_nvar_t::_clean_up() { void ami_nvar_t::_clean_up() {
if (m_entries) {
for (std::vector<nvar_entry_t*>::iterator it = m_entries->begin(); it != m_entries->end(); ++it) {
delete *it;
}
delete m_entries; m_entries = 0;
}
} }
ami_nvar_t::nvar_attributes_t::nvar_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::nvar_attributes_t::nvar_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = p__root; m__root = p__root;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::nvar_attributes_t::_read() { void ami_nvar_t::nvar_attributes_t::_read() {
@ -75,18 +57,12 @@ void ami_nvar_t::nvar_attributes_t::_clean_up() {
ami_nvar_t::ucs2_string_t::ucs2_string_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::ucs2_string_t::ucs2_string_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = p__root; m__root = p__root;
m_ucs2_chars = 0; m_ucs2_chars = nullptr;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::ucs2_string_t::_read() { void ami_nvar_t::ucs2_string_t::_read() {
m_ucs2_chars = new std::vector<uint16_t>(); m_ucs2_chars = std::unique_ptr<std::vector<uint16_t>>(new std::vector<uint16_t>());
{ {
int i = 0; int i = 0;
uint16_t _; uint16_t _;
@ -103,21 +79,12 @@ ami_nvar_t::ucs2_string_t::~ucs2_string_t() {
} }
void ami_nvar_t::ucs2_string_t::_clean_up() { void ami_nvar_t::ucs2_string_t::_clean_up() {
if (m_ucs2_chars) {
delete m_ucs2_chars; m_ucs2_chars = 0;
}
} }
ami_nvar_t::nvar_extended_attributes_t::nvar_extended_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::nvar_extended_attributes_t::nvar_extended_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = p__root; m__root = p__root;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::nvar_extended_attributes_t::_read() { void ami_nvar_t::nvar_extended_attributes_t::_read() {
@ -138,18 +105,12 @@ void ami_nvar_t::nvar_extended_attributes_t::_clean_up() {
ami_nvar_t::nvar_entry_t::nvar_entry_t(kaitai::kstream* p__io, ami_nvar_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::nvar_entry_t::nvar_entry_t(kaitai::kstream* p__io, ami_nvar_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = p__root; m__root = p__root;
m_attributes = 0; m_attributes = nullptr;
m_body = 0; m_body = nullptr;
m__io__raw_body = 0; m__io__raw_body = nullptr;
f_offset = false; f_offset = false;
f_end_offset = false; f_end_offset = false;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::nvar_entry_t::_read() { void ami_nvar_t::nvar_entry_t::_read() {
@ -187,14 +148,14 @@ void ami_nvar_t::nvar_entry_t::_read() {
n_attributes = true; n_attributes = true;
if (signature_first() == 78) { if (signature_first() == 78) {
n_attributes = false; n_attributes = false;
m_attributes = new nvar_attributes_t(m__io, this, m__root); m_attributes = std::unique_ptr<nvar_attributes_t>(new nvar_attributes_t(m__io, this, m__root));
} }
n_body = true; n_body = true;
if (signature_first() == 78) { if (signature_first() == 78) {
n_body = false; n_body = false;
m__raw_body = m__io->read_bytes((size() - ((4 + 2) + 4))); m__raw_body = m__io->read_bytes((size() - ((4 + 2) + 4)));
m__io__raw_body = new kaitai::kstream(m__raw_body); m__io__raw_body = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_body));
m_body = new nvar_entry_body_t(m__io__raw_body, this, m__root); m_body = std::unique_ptr<nvar_entry_body_t>(new nvar_entry_body_t(m__io__raw_body.get(), this, m__root));
} }
n_invoke_end_offset = true; n_invoke_end_offset = true;
if ( ((signature_first() == 78) && (end_offset() >= 0)) ) { if ( ((signature_first() == 78) && (end_offset() >= 0)) ) {
@ -217,17 +178,8 @@ void ami_nvar_t::nvar_entry_t::_clean_up() {
if (!n_next) { if (!n_next) {
} }
if (!n_attributes) { if (!n_attributes) {
if (m_attributes) {
delete m_attributes; m_attributes = 0;
}
} }
if (!n_body) { if (!n_body) {
if (m__io__raw_body) {
delete m__io__raw_body; m__io__raw_body = 0;
}
if (m_body) {
delete m_body; m_body = 0;
}
} }
if (!n_invoke_end_offset) { if (!n_invoke_end_offset) {
} }
@ -252,8 +204,8 @@ int32_t ami_nvar_t::nvar_entry_t::end_offset() {
ami_nvar_t::nvar_entry_body_t::nvar_entry_body_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) { ami_nvar_t::nvar_entry_body_t::nvar_entry_body_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent, ami_nvar_t* p__root) : kaitai::kstruct(p__io) {
m__parent = p__parent; m__parent = p__parent;
m__root = p__root; m__root = p__root;
m_ucs2_name = 0; m_ucs2_name = nullptr;
m_extended_header_attributes = 0; m_extended_header_attributes = nullptr;
f_extended_header_attributes = false; f_extended_header_attributes = false;
f_data_start_offset = false; f_data_start_offset = false;
f_extended_header_size_field = false; f_extended_header_size_field = false;
@ -263,13 +215,7 @@ ami_nvar_t::nvar_entry_body_t::nvar_entry_body_t(kaitai::kstream* p__io, ami_nva
f_data_end_offset = false; f_data_end_offset = false;
f_extended_header_size = false; f_extended_header_size = false;
f_extended_header_hash = false; f_extended_header_hash = false;
_read();
try {
_read();
} catch(...) {
_clean_up();
throw;
}
} }
void ami_nvar_t::nvar_entry_body_t::_read() { void ami_nvar_t::nvar_entry_body_t::_read() {
@ -291,7 +237,7 @@ void ami_nvar_t::nvar_entry_body_t::_read() {
n_ucs2_name = true; n_ucs2_name = true;
if ( ((!(_parent()->attributes()->ascii_name())) && (!(_parent()->attributes()->data_only())) && (_parent()->attributes()->valid())) ) { if ( ((!(_parent()->attributes()->ascii_name())) && (!(_parent()->attributes()->data_only())) && (_parent()->attributes()->valid())) ) {
n_ucs2_name = false; n_ucs2_name = false;
m_ucs2_name = new ucs2_string_t(m__io, this, m__root); m_ucs2_name = std::unique_ptr<ucs2_string_t>(new ucs2_string_t(m__io, this, m__root));
} }
n_invoke_data_start = true; n_invoke_data_start = true;
if (data_start_offset() >= 0) { if (data_start_offset() >= 0) {
@ -313,16 +259,10 @@ void ami_nvar_t::nvar_entry_body_t::_clean_up() {
if (!n_ascii_name) { if (!n_ascii_name) {
} }
if (!n_ucs2_name) { if (!n_ucs2_name) {
if (m_ucs2_name) {
delete m_ucs2_name; m_ucs2_name = 0;
}
} }
if (!n_invoke_data_start) { if (!n_invoke_data_start) {
} }
if (f_extended_header_attributes && !n_extended_header_attributes) { if (f_extended_header_attributes && !n_extended_header_attributes) {
if (m_extended_header_attributes) {
delete m_extended_header_attributes; m_extended_header_attributes = 0;
}
} }
if (f_extended_header_size_field && !n_extended_header_size_field) { if (f_extended_header_size_field && !n_extended_header_size_field) {
} }
@ -336,17 +276,17 @@ void ami_nvar_t::nvar_entry_body_t::_clean_up() {
ami_nvar_t::nvar_extended_attributes_t* ami_nvar_t::nvar_entry_body_t::extended_header_attributes() { ami_nvar_t::nvar_extended_attributes_t* ami_nvar_t::nvar_entry_body_t::extended_header_attributes() {
if (f_extended_header_attributes) if (f_extended_header_attributes)
return m_extended_header_attributes; return m_extended_header_attributes.get();
n_extended_header_attributes = true; n_extended_header_attributes = true;
if ( ((_parent()->attributes()->valid()) && (_parent()->attributes()->extended_header()) && (extended_header_size() >= (1 + 2))) ) { if ( ((_parent()->attributes()->valid()) && (_parent()->attributes()->extended_header()) && (extended_header_size() >= (1 + 2))) ) {
n_extended_header_attributes = false; n_extended_header_attributes = false;
std::streampos _pos = m__io->pos(); std::streampos _pos = m__io->pos();
m__io->seek((_io()->pos() - extended_header_size())); m__io->seek((_io()->pos() - extended_header_size()));
m_extended_header_attributes = new nvar_extended_attributes_t(m__io, this, m__root); m_extended_header_attributes = std::unique_ptr<nvar_extended_attributes_t>(new nvar_extended_attributes_t(m__io, this, m__root));
m__io->seek(_pos); m__io->seek(_pos);
f_extended_header_attributes = true; f_extended_header_attributes = true;
} }
return m_extended_header_attributes; return m_extended_header_attributes.get();
} }
int32_t ami_nvar_t::nvar_entry_body_t::data_start_offset() { int32_t ami_nvar_t::nvar_entry_body_t::data_start_offset() {

View File

@ -1,10 +1,10 @@
#ifndef AMI_NVAR_H_ #pragma once
#define AMI_NVAR_H_
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild // This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "../kaitai/kaitaistruct.h" #include "../kaitai/kaitaistruct.h"
#include <stdint.h> #include <stdint.h>
#include <memory>
#include <vector> #include <vector>
#if KAITAI_STRUCT_VERSION < 9000L #if KAITAI_STRUCT_VERSION < 9000L
@ -20,7 +20,7 @@ public:
class nvar_entry_t; class nvar_entry_t;
class nvar_entry_body_t; class nvar_entry_body_t;
ami_nvar_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, ami_nvar_t* p__root = 0); ami_nvar_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -33,7 +33,7 @@ public:
public: public:
nvar_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent = 0, ami_nvar_t* p__root = 0); nvar_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -71,7 +71,7 @@ public:
public: public:
ucs2_string_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent = 0, ami_nvar_t* p__root = 0); ucs2_string_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -81,12 +81,12 @@ public:
~ucs2_string_t(); ~ucs2_string_t();
private: private:
std::vector<uint16_t>* m_ucs2_chars; std::unique_ptr<std::vector<uint16_t>> m_ucs2_chars;
ami_nvar_t* m__root; ami_nvar_t* m__root;
ami_nvar_t::nvar_entry_body_t* m__parent; ami_nvar_t::nvar_entry_body_t* m__parent;
public: public:
std::vector<uint16_t>* ucs2_chars() const { return m_ucs2_chars; } std::vector<uint16_t>* ucs2_chars() const { return m_ucs2_chars.get(); }
ami_nvar_t* _root() const { return m__root; } ami_nvar_t* _root() const { return m__root; }
ami_nvar_t::nvar_entry_body_t* _parent() const { return m__parent; } ami_nvar_t::nvar_entry_body_t* _parent() const { return m__parent; }
}; };
@ -95,7 +95,7 @@ public:
public: public:
nvar_extended_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent = 0, ami_nvar_t* p__root = 0); nvar_extended_attributes_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_body_t* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -127,7 +127,7 @@ public:
public: public:
nvar_entry_t(kaitai::kstream* p__io, ami_nvar_t* p__parent = 0, ami_nvar_t* p__root = 0); nvar_entry_t(kaitai::kstream* p__io, ami_nvar_t* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -180,14 +180,14 @@ public:
bool _is_null_next() { next(); return n_next; }; bool _is_null_next() { next(); return n_next; };
private: private:
nvar_attributes_t* m_attributes; std::unique_ptr<nvar_attributes_t> m_attributes;
bool n_attributes; bool n_attributes;
public: public:
bool _is_null_attributes() { attributes(); return n_attributes; }; bool _is_null_attributes() { attributes(); return n_attributes; };
private: private:
nvar_entry_body_t* m_body; std::unique_ptr<nvar_entry_body_t> m_body;
bool n_body; bool n_body;
public: public:
@ -210,7 +210,7 @@ public:
bool _is_null__raw_body() { _raw_body(); return n__raw_body; }; bool _is_null__raw_body() { _raw_body(); return n__raw_body; };
private: private:
kaitai::kstream* m__io__raw_body; std::unique_ptr<kaitai::kstream> m__io__raw_body;
public: public:
std::string invoke_offset() const { return m_invoke_offset; } std::string invoke_offset() const { return m_invoke_offset; }
@ -218,20 +218,20 @@ public:
std::string signature_rest() const { return m_signature_rest; } std::string signature_rest() const { return m_signature_rest; }
uint16_t size() const { return m_size; } uint16_t size() const { return m_size; }
uint64_t next() const { return m_next; } uint64_t next() const { return m_next; }
nvar_attributes_t* attributes() const { return m_attributes; } nvar_attributes_t* attributes() const { return m_attributes.get(); }
nvar_entry_body_t* body() const { return m_body; } nvar_entry_body_t* body() const { return m_body.get(); }
std::string invoke_end_offset() const { return m_invoke_end_offset; } std::string invoke_end_offset() const { return m_invoke_end_offset; }
ami_nvar_t* _root() const { return m__root; } ami_nvar_t* _root() const { return m__root; }
ami_nvar_t* _parent() const { return m__parent; } ami_nvar_t* _parent() const { return m__parent; }
std::string _raw_body() const { return m__raw_body; } std::string _raw_body() const { return m__raw_body; }
kaitai::kstream* _io__raw_body() const { return m__io__raw_body; } kaitai::kstream* _io__raw_body() const { return m__io__raw_body.get(); }
}; };
class nvar_entry_body_t : public kaitai::kstruct { class nvar_entry_body_t : public kaitai::kstruct {
public: public:
nvar_entry_body_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent = 0, ami_nvar_t* p__root = 0); nvar_entry_body_t(kaitai::kstream* p__io, ami_nvar_t::nvar_entry_t* p__parent = nullptr, ami_nvar_t* p__root = nullptr);
private: private:
void _read(); void _read();
@ -242,7 +242,7 @@ public:
private: private:
bool f_extended_header_attributes; bool f_extended_header_attributes;
nvar_extended_attributes_t* m_extended_header_attributes; std::unique_ptr<nvar_extended_attributes_t> m_extended_header_attributes;
bool n_extended_header_attributes; bool n_extended_header_attributes;
public: public:
@ -355,7 +355,7 @@ public:
bool _is_null_ascii_name() { ascii_name(); return n_ascii_name; }; bool _is_null_ascii_name() { ascii_name(); return n_ascii_name; };
private: private:
ucs2_string_t* m_ucs2_name; std::unique_ptr<ucs2_string_t> m_ucs2_name;
bool n_ucs2_name; bool n_ucs2_name;
public: public:
@ -377,7 +377,7 @@ public:
uint8_t guid_index() const { return m_guid_index; } uint8_t guid_index() const { return m_guid_index; }
std::string guid() const { return m_guid; } std::string guid() const { return m_guid; }
std::string ascii_name() const { return m_ascii_name; } std::string ascii_name() const { return m_ascii_name; }
ucs2_string_t* ucs2_name() const { return m_ucs2_name; } ucs2_string_t* ucs2_name() const { return m_ucs2_name.get(); }
std::string invoke_data_start() const { return m_invoke_data_start; } std::string invoke_data_start() const { return m_invoke_data_start; }
std::string data() const { return m_data; } std::string data() const { return m_data; }
ami_nvar_t* _root() const { return m__root; } ami_nvar_t* _root() const { return m__root; }
@ -385,14 +385,12 @@ public:
}; };
private: private:
std::vector<nvar_entry_t*>* m_entries; std::unique_ptr<std::vector<std::unique_ptr<nvar_entry_t>>> m_entries;
ami_nvar_t* m__root; ami_nvar_t* m__root;
kaitai::kstruct* m__parent; kaitai::kstruct* m__parent;
public: public:
std::vector<nvar_entry_t*>* entries() const { return m_entries; } std::vector<std::unique_ptr<nvar_entry_t>>* entries() const { return m_entries.get(); }
ami_nvar_t* _root() const { return m__root; } ami_nvar_t* _root() const { return m__root; }
kaitai::kstruct* _parent() const { return m__parent; } kaitai::kstruct* _parent() const { return m__parent; }
}; };
#endif // AMI_NVAR_H_