neptools

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

exports.hpp (2086B)


      1 #ifndef UUID_3260390C_7569_4E66_B6BA_CC5CC7E58F9A
      2 #define UUID_3260390C_7569_4E66_B6BA_CC5CC7E58F9A
      3 #pragma once
      4 
      5 #include "../item.hpp"
      6 #include "../../source.hpp"
      7 
      8 #include <libshit/fixed_string.hpp>
      9 #include <libshit/lua/auto_table.hpp>
     10 #include <boost/endian/arithmetic.hpp>
     11 
     12 namespace Neptools::Stcm
     13 {
     14 
     15   class HeaderItem;
     16   class ExportsItem final : public Item
     17   {
     18     LIBSHIT_DYNAMIC_OBJECT;
     19   public:
     20     enum LIBSHIT_LUAGEN() Type : uint32_t
     21     {
     22       CODE = 0,
     23       DATA = 1,
     24     };
     25 
     26     struct Entry
     27     {
     28       boost::endian::little_uint32_t type;
     29       Libshit::FixedString<0x20> name;
     30       boost::endian::little_uint32_t offset;
     31 
     32       void Validate(FilePosition file_size) const;
     33     };
     34     static_assert(sizeof(Entry) == 0x28);
     35 
     36     struct EntryType : public RefCounted, public Libshit::Lua::DynamicObject
     37     {
     38       Type type;
     39       Libshit::FixedString<0x20> name;
     40       Libshit::NotNull<LabelPtr> lbl;
     41 
     42       EntryType(Type type, const Libshit::FixedString<0x20>& name,
     43                 Libshit::NotNull<LabelPtr> lbl)
     44         : type{type}, name{std::move(name)}, lbl{std::move(lbl)} {}
     45 
     46       LIBSHIT_DYNAMIC_OBJECT;
     47     };
     48     using VectorEntry = Libshit::NotNull<Libshit::RefCountedPtr<EntryType>>;
     49 
     50     ExportsItem(Key k, Context& ctx) : Item{k, ctx} {}
     51     ExportsItem(Key k, Context& ctx, Source src, uint32_t export_count);
     52     ExportsItem(Key k, Context& ctx, Libshit::AT<std::vector<VectorEntry>> entries)
     53       : Item{k, ctx}, entries{std::move(entries.Get())} {}
     54     static ExportsItem& CreateAndInsert(ItemPointer ptr, uint32_t export_count);
     55 
     56     FilePosition GetSize() const noexcept override
     57     { return sizeof(Entry) * entries.size(); }
     58 
     59     LIBSHIT_LUAGEN(get: "::Libshit::Lua::GetSmartOwnedMember")
     60     std::vector<VectorEntry> entries;
     61 
     62     void Dispose() noexcept override;
     63 
     64   private:
     65     void Dump_(Sink& sink) const override;
     66     void Inspect_(std::ostream& os, unsigned indent) const override;
     67     void Parse_(Context& ctx, Source& src, uint32_t export_count);
     68 };
     69 
     70 }
     71 
     72 LIBSHIT_ENUM(Neptools::Stcm::ExportsItem::ExportsItem::Type);
     73 #endif