X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=tools%2Fsetupgen%2Ftype.h;fp=tools%2Fsetupgen%2Ftype.h;h=3338fd94a12c8027121dcf3ad50088f80e71d97c;hb=3b551a2caabdfebaac592b5fcbbeb6cbfe2fd43f;hp=0000000000000000000000000000000000000000;hpb=8420959665d2a2cfeed3e50dc0d706b9b7570414;p=libs%2Fgame.git diff --git a/tools/setupgen/type.h b/tools/setupgen/type.h new file mode 100644 index 0000000..3338fd9 --- /dev/null +++ b/tools/setupgen/type.h @@ -0,0 +1,57 @@ +#ifndef TYPE_H_ +#define TYPE_H_ + +#include + +class Enum; +class Struct; + +class Type +{ +public: + enum Kind + { + VALUE, + AGGREGATE, + POINTER, + DYN_ARRAY, + STRUCT, + ENUM + }; + +private: + std::string name; + Kind kind = VALUE; + std::string cpp_type; + std::string header; + const Type *element_type = nullptr; + unsigned element_count = 0; + std::string load_type; + std::string conversion; + const Struct *struct_def = nullptr; + const Enum *enum_def = nullptr; + +public: + Type(const std::string &, Kind); + + Type &set_cpp_type(const std::string &, const std::string & = std::string()); + Type &set_elements(const Type &, unsigned = 0); + Type &set_struct(const Struct &); + Type &set_enum(const Enum &); + Type &set_load(const std::string &, const std::string & = std::string()); + + const std::string &get_name() const { return name; } + Kind get_kind() const { return kind; } + const std::string &get_cpp_type() const { return cpp_type; } + const std::string &get_header() const { return header; } + const Type &get_element_type() const; + const std::string &get_conversion() const { return conversion; } + const Struct &get_struct() const; + const Enum &get_enum() const; + + bool needs_loader_function() const; + std::string create_loader_params(bool) const; + std::string create_loader_statement() const; +}; + +#endif