7 #ifndef _QI_TYPE_TYPEINTERFACE_HPP_
8 #define _QI_TYPE_TYPEINTERFACE_HPP_
13 #include <boost/preprocessor.hpp>
14 #include <boost/function.hpp>
15 #include <boost/type_traits/is_function.hpp>
16 #include <boost/mpl/if.hpp>
25 # pragma warning( push )
26 # pragma warning( disable: 4251 )
30 # pragma warning( disable: 4503 )
42 #define QI_TYPE_NOT_CONSTRUCTIBLE(T) \
43 namespace qi { namespace detail { \
44 template<> struct TypeManager<T>: public TypeManagerNotConstructible<T> {};}}
48 #define QI_NO_TYPE(T) namespace qi {template<> class TypeImpl<T>: public detail::ForbiddenInTypeSystem {};}
52 #define QI_TYPE_INTERFACE(T) \
53 namespace qi { namespace detail { \
54 template<> struct TypeManager<T>: public TypeManagerDefaultInterface<T> {};}}
58 #define QI_TYPE_CONCRETE(T) \
59 namespace qi { namespace detail { \
60 template<> struct TypeManager<T>: public TypeManagerDefaultStruct<T> {}; }}
64 #define QI_TYPE_REGISTER(t) \
65 QI_TYPE_REGISTER_CUSTOM(t, qi::TypeImpl<t>)
69 #define QI_TYPE_REGISTER_CUSTOM(type, typeimpl) \
70 static bool BOOST_PP_CAT(__qi_registration, __LINE__) = qi::registerType(typeid(type), new typeimpl)
73 class ListTypeInterface;
74 class StructTypeInterface;
81 virtual int64_t get(
void* value) = 0;
83 virtual unsigned int size() = 0;
85 virtual bool isSigned() = 0;
87 virtual void set(
void** storage,
int64_t value) = 0;
95 virtual double get(
void* value) = 0;
97 virtual unsigned int size() = 0;
99 virtual void set(
void** storage,
double value) = 0;
107 typedef boost::function<void(const RawString&)>
Deleter;
111 std::string getString(
void* storage);
116 void set(
void** storage,
const std::string& value);
118 virtual void set(
void** storage,
const char* ptr,
size_t sz) = 0;
130 virtual std::pair<char*, size_t>
get(
void* storage) = 0;
132 virtual void set(
void** storage,
const char* ptr,
size_t sz) = 0;
145 virtual PointerKind pointerKind() = 0;
151 virtual void setPointee(
void** storage,
void* pointer) = 0;
174 virtual void next(
void** storage) = 0;
176 virtual bool equals(
void* s1,
void* s2) = 0;
191 virtual size_t size(
void* storage) = 0;
198 virtual void pushBack(
void** storage,
void* valueStorage) = 0;
200 virtual void* element(
void* storage,
int index);
218 virtual size_t size(
void* storage) = 0;
225 virtual void insert(
void** storage,
void* keyStorage,
void* valueStorage) = 0;
232 virtual AnyReference element(
void** storage,
void* keyStorage,
bool autoInsert) = 0;
250 virtual std::vector<TypeInterface*> memberTypes() = 0;
252 virtual std::vector<void*>
get(
void* storage);
254 virtual void*
get(
void* storage,
unsigned int index) = 0;
256 virtual void set(
void** storage,
const std::vector<void*>&);
258 virtual void set(
void** storage,
unsigned int index,
void* valStorage) = 0;
261 virtual std::vector<std::string>
elementsName() {
return std::vector<std::string>();}
263 virtual std::string
className() {
return std::string(); }
284 virtual bool canDropFields(
void* storage,
const std::vector<std::string>& fieldNames) {
return false;}
287 virtual bool fillMissingFields(std::map<std::string, AnyValue>& fields,
const std::vector<std::string>& missing) {
return false;}
303 virtual void set(
void** storage,
AnyReference source) = 0;
336 QI_API TypeInterface*
makeMapType(TypeInterface* keyType, TypeInterface* ElementType);
339 QI_API TypeInterface*
makeTupleType(
const std::vector<TypeInterface*>& memberTypes,
const std::string &name = std::string(),
const std::vector<std::string>& elementNames = std::vector<std::string>());
346 #define QI_TEMPLATE_TYPE_DECLARE(n) \
349 template <typename T> \
350 class QITYPE_TEMPLATE_API TypeImpl<n<T> > : public TypeOfTemplateImpl<n, T> \
358 #define QI_TEMPLATE_TYPE_GET(typeInst, templateName) \
359 dynamic_cast< ::qi::TypeOfTemplate<templateName>*>(typeInst)
365 #define QI_TYPE_ENUM_REGISTER(Enum) \
367 template<> class TypeImpl<Enum>: public IntTypeInterfaceImpl<int> {}; \
370 #define QI_TYPE_STRUCT_DECLARE(name) \
371 __QI_TYPE_STRUCT_DECLARE(name, )
391 # pragma warning( pop )
393 # pragma warning( disable: 4503 )
396 #endif // _QITYPE_TYPEINTERFACE_HPP_
virtual std::string className()
Get the type name of the struct.
TypeInterface * makeTupleType(const std::vector< TypeInterface * > &memberTypes, const std::string &name=std::string(), const std::vector< std::string > &elementNames=std::vector< std::string >())
std::pair< RawString, Deleter > ManagedRawString
void pushBack(T &container, E *element)
TypeInterface * makeFloatType(int bytelen)
dll import/export and compiler message
TypeInterface * makeTypeOfKind(const qi::TypeKind &kind)
boost::function< void(const RawString &)> Deleter
TypeInterface * makeMapType(TypeInterface *keyType, TypeInterface *ElementType)
std::vector< AnyReference > AnyReferenceVector
std::pair< char *, size_t > RawString
virtual bool fillMissingFields(std::map< std::string, AnyValue > &fields, const std::vector< std::string > &missing)
Fill missing fields caused by conversion from a different struct. Return whether fill succeeded...
TypeInterface * makeVarArgsType(TypeInterface *elementType)
virtual std::vector< std::string > elementsName()
Get the names of the fields of the struct.
TypeInterface * makeIntType(bool issigned, int bytelen)
TypeInterface * makeListType(TypeInterface *elementType)
int64_t int64_t
Cross-platform signed integer of length 64 bits (8 bytes).