00001 #ifndef __TYPEBUILDER_H__ 00002 #define __TYPEBUILDER_H__ 00003 00004 #include <string> 00005 #include <list> 00006 00007 #include "typemodel.hh" 00008 00009 namespace Typelib 00010 { 00011 class Registry; 00012 00014 class TypeBuilder 00015 { 00016 std::string m_basename; 00017 Type* m_type; 00018 00019 struct Modifier 00020 { 00021 Type::Category category; 00022 int size; // Size of an array, deference count on multi-dim pointers 00023 }; 00024 typedef std::list<Modifier> ModifierList; 00025 typedef std::pair<const Type*, ModifierList> TypeSpec; 00026 00027 static TypeSpec parse(const Registry& registry, const std::string& full_name); 00028 static const Type& build(Registry& registry, const TypeSpec& spec, int size); 00029 00030 Registry& m_registry; 00031 00032 public: 00041 TypeBuilder(Registry& registry, const std::list<std::string>& base); 00042 00047 TypeBuilder(Registry& registry, const Type* base_type); 00048 00050 void addPointer(int level); 00053 void addArrayMajor(int size); 00056 void addArrayMinor(int size); 00058 void setSize(int size); 00059 00061 const Type& getType() const; 00062 00065 static const Type* build(Registry& registry, const std::string& full_name, int size = 0); 00067 static std::string getBaseTypename(const std::string& full_name); 00070 static const Type* getBaseType(const Registry& registry, const std::string& full_name); 00071 }; 00072 }; 00073 00074 #endif 00075