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 using Deleter = boost::function<void(const RawString&)>;
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 set(
void** storage,
AnyReference pointer) = 0;
153 virtual void setPointee(
void** storage,
void* pointer) = 0;
176 virtual void next(
void** storage) = 0;
178 virtual bool equals(
void* s1,
void* s2) = 0;
193 virtual size_t size(
void* storage) = 0;
200 virtual void pushBack(
void** storage,
void* valueStorage) = 0;
202 virtual void* element(
void* storage,
int index);
220 virtual size_t size(
void* storage) = 0;
227 virtual void insert(
void** storage,
void* keyStorage,
void* valueStorage) = 0;
234 virtual AnyReference element(
void** storage,
void* keyStorage,
bool autoInsert) = 0;
252 virtual std::vector<TypeInterface*> memberTypes() = 0;
254 virtual std::vector<void*>
get(
void* storage);
256 virtual void*
get(
void* storage,
unsigned int index) = 0;
258 virtual void set(
void** storage,
const std::vector<void*>&);
260 virtual void set(
void** storage,
unsigned int index,
void* valStorage) = 0;
263 virtual std::vector<std::string>
elementsName() {
return std::vector<std::string>();}
265 virtual std::string
className() {
return std::string(); }
286 virtual bool convertFrom(std::map<std::string, ::qi::AnyValue>& fields,
288 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
289 const std::map<std::string, ::qi::AnyReference>& dropfields)
294 virtual bool convertTo(std::map<std::string, ::qi::AnyValue>& fields,
295 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
296 const std::map<std::string, ::qi::AnyReference>& dropfields)
315 virtual void set(
void** storage,
AnyReference source) = 0;
348 QI_API TypeInterface*
makeMapType(TypeInterface* keyType, TypeInterface* ElementType);
351 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>());
358 #define QI_TEMPLATE_TYPE_DECLARE(n) \
361 template <typename T> \
362 class QITYPE_TEMPLATE_API TypeImpl<n<T> > : public TypeOfTemplateImpl<n, T> \
370 #define QI_TEMPLATE_TYPE_GET(typeInst, templateName) \
371 dynamic_cast< ::qi::TypeOfTemplate<templateName>*>(typeInst)
376 #define QI_TYPE_ENUM(Enum) \
380 class TypeImpl<Enum> : public IntTypeInterfaceImpl<int> \
390 #define QI_TYPE_ENUM_REGISTER(Enum) \
394 class TypeImpl<Enum> : public IntTypeInterfaceImpl<int> \
396 static const detail::QI_TYPE_ENUM_REGISTER_ BLAH; \
400 #define QI_TYPE_STRUCT_DECLARE(name) \
401 __QI_TYPE_STRUCT_DECLARE(name, )
421 # pragma warning( pop )
423 # pragma warning( disable: 4503 )
426 #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)
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...