neptools

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

dumpable.hpp (1738B)


      1 #ifndef UUID_C9446864_0020_4D2F_8E96_CBC6ADCCA3BE
      2 #define UUID_C9446864_0020_4D2F_8E96_CBC6ADCCA3BE
      3 #pragma once
      4 
      5 #include "utils.hpp"
      6 
      7 #include <libshit/lua/dynamic_object.hpp>
      8 #include <libshit/lua/type_traits.hpp>
      9 #include <libshit/meta.hpp>
     10 #include <libshit/shared_ptr.hpp>
     11 
     12 #include <boost/filesystem/path.hpp>
     13 
     14 namespace Neptools
     15 {
     16 
     17   class TxtSerializable;
     18   class Sink;
     19 
     20   class Dumpable : public Libshit::Lua::DynamicObject
     21   {
     22     LIBSHIT_LUA_CLASS;
     23   public:
     24     Dumpable() = default;
     25     Dumpable(const Dumpable&) = delete;
     26     void operator=(const Dumpable&) = delete;
     27     virtual ~Dumpable() = default;
     28 
     29     virtual void Fixup() {};
     30     virtual FilePosition GetSize() const = 0;
     31 
     32     LIBSHIT_NOLUA
     33     virtual Libshit::NotNullSharedPtr<TxtSerializable>
     34     GetDefaultTxtSerializable(const Libshit::NotNullSharedPtr<Dumpable>& thiz);
     35 
     36     void Dump(Sink& os) const { return Dump_(os); }
     37     LIBSHIT_NOLUA
     38     void Dump(Sink&& os) const { return Dump_(os); }
     39     void Dump(const boost::filesystem::path& path) const;
     40 
     41     LIBSHIT_NOLUA
     42     void Inspect(std::ostream& os, unsigned indent = 0) const
     43     { return Inspect_(os, indent); }
     44     LIBSHIT_NOLUA
     45     void Inspect(std::ostream&& os, unsigned indent = 0) const
     46     { return Inspect_(os, indent); }
     47     void Inspect(const boost::filesystem::path& path) const;
     48     std::string Inspect() const;
     49 
     50   protected:
     51     static std::ostream& Indent(std::ostream& os, unsigned indent);
     52 
     53   private:
     54     virtual void Dump_(Sink& sink) const = 0;
     55     virtual void Inspect_(std::ostream& os, unsigned indent) const = 0;
     56   };
     57 
     58   std::ostream& operator<<(std::ostream& os, const Dumpable& dmp);
     59 
     60   inline Libshit::Lua::DynamicObject& GetDynamicObject(Dumpable& d) { return d; }
     61 
     62 }
     63 #endif