2017-07-22 08:59:06 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
2017-08-05 13:09:50 +00:00
|
|
|
#include <fnd/MemoryBlob.h>
|
2017-07-22 08:59:06 +00:00
|
|
|
#include <fnd/ISerialiseableBinary.h>
|
|
|
|
|
|
|
|
namespace es
|
|
|
|
{
|
|
|
|
class ETicketSectionHeader_V2 :
|
|
|
|
public fnd::ISerialiseableBinary
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum SectionType
|
|
|
|
{
|
|
|
|
PERMANENT = 1,
|
|
|
|
SUBSCRIPTION = 2,
|
|
|
|
CONTENT = 3,
|
|
|
|
CONTENT_CONSUMPTION = 4,
|
|
|
|
ACCESS_TITLE = 5,
|
|
|
|
LIMITED_RESOURCE = 6,
|
|
|
|
};
|
|
|
|
|
|
|
|
ETicketSectionHeader_V2();
|
|
|
|
ETicketSectionHeader_V2(const ETicketSectionHeader_V2& other);
|
2018-03-22 05:26:22 +00:00
|
|
|
ETicketSectionHeader_V2(const byte_t* bytes, size_t len);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
|
|
|
bool operator==(const ETicketSectionHeader_V2& other) const;
|
|
|
|
bool operator!=(const ETicketSectionHeader_V2& other) const;
|
|
|
|
void operator=(const ETicketSectionHeader_V2& other);
|
|
|
|
|
|
|
|
// to be used after export
|
2018-03-22 05:26:22 +00:00
|
|
|
const byte_t* getBytes() const;
|
2017-07-22 08:59:06 +00:00
|
|
|
size_t getSize() const;
|
|
|
|
|
|
|
|
// export/import binary
|
|
|
|
virtual void exportBinary();
|
2018-03-22 05:26:22 +00:00
|
|
|
virtual void importBinary(const byte_t* bytes, size_t len);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
virtual void clear();
|
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t getSectionOffset() const;
|
|
|
|
void setSectionOffset(uint32_t offset);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t getRecordSize() const;
|
|
|
|
void setRecordSize(uint32_t size);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t getSectionSize() const;
|
|
|
|
void getSectionSize(uint32_t size);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint16_t getRecordNum() const;
|
|
|
|
void setRecordNum(uint16_t record_num);
|
2017-07-22 08:59:06 +00:00
|
|
|
|
|
|
|
SectionType getSectionType() const;
|
|
|
|
void setSectionType(SectionType type);
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "ETICKET_SECTION_HEADER_V2";
|
|
|
|
#pragma pack (push, 1)
|
|
|
|
struct sSectionHeader_v2
|
|
|
|
{
|
|
|
|
private:
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t section_offset_;
|
|
|
|
uint32_t record_size_;
|
|
|
|
uint32_t section_size_;
|
|
|
|
uint16_t record_num_;
|
|
|
|
uint16_t section_type_;
|
2017-07-22 08:59:06 +00:00
|
|
|
public:
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t section_offset() const { return le_word(section_offset_); }
|
|
|
|
void set_section_offset(uint32_t offset) { section_offset_ = le_word(offset); }
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t record_size() const { return le_word(record_size_); }
|
|
|
|
void set_record_size(uint32_t size) { record_size_ = le_word(size); }
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t section_size() const { return le_word(section_size_); }
|
|
|
|
void set_section_size(uint32_t size) { section_size_ = le_word(size); }
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint16_t record_num() const { return le_hword(record_num_); }
|
|
|
|
void set_record_num(uint16_t num) { record_num_ = le_hword(num); }
|
2017-07-22 08:59:06 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint16_t section_type() const { return le_hword(section_type_); }
|
|
|
|
void set_section_type(uint16_t type) { section_type_ = le_hword(type); }
|
2017-07-22 08:59:06 +00:00
|
|
|
};
|
|
|
|
#pragma pack (pop)
|
|
|
|
|
|
|
|
// raw binary
|
|
|
|
fnd::MemoryBlob mBinaryBlob;
|
|
|
|
|
|
|
|
// variables
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t mSectionOffset;
|
|
|
|
uint32_t mRecordSize;
|
|
|
|
uint32_t mSectionSize;
|
|
|
|
uint16_t mRecordNum;
|
2017-07-22 08:59:06 +00:00
|
|
|
SectionType mSectionType;
|
|
|
|
|
|
|
|
// helpers
|
|
|
|
bool isEqual(const ETicketSectionHeader_V2& other) const;
|
|
|
|
void copyFrom(const ETicketSectionHeader_V2& other);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|