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_ATTR_UNUSED \
71 = qi::registerType(qi::typeId<type>(), new typeimpl)
74 class ListTypeInterface;
75 class StructTypeInterface;
82 virtual int64_t get(
void* value) = 0;
84 virtual unsigned int size() = 0;
86 virtual bool isSigned() = 0;
88 virtual void set(
void** storage,
int64_t value) = 0;
96 virtual double get(
void* value) = 0;
98 virtual unsigned int size() = 0;
100 virtual void set(
void** storage,
double value) = 0;
108 using Deleter = boost::function<void(const RawString&)>;
112 std::string getString(
void* storage);
117 void set(
void** storage,
const std::string& value);
119 virtual void set(
void** storage,
const char* ptr,
size_t sz) = 0;
131 virtual std::pair<char*, size_t>
get(
void* storage) = 0;
133 virtual void set(
void** storage,
const char* ptr,
size_t sz) = 0;
146 virtual PointerKind pointerKind() = 0;
152 virtual void set(
void** storage,
AnyReference pointer) = 0;
154 virtual void setPointee(
void** storage,
void* pointer) = 0;
177 virtual void next(
void** storage) = 0;
179 virtual bool equals(
void* s1,
void* s2) = 0;
194 virtual size_t size(
void* storage) = 0;
201 virtual void pushBack(
void** storage,
void* valueStorage) = 0;
203 virtual void* element(
void* storage,
int index);
221 virtual size_t size(
void* storage) = 0;
228 virtual void insert(
void** storage,
void* keyStorage,
void* valueStorage) = 0;
235 virtual AnyReference element(
void** storage,
void* keyStorage,
bool autoInsert) = 0;
253 virtual std::vector<TypeInterface*> memberTypes() = 0;
255 virtual std::vector<void*>
get(
void* storage);
257 virtual void*
get(
void* storage,
unsigned int index) = 0;
259 virtual void set(
void** storage,
const std::vector<void*>&);
261 virtual void set(
void** storage,
unsigned int index,
void* valStorage) = 0;
264 virtual std::vector<std::string>
elementsName() {
return std::vector<std::string>();}
266 virtual std::string
className() {
return std::string(); }
287 virtual bool convertFrom(std::map<std::string, ::qi::AnyValue>& fields,
289 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
290 const std::map<std::string, ::qi::AnyReference>& dropfields)
295 virtual bool convertTo(std::map<std::string, ::qi::AnyValue>& fields,
296 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
297 const std::map<std::string, ::qi::AnyReference>& dropfields)
316 virtual void set(
void** storage,
AnyReference source) = 0;
340 virtual bool hasValue(
void* storage) = 0;
344 virtual void set(
void** storage,
void* valueStorage) = 0;
346 virtual void reset(
void** storage) = 0;
369 QI_API TypeInterface*
makeMapType(TypeInterface* keyType, TypeInterface* ElementType);
372 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>());
382 #define QI_TEMPLATE_TYPE_DECLARE(n) \
385 template <typename T> \
386 class QITYPE_TEMPLATE_API TypeImpl<n<T> > : public TypeOfTemplateImpl<n, T> \
394 #define QI_TEMPLATE_TYPE_GET(typeInst, templateName) \
395 dynamic_cast< ::qi::TypeOfTemplate<templateName>*>(typeInst)
400 #define QI_TYPE_ENUM(Enum) \
404 class TypeImpl<Enum> : public IntTypeInterfaceImpl<int> \
414 #define QI_TYPE_ENUM_REGISTER(Enum) \
418 class TypeImpl<Enum> : public IntTypeInterfaceImpl<int> \
420 static const detail::QI_TYPE_ENUM_REGISTER_ BLAH; \
424 #define QI_TYPE_STRUCT_DECLARE(name) \
425 __QI_TYPE_STRUCT_DECLARE(name, )
446 # pragma warning( pop )
448 # pragma warning( disable: 4503 )
451 #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 >())
#define QI_TYPE_ENUM(Enum)
void pushBack(T &container, E *element)
TypeInterface * makeFloatType(int bytelen)
boost::function< void(const RawString &)> Deleter
dll import/export and compiler message
TypeInterface * makeTypeOfKind(const qi::TypeKind &kind)
std::pair< RawString, Deleter > ManagedRawString
TypeInterface * makeMapType(TypeInterface *keyType, TypeInterface *ElementType)
std::vector< AnyReference > AnyReferenceVector
std::pair< char *, size_t > RawString
TypeInterface * makeVarArgsType(TypeInterface *elementType)
TypeInterface * makeOptionalType(TypeInterface *valueType)
virtual std::vector< std::string > elementsName()
Get the names of the fields of the struct.
TypeInterface * makeIntType(bool issigned, int bytelen)
struct QI_API_DEPRECATED_MSG(Use 'QI_TYPE_ENUM'instead) QI_TYPE_ENUM_REGISTER_
TypeInterface * makeListType(TypeInterface *elementType)
virtual bool convertTo(std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string,::qi::AnyReference > &dropfields)
Fill missing fields caused by conversion to a different struct. Return whether fill succeeded...