X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=tools%2Fsetupgen%2Fstruct.h;fp=tools%2Fsetupgen%2Fstruct.h;h=adc95f8a7d36970ebaaabc6ccc7280bdf2b6bb18;hb=3b551a2caabdfebaac592b5fcbbeb6cbfe2fd43f;hp=0000000000000000000000000000000000000000;hpb=8420959665d2a2cfeed3e50dc0d706b9b7570414;p=libs%2Fgame.git diff --git a/tools/setupgen/struct.h b/tools/setupgen/struct.h new file mode 100644 index 0000000..adc95f8 --- /dev/null +++ b/tools/setupgen/struct.h @@ -0,0 +1,62 @@ +#ifndef STRUCT_H_ +#define STRUCT_H_ + +#include +#include +#include +#include + +class SetupGen; +class Type; + +class Struct +{ +public: + enum Kind + { + DATA, + ENTITY, + COMPONENT + }; + + struct Field + { + class Loader; + + std::string name; + const Type *type = nullptr; + std::string default_value; + }; + + class Loader; + +private: + std::string name; + Kind kind; + std::vector fields; + +public: + Struct(const std::string &, Kind); + + const std::vector &get_fields() const { return fields; } + + void define_type(Msp::IO::Base &) const; + void define_loader(Msp::IO::Base &) const; + void define_functions(Msp::IO::Base &) const; +}; + +class Struct::Loader: public Msp::DataFile::ObjectLoader +{ +private: + const SetupGen &gen; + +public: + Loader(Struct &, const SetupGen &); + +private: + void init_actions() override; + + void field(const Msp::DataFile::Symbol &, const Msp::DataFile::Symbol &); +}; + +#endif