__PIP_TYPENAME_DECLARE
This commit is contained in:
@@ -309,4 +309,9 @@ private:
|
||||
//! \~russian Оператор вывода в \a PICout
|
||||
PIP_EXPORT PICout operator<<(PICout s, const PIBitArray & ba);
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIBitArray, "PIBitArray")
|
||||
#endif
|
||||
|
||||
#endif // PIBITARRAY_H
|
||||
|
||||
@@ -1362,4 +1362,8 @@ T piDeserialize(const PIByteArray & data) {
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIByteArray, "PIByteArray")
|
||||
#endif
|
||||
|
||||
#endif // PIBYTEARRAY_H
|
||||
|
||||
@@ -404,4 +404,10 @@ inline bool operator>=(const PIDateTime & t0, const PIDateTime & t1) {
|
||||
PIP_EXPORT PICout operator<<(PICout s, const PIDateTime & v);
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PITime, "PITime")
|
||||
__PIP_TYPENAME_DECLARE(PIDate, "PIDate")
|
||||
__PIP_TYPENAME_DECLARE(PIDateTime, "PIDateTime")
|
||||
#endif
|
||||
|
||||
#endif // PIDATETIME_H
|
||||
|
||||
@@ -141,4 +141,8 @@ inline PICout operator<<(PICout s, const PINetworkAddress & v) {
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PINetworkAddress, "PINetworkAddress")
|
||||
#endif
|
||||
|
||||
#endif // PINETWORKADDRESS_H
|
||||
|
||||
@@ -520,4 +520,9 @@ private:
|
||||
PISystemTime t_st;
|
||||
};
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PISystemTime, "PISystemTime")
|
||||
#endif
|
||||
|
||||
#endif // PITIME_H
|
||||
|
||||
@@ -27,11 +27,6 @@
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
#include <typeinfo>
|
||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
# include "pivariant.h"
|
||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
|
||||
|
||||
class __VariantFunctionsBase__ {
|
||||
public:
|
||||
@@ -52,21 +47,10 @@ public:
|
||||
static __VariantFunctions__<T> ret;
|
||||
return &ret;
|
||||
}
|
||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
PIString typeName() const final {
|
||||
static PIString ret(PIVariant::fromValue<T>(T()).typeName());
|
||||
static PIString ret(__PIP_TYPENAME__(T));
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
PIString typeName() const final {
|
||||
# if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static PIString ret(typeid(T).name());
|
||||
# else
|
||||
static PIString ret("unknown");
|
||||
# endif
|
||||
return ret;
|
||||
}
|
||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
uint hash() const final {
|
||||
static uint ret = typeName().hash();
|
||||
return ret;
|
||||
@@ -182,27 +166,35 @@ private:
|
||||
//! \~\brief
|
||||
//! \~english Registers a readable type name for %PIVariantSimple.
|
||||
//! \~russian Регистрирует читаемое имя типа для %PIVariantSimple.
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { ptr = (void *)(new Type(*(const Type *)value)); } \
|
||||
void newNullT(void *& ptr) final { ptr = (void *)(new Type()); } \
|
||||
void assignT(void *& ptr, const void * value) final { *(Type *)ptr = *(const Type *)value; } \
|
||||
void deleteT(void *& ptr) final { delete (Type *)(ptr); } \
|
||||
};
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { \
|
||||
ptr = (void *)(new Type(*(const Type *)value)); \
|
||||
} \
|
||||
void newNullT(void *& ptr) final { \
|
||||
ptr = (void *)(new Type()); \
|
||||
} \
|
||||
void assignT(void *& ptr, const void * value) final { \
|
||||
*(Type *)ptr = *(const Type *)value; \
|
||||
} \
|
||||
void deleteT(void *& ptr) final { \
|
||||
delete (Type *)(ptr); \
|
||||
} \
|
||||
};
|
||||
|
||||
REGISTER_PIVARIANTSIMPLE(std::function<void(void *)>)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user