neptools

Modding tools to Neptunia games
git clone https://git.neptards.moe/neptards/neptools.git
Log | Files | Refs | Submodules | README | LICENSE

data.hpp (1388B)


      1 #ifndef UUID_CB40AD6D_5157_4C96_A9A9_371A9F215955
      2 #define UUID_CB40AD6D_5157_4C96_A9A9_371A9F215955
      3 #pragma once
      4 
      5 #include "../item.hpp"
      6 #include "../../factory.hpp"
      7 #include <boost/endian/arithmetic.hpp>
      8 
      9 namespace Neptools::Stcm
     10 {
     11 
     12   class DataItem final : public ItemWithChildren
     13   {
     14     LIBSHIT_DYNAMIC_OBJECT;
     15   public:
     16     struct Header
     17     {
     18       boost::endian::little_uint32_t type;
     19       boost::endian::little_uint32_t offset_unit;
     20       boost::endian::little_uint32_t field_8;
     21       boost::endian::little_uint32_t length;
     22 
     23       void Validate(FilePosition chunk_size) const;
     24     };
     25     static_assert(sizeof(Header) == 0x10);
     26 
     27     DataItem(Key k, Context& ctx, uint32_t type, uint32_t offset_unit,
     28              uint32_t field_8)
     29       : ItemWithChildren{k, ctx}, type{type}, offset_unit{offset_unit},
     30         field_8{field_8} {}
     31     LIBSHIT_NOLUA
     32     DataItem(Key k, Context& ctx, const Header& hdr, size_t chunk_size);
     33     static DataItem& CreateAndInsert(ItemPointer ptr);
     34 
     35     FilePosition GetSize() const noexcept override;
     36     void Fixup() override;
     37 
     38     uint32_t type, offset_unit, field_8;
     39 
     40   private:
     41     void Dump_(Sink& sink) const override;
     42     void Inspect_(std::ostream& os, unsigned indent) const override;
     43   };
     44 
     45   struct DataFactory : BaseFactory<bool (*)(DataItem& it)>
     46   {
     47     using BaseFactory::BaseFactory;
     48     static void Check(DataItem& it);
     49   };
     50 
     51 }
     52 #endif