__PIP_TYPENAME_DECLARE
This commit is contained in:
@@ -231,7 +231,36 @@ extern char ** environ;
|
||||
# if PIP_HAS_RTTI
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# else
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
template<typename T>
|
||||
inline const char * __pip_typename__() {
|
||||
static_assert(false, "this type must declare typename via __PIP_TYPENAME_DECLARE");
|
||||
return "?";
|
||||
}
|
||||
|
||||
# define __PIP_TYPENAME_DECLARE(T, NAME) \
|
||||
template<> \
|
||||
inline const char * __pip_typename__<T>() { \
|
||||
return NAME; \
|
||||
}
|
||||
|
||||
__PIP_TYPENAME_DECLARE(bool, "bool")
|
||||
__PIP_TYPENAME_DECLARE(char, "char")
|
||||
__PIP_TYPENAME_DECLARE(signed char, "signed char")
|
||||
__PIP_TYPENAME_DECLARE(unsigned char, "unsigned char")
|
||||
__PIP_TYPENAME_DECLARE(short, "short")
|
||||
__PIP_TYPENAME_DECLARE(unsigned short, "unsigned short")
|
||||
__PIP_TYPENAME_DECLARE(int, "int")
|
||||
__PIP_TYPENAME_DECLARE(unsigned int, "unsigned int")
|
||||
__PIP_TYPENAME_DECLARE(long, "long")
|
||||
__PIP_TYPENAME_DECLARE(unsigned long, "unsigned long")
|
||||
__PIP_TYPENAME_DECLARE(long long, "long long")
|
||||
__PIP_TYPENAME_DECLARE(unsigned long long, "unsigned long long")
|
||||
__PIP_TYPENAME_DECLARE(float, "float")
|
||||
__PIP_TYPENAME_DECLARE(double, "double")
|
||||
__PIP_TYPENAME_DECLARE(long double, "long double")
|
||||
__PIP_TYPENAME_DECLARE(void, "void")
|
||||
|
||||
# define __PIP_TYPENAME__(T) __pip_typename__<T>()
|
||||
# endif
|
||||
|
||||
# ifdef CC_GCC
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
enum CoordinateSystem {
|
||||
Unknown = 0 /** \~english Unknown coordinate system \~russian Неизвестная система координат */,
|
||||
Geodetic /** \~english Geodetic latitude, longitude and height above the ellipsoid \~russian Геодезическая широта, долгота и высота
|
||||
над эллипсоидом */
|
||||
над эллипсоидом */
|
||||
,
|
||||
Geocentric /** \~english Geocentric latitude, longitude and radius \~russian Геоцентрическая широта, долгота и радиус */,
|
||||
Cartesian /** \~english Earth-centered Earth-fixed Cartesian coordinates \~russian Декартовы координаты ECEF */,
|
||||
@@ -381,4 +381,9 @@ inline PIGeoPosition operator*(const PIGeoPosition & left, const int & scale) {
|
||||
return operator*(double(scale), left);
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIGeoPosition, "PIGeoPosition")
|
||||
#endif
|
||||
|
||||
#endif // PIGEOPOSITION_H
|
||||
|
||||
@@ -210,4 +210,12 @@ typedef PILine<float> PILinef;
|
||||
//! \~russian Псевдоним отрезка с координатами типа `double`.
|
||||
typedef PILine<double> PILined;
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PILined, "PILined")
|
||||
__PIP_TYPENAME_DECLARE(PILinei, "PILinei")
|
||||
__PIP_TYPENAME_DECLARE(PILinef, "PILinef")
|
||||
__PIP_TYPENAME_DECLARE(PILineu, "PILineu")
|
||||
#endif
|
||||
|
||||
#endif // PILINE_H
|
||||
|
||||
@@ -186,4 +186,11 @@ inline bool PIMathFloatNullCompare(const T v) {
|
||||
return (abs(v) < float(1E-200));
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(complexf, "complexf")
|
||||
__PIP_TYPENAME_DECLARE(complexd, "complexd")
|
||||
__PIP_TYPENAME_DECLARE(complexld, "complexld")
|
||||
#endif
|
||||
|
||||
#endif // PIMATHCOMPLEX_H
|
||||
|
||||
@@ -1652,6 +1652,12 @@ PIMathMatrix<complex<T>> hermitian(const PIMathMatrix<complex<T>> & m) {
|
||||
return ret.transposed();
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIMathMatrixd, "PIMathMatrixd")
|
||||
__PIP_TYPENAME_DECLARE(PIMathMatrixi, "PIMathMatrixi")
|
||||
#endif
|
||||
|
||||
#undef PIMM_FOR
|
||||
#undef PIMM_FOR_A
|
||||
#undef PIMM_FOR_C
|
||||
|
||||
@@ -909,4 +909,10 @@ typedef PIMathVector<int> PIMathVectori;
|
||||
//! \~russian Динамический вектор из \c double.
|
||||
typedef PIMathVector<double> PIMathVectord;
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIMathVectord, "PIMathVectord")
|
||||
__PIP_TYPENAME_DECLARE(PIMathVectori, "PIMathVectori")
|
||||
#endif
|
||||
|
||||
#endif // PIMATHVECTOR_H
|
||||
|
||||
@@ -286,4 +286,12 @@ typedef PIPoint<float> PIPointf;
|
||||
//! \~russian Псевдоним точки с координатами типа `double`.
|
||||
typedef PIPoint<double> PIPointd;
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIPointd, "PIPointd")
|
||||
__PIP_TYPENAME_DECLARE(PIPointi, "PIPointi")
|
||||
__PIP_TYPENAME_DECLARE(PIPointf, "PIPointf")
|
||||
__PIP_TYPENAME_DECLARE(PIPointu, "PIPointu")
|
||||
#endif
|
||||
|
||||
#endif // PIPOINT_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! \~russian Класс прямоугольника для 2D геометрии
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Rect class for 2D geometry
|
||||
Rect class for 2D geometry
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -444,4 +444,12 @@ typedef PIRect<float> PIRectf;
|
||||
//! \~russian Псевдоним прямоугольника с координатами типа `double`.
|
||||
typedef PIRect<double> PIRectd;
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIRectd, "PIRectd")
|
||||
__PIP_TYPENAME_DECLARE(PIRecti, "PIRecti")
|
||||
__PIP_TYPENAME_DECLARE(PIRectf, "PIRectf")
|
||||
__PIP_TYPENAME_DECLARE(PIRectu, "PIRectu")
|
||||
#endif
|
||||
|
||||
#endif // PIRECT_H
|
||||
|
||||
@@ -270,4 +270,9 @@ inline bool operator<=(ushort v, const PIChar & c) {
|
||||
return (PIChar(v) <= c);
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIChar, "PIChar")
|
||||
#endif
|
||||
|
||||
#endif // PICHAR_H
|
||||
|
||||
@@ -2052,4 +2052,8 @@ inline PIString piStringify(const T & v) {
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIString, "PIString")
|
||||
#endif
|
||||
|
||||
#endif // PISTRING_H
|
||||
|
||||
@@ -216,4 +216,9 @@ inline PICout operator<<(PICout s, const PIStringList & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
#if !PIP_HAS_RTTI
|
||||
__PIP_TYPENAME_DECLARE(PIStringList, "PIStringList")
|
||||
#endif
|
||||
|
||||
#endif // PISTRINGLIST_H
|
||||
|
||||
@@ -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