git-svn-id: svn://db.shs.com.ru/pip@189 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -30,21 +30,96 @@
|
||||
#include "pitime.h"
|
||||
#include "pimathbase.h"
|
||||
|
||||
#define __PIVARIANT_UNION_SIZE__ 32
|
||||
|
||||
#define _vcomplexd (*((complexd*)_vraw))
|
||||
#define _vcomplexld (*((complexld*)_vraw))
|
||||
#define _vtime (*((PITime*)_vraw))
|
||||
#define _vdate (*((PIDate*)_vraw))
|
||||
#define _vdatetime (*((PIDateTime*)_vraw))
|
||||
#define _vsystime (*((PISystemTime*)_vraw))
|
||||
template<typename T>
|
||||
class __PIVariantFunctions__ {
|
||||
public:
|
||||
static PIString typeNameHelper() {return PIStringAscii("");}
|
||||
|
||||
static bool isSimpleHelper() {return false;}
|
||||
template<typename C> static PIByteArray castHelper(PIByteArray ba) {return PIByteArray();}
|
||||
template<typename C> static C castVariant(const T & v) {return C();}
|
||||
};
|
||||
|
||||
struct __PIVariantInfo__ {
|
||||
__PIVariantInfo__() {
|
||||
simple = false;
|
||||
}
|
||||
typedef PIByteArray(*castHelperFunc)(PIByteArray);
|
||||
PIMap<PIString, castHelperFunc> cast;
|
||||
PIString typeName;
|
||||
bool simple;
|
||||
};
|
||||
|
||||
class __PIVariantInfoStorage__ {
|
||||
public:
|
||||
__PIVariantInfoStorage__() {if (!map) map = new PIMap<PIString, __PIVariantInfo__ * >();}
|
||||
static __PIVariantInfoStorage__ * get() {static __PIVariantInfoStorage__ * r = new __PIVariantInfoStorage__(); return r;}
|
||||
static PIMap<PIString, __PIVariantInfo__ * > * map;
|
||||
};
|
||||
|
||||
|
||||
#define REGISTER_VARIANT_H(classname) \
|
||||
template<> inline PIString __PIVariantFunctions__< classname >::typeNameHelper() {static PIString tn = PIStringAscii(#classname); return tn;}
|
||||
|
||||
#define REGISTER_VARIANT_CPP(classname) \
|
||||
template <typename T> \
|
||||
class __##classname##_PIVariantInitializer__ { \
|
||||
public: \
|
||||
__##classname##_PIVariantInitializer__(const PIString & name) { \
|
||||
if (__PIVariantInfoStorage__::get()->map->contains(name)) \
|
||||
return; \
|
||||
__PIVariantInfo__ * vi = new __PIVariantInfo__(); \
|
||||
vi->typeName = name; \
|
||||
(*(__PIVariantInfoStorage__::get()->map))[name] = vi; \
|
||||
} \
|
||||
};
|
||||
|
||||
#define INIT_VARIANT(classname) \
|
||||
__##classname##_PIVariantInitializer__< classname > __##classname##_pivariant_initializer__(#classname);
|
||||
|
||||
#define REGISTER_VARIANT(classname) \
|
||||
REGISTER_VARIANT_H(classname) \
|
||||
REGISTER_VARIANT_CPP(classname) \
|
||||
static INIT_VARIANT(classname)
|
||||
|
||||
|
||||
#define REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||
template<> template<> inline \
|
||||
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v);
|
||||
|
||||
#define REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) \
|
||||
template<> template<> inline \
|
||||
PIByteArray __PIVariantFunctions__<classname_from>::castHelper<classname_to>(PIByteArray v) { \
|
||||
classname_from f; v >> f; \
|
||||
classname_to t = __PIVariantFunctions__<classname_from>::castVariant<classname_to>(f); \
|
||||
PIByteArray ret; ret << t; \
|
||||
return ret;} \
|
||||
template <typename T, typename C> \
|
||||
class __##classname_from##_##classname_to##_PIVariantCastInitializer__ { \
|
||||
public: \
|
||||
__##classname_from##_##classname_to##_PIVariantCastInitializer__(const PIString & name, const PIString & cname) { \
|
||||
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get()->map->value(name, 0)); \
|
||||
if (!vi) { \
|
||||
piCout << "Warning! Using REGISTER_VARIANT_CAST("#classname_from", "#classname_to") before REGISTER_VARIANT("#classname_from"), ignore."; \
|
||||
return; \
|
||||
} \
|
||||
vi->cast[cname] = __PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
|
||||
} \
|
||||
}; \
|
||||
static __##classname_from##_##classname_to##_PIVariantCastInitializer__< classname_from, classname_to > __##classname_from##_##classname_to##_pivariant_cast_initializer__(#classname_from, #classname_to); \
|
||||
template<> template<> \
|
||||
classname_to __PIVariantFunctions__<classname_from>::castVariant<classname_to>(const classname_from & v)
|
||||
|
||||
#define REGISTER_VARIANT_CAST(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_H(classname_from, classname_to) \
|
||||
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to)
|
||||
|
||||
|
||||
#define REGISTER_VARIANT_CAST_SIMPLE(classname_from, classname_to) REGISTER_VARIANT_CAST(classname_from, classname_to) {return classname_to(v);}
|
||||
#define REGISTER_VARIANT_CAST_SIMPLE_H(classname_from, classname_to) REGISTER_VARIANT_CAST_H(classname_from, classname_to)
|
||||
#define REGISTER_VARIANT_CAST_SIMPLE_CPP(classname_from, classname_to) REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) {return classname_to(v);}
|
||||
|
||||
#define _vvcomplexd(v) (*((complexd*)v._vraw))
|
||||
#define _vvcomplexld(v) (*((complexld*)v._vraw))
|
||||
#define _vvtime(v) (*((PITime*)v._vraw))
|
||||
#define _vvdate(v) (*((PIDate*)v._vraw))
|
||||
#define _vvdatetime(v) (*((PIDateTime*)v._vraw))
|
||||
#define _vvsystime(v) (*((PISystemTime*)v._vraw))
|
||||
|
||||
class PIP_EXPORT PIVariant {
|
||||
friend PICout operator <<(PICout s, const PIVariant & v);
|
||||
@@ -60,8 +135,6 @@ public:
|
||||
UShort /** ushort */ ,
|
||||
Int /** int */ ,
|
||||
UInt /** uint */ ,
|
||||
Long /** long */ ,
|
||||
ULong /** ulong */ ,
|
||||
LLong /** llong */ ,
|
||||
ULLong /** ullong */ ,
|
||||
Float /** float */ ,
|
||||
@@ -84,155 +157,143 @@ public:
|
||||
PIVariant();
|
||||
|
||||
//! Constructs variant from string
|
||||
PIVariant(const char * v) {setValue(PIString(v));}
|
||||
PIVariant(const char * v) {initType(PIString(v));}
|
||||
|
||||
//! Constructs variant from boolean
|
||||
PIVariant(const bool v) {setValue(v);}
|
||||
PIVariant(const bool v) {initType(v);}
|
||||
|
||||
//! Constructs variant from char
|
||||
PIVariant(const char v) {setValue(v);}
|
||||
PIVariant(const char v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const uchar v) {setValue(v);}
|
||||
PIVariant(const uchar v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const short v) {setValue(v);}
|
||||
PIVariant(const short v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const ushort v) {setValue(v);}
|
||||
PIVariant(const ushort v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const int & v) {setValue(v);}
|
||||
PIVariant(const int & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const uint & v) {setValue(v);}
|
||||
PIVariant(const uint & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const long & v) {setValue(v);}
|
||||
PIVariant(const llong & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const ulong & v) {setValue(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const llong & v) {setValue(v);}
|
||||
|
||||
//! Constructs variant from integer
|
||||
PIVariant(const ullong & v) {setValue(v);}
|
||||
PIVariant(const ullong & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from float
|
||||
PIVariant(const float & v) {setValue(v);}
|
||||
PIVariant(const float & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from double
|
||||
PIVariant(const double & v) {setValue(v);}
|
||||
PIVariant(const double & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from long double
|
||||
PIVariant(const ldouble & v) {setValue(v);}
|
||||
PIVariant(const ldouble & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from complex
|
||||
PIVariant(const complexd & v) {setValue(v);}
|
||||
PIVariant(const complexd & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from complex
|
||||
PIVariant(const complexld & v) {setValue(v);}
|
||||
PIVariant(const complexld & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from bit array
|
||||
PIVariant(const PIBitArray & v) {setValue(v);}
|
||||
PIVariant(const PIBitArray & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from byte array
|
||||
PIVariant(const PIByteArray & v) {setValue(v);}
|
||||
PIVariant(const PIByteArray & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from string
|
||||
PIVariant(const PIString & v) {setValue(v);}
|
||||
PIVariant(const PIString & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from strings list
|
||||
PIVariant(const PIStringList & v) {setValue(v);}
|
||||
PIVariant(const PIStringList & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from time
|
||||
PIVariant(const PITime & v) {setValue(v);}
|
||||
PIVariant(const PITime & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from date
|
||||
PIVariant(const PIDate & v) {setValue(v);}
|
||||
PIVariant(const PIDate & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from date and time
|
||||
PIVariant(const PIDateTime & v) {setValue(v);}
|
||||
PIVariant(const PIDateTime & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from system time
|
||||
PIVariant(const PISystemTime & v) {setValue(v);}
|
||||
PIVariant(const PISystemTime & v) {initType(v);}
|
||||
|
||||
|
||||
//! Set variant content and type to string
|
||||
void setValue(const char * v) {setValue(PIString(v));}
|
||||
|
||||
//! Set variant content and type to boolean
|
||||
void setValue(const bool v) {type_ = PIVariant::Bool; _vint = (v ? 1 : 0);}
|
||||
void setValue(const bool v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to char
|
||||
void setValue(const char v) {type_ = PIVariant::Char; _vint = v;}
|
||||
void setValue(const char v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const uchar v) {type_ = PIVariant::UChar; _vint = v;}
|
||||
void setValue(const uchar v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const short v) {type_ = PIVariant::Short; _vint = v;}
|
||||
void setValue(const short v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const ushort v) {type_ = PIVariant::UShort; _vint = v;}
|
||||
void setValue(const ushort v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const int & v) {type_ = PIVariant::Int; _vint = v;}
|
||||
void setValue(const int & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const uint & v) {type_ = PIVariant::UInt; _vint = v;}
|
||||
void setValue(const uint & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const long & v) {type_ = PIVariant::Long; _vint = v;}
|
||||
void setValue(const llong & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const ulong & v) {type_ = PIVariant::ULong; _vint = v;}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const llong & v) {type_ = PIVariant::LLong; _vllong = v;}
|
||||
|
||||
//! Set variant content and type to integer
|
||||
void setValue(const ullong & v) {type_ = PIVariant::ULLong; _vllong = v;}
|
||||
void setValue(const ullong & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to float
|
||||
void setValue(const float & v) {type_ = PIVariant::Float; _vfloat = v;}
|
||||
void setValue(const float & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to double
|
||||
void setValue(const double & v) {type_ = PIVariant::Double; _vdouble = v;}
|
||||
void setValue(const double & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to long double
|
||||
void setValue(const ldouble & v) {type_ = PIVariant::LDouble; _vldouble = v;}
|
||||
void setValue(const ldouble & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to complex
|
||||
void setValue(const complexd & v) {type_ = PIVariant::Complexd; _vcomplexd = v;}
|
||||
void setValue(const complexd & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to complex
|
||||
void setValue(const complexld & v) {type_ = PIVariant::Complexld; _vcomplexld = v;}
|
||||
void setValue(const complexld & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to bit array
|
||||
void setValue(const PIBitArray & v) {type_ = PIVariant::BitArray; _vbitarray = v;}
|
||||
void setValue(const PIBitArray & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to byte array
|
||||
void setValue(const PIByteArray & v) {type_ = PIVariant::ByteArray; _vbytearray = v;}
|
||||
void setValue(const PIByteArray & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to string
|
||||
void setValue(const PIString & v) {type_ = PIVariant::String; _vstring = v;}
|
||||
void setValue(const PIString & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to strings list
|
||||
void setValue(const PIStringList & v) {type_ = PIVariant::StringList; _vstringlist = v;}
|
||||
void setValue(const PIStringList & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to time
|
||||
void setValue(const PITime & v) {type_ = PIVariant::Time; _vtime = v;}
|
||||
void setValue(const PITime & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to date
|
||||
void setValue(const PIDate & v) {type_ = PIVariant::Date; _vdate = v;}
|
||||
void setValue(const PIDate & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to date and time
|
||||
void setValue(const PIDateTime & v) {type_ = PIVariant::DateTime; _vdatetime = v;}
|
||||
void setValue(const PIDateTime & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to system time
|
||||
void setValue(const PISystemTime & v) {type_ = PIVariant::SystemTime; _vsystime = v;}
|
||||
void setValue(const PISystemTime & v) {initType(v);}
|
||||
|
||||
|
||||
bool toBool() const;
|
||||
@@ -257,7 +318,7 @@ public:
|
||||
* \details In case of known types this function equivalent \a to<Type> function. \n
|
||||
* Otherwise returns content as type T. */
|
||||
template<typename T>
|
||||
T toValue() const {if (_vcustom.size() != sizeof(T)) return T(); return *((T*)_vcustom.data());}
|
||||
T value() const {return getAsValue<T>(*this);}
|
||||
/*
|
||||
operator bool() const {return toBool();}
|
||||
operator char() const {return toInt();}
|
||||
@@ -305,10 +366,6 @@ public:
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const uint & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const long & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const ulong & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const llong & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const ullong & v) {setValue(v); return *this;}
|
||||
@@ -347,21 +404,41 @@ public:
|
||||
|
||||
|
||||
//! Returns type of variant content
|
||||
PIVariant::Type type() const {return type_;}
|
||||
PIVariant::Type type() const {return _type;}
|
||||
|
||||
//! Returns type name of variant content
|
||||
PIString typeName() const {return typeName(type_);}
|
||||
PIString typeName() const;
|
||||
|
||||
|
||||
//! Returns \b true if type is not Invalid
|
||||
bool isValid() const {return type_ != PIVariant::Invalid;}
|
||||
bool isValid() const {return _type != PIVariant::Invalid;}
|
||||
|
||||
|
||||
/** \brief Returns new variant from custom type
|
||||
* \details In case of known types this function equivalent \a PIVariant(T) constructors. \n
|
||||
* Otherwise returns variant with content \a v and type Custom. */
|
||||
template <typename T>
|
||||
static PIVariant fromValue(const T & v) {PIVariant ret; ret._vcustom.resize(sizeof(T)); new((T*)(ret._vcustom.data()))T(v); ret.type_ = PIVariant::Custom; return ret;}
|
||||
static PIVariant fromValue(const T & v) {
|
||||
PIVariant ret;
|
||||
ret.initType<T>(v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PIVariant fromValue(const PIByteArray & c, const PIString & type) {
|
||||
PIVariant ret;
|
||||
ret._info = __PIVariantInfoStorage__::get()->map->value(type, 0);
|
||||
if (!ret._info) {
|
||||
PIVariant::Type t = typeFromName(type);
|
||||
if (t == Invalid) {
|
||||
piCout << "Can`t initialize PIVariant from unregistered type \"" << type << "\"!";
|
||||
return ret;
|
||||
}
|
||||
ret._type = t;
|
||||
} else
|
||||
ret._type = Custom;
|
||||
ret._content = c;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! Returns type from name
|
||||
@@ -371,56 +448,65 @@ public:
|
||||
static PIString typeName(PIVariant::Type type);
|
||||
|
||||
private:
|
||||
void destroy() {_vcustom.clear();}
|
||||
void destroy() {_content.clear();}
|
||||
template <typename T> static Type getType() {return Custom;}
|
||||
template <typename T> void initType(const T & v) {
|
||||
_content.clear();
|
||||
_content << v;
|
||||
_type = getType<T>();
|
||||
if (_type == Custom) {
|
||||
_info = __PIVariantInfoStorage__::get()->map->value(__PIVariantFunctions__<T>::typeNameHelper(), 0);
|
||||
if (!_info)
|
||||
piCout << "Can`t initialize PIVariant from unregistered type!";
|
||||
} else
|
||||
_info = 0;
|
||||
}
|
||||
template<typename T> static T getAsValue(const PIVariant & v) {
|
||||
if (v._content.isEmpty() || !v._info) return T();
|
||||
PIString cn = __PIVariantFunctions__<T>::typeNameHelper();
|
||||
piCout << "gav" << cn;
|
||||
PIByteArray ba;
|
||||
if (cn == v._info->typeName) {
|
||||
ba = v._content;
|
||||
} else {
|
||||
__PIVariantInfo__::castHelperFunc cf = v._info->cast.value(cn);
|
||||
piCout << "gav cast" << cf;
|
||||
if (!cf) return T();
|
||||
ba = cf(v._content);
|
||||
}
|
||||
T ret; ba >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
union {
|
||||
int _vint;
|
||||
llong _vllong;
|
||||
float _vfloat;
|
||||
double _vdouble;
|
||||
ldouble _vldouble;
|
||||
uchar _vraw[__PIVARIANT_UNION_SIZE__];
|
||||
/*complexd _vcomplexd;
|
||||
complexld _vcomplexld;
|
||||
PITime _vtime;
|
||||
PIDate _vdate;
|
||||
PIDateTime _vdatetime;
|
||||
PISystemTime _vsystime;*/
|
||||
};
|
||||
PIBitArray _vbitarray;
|
||||
PIByteArray _vbytearray;
|
||||
PIString _vstring;
|
||||
PIStringList _vstringlist;
|
||||
PIByteArray _vcustom;
|
||||
PIVariant::Type type_;
|
||||
PIByteArray _content;
|
||||
PIVariant::Type _type;
|
||||
__PIVariantInfo__ * _info;
|
||||
|
||||
};
|
||||
|
||||
template<> inline bool PIVariant::toValue() const {return toBool();}
|
||||
template<> inline char PIVariant::toValue() const {return (char)toInt();}
|
||||
template<> inline uchar PIVariant::toValue() const {return (uchar)toInt();}
|
||||
template<> inline short PIVariant::toValue() const {return (short)toInt();}
|
||||
template<> inline ushort PIVariant::toValue() const {return (ushort)toInt();}
|
||||
template<> inline int PIVariant::toValue() const {return toInt();}
|
||||
template<> inline uint PIVariant::toValue() const {return (uint)toInt();}
|
||||
template<> inline long PIVariant::toValue() const {return (long)toInt();}
|
||||
template<> inline ulong PIVariant::toValue() const {return (ulong)toInt();}
|
||||
template<> inline llong PIVariant::toValue() const {return toLLong();}
|
||||
template<> inline ullong PIVariant::toValue() const {return (ullong)toLLong();}
|
||||
template<> inline float PIVariant::toValue() const {return toFloat();}
|
||||
template<> inline double PIVariant::toValue() const {return toDouble();}
|
||||
template<> inline ldouble PIVariant::toValue() const {return toLDouble();}
|
||||
template<> inline complexd PIVariant::toValue() const {return toComplexd();}
|
||||
template<> inline complexld PIVariant::toValue() const {return toComplexld();}
|
||||
template<> inline void* PIVariant::toValue() const {return (void*)toLLong();}
|
||||
template<> inline const char* PIVariant::toValue() const {return toString().data();}
|
||||
template<> inline PITime PIVariant::toValue() const {return toTime();}
|
||||
template<> inline PIDate PIVariant::toValue() const {return toDate();}
|
||||
template<> inline PIDateTime PIVariant::toValue() const {return toDateTime();}
|
||||
template<> inline PIString PIVariant::toValue() const {return toString();}
|
||||
template<> inline PIStringList PIVariant::toValue() const {return toStringList();}
|
||||
template<> inline PIBitArray PIVariant::toValue() const {return toBitArray();}
|
||||
template<> inline PIByteArray PIVariant::toValue() const {return toByteArray();}
|
||||
template<> inline bool PIVariant::value() const {return toBool();}
|
||||
template<> inline char PIVariant::value() const {return (char)toInt();}
|
||||
template<> inline uchar PIVariant::value() const {return (uchar)toInt();}
|
||||
template<> inline short PIVariant::value() const {return (short)toInt();}
|
||||
template<> inline ushort PIVariant::value() const {return (ushort)toInt();}
|
||||
template<> inline int PIVariant::value() const {return toInt();}
|
||||
template<> inline uint PIVariant::value() const {return (uint)toInt();}
|
||||
template<> inline llong PIVariant::value() const {return toLLong();}
|
||||
template<> inline ullong PIVariant::value() const {return (ullong)toLLong();}
|
||||
template<> inline float PIVariant::value() const {return toFloat();}
|
||||
template<> inline double PIVariant::value() const {return toDouble();}
|
||||
template<> inline ldouble PIVariant::value() const {return toLDouble();}
|
||||
template<> inline complexd PIVariant::value() const {return toComplexd();}
|
||||
template<> inline complexld PIVariant::value() const {return toComplexld();}
|
||||
template<> inline void* PIVariant::value() const {return (void*)toLLong();}
|
||||
template<> inline const char* PIVariant::value() const {return toString().data();}
|
||||
template<> inline PITime PIVariant::value() const {return toTime();}
|
||||
template<> inline PIDate PIVariant::value() const {return toDate();}
|
||||
template<> inline PIDateTime PIVariant::value() const {return toDateTime();}
|
||||
template<> inline PIString PIVariant::value() const {return toString();}
|
||||
template<> inline PIStringList PIVariant::value() const {return toStringList();}
|
||||
template<> inline PIBitArray PIVariant::value() const {return toBitArray();}
|
||||
template<> inline PIByteArray PIVariant::value() const {return toByteArray();}
|
||||
|
||||
//template<> inline PIVariant PIVariant::fromValue(const char * v) {return PIVariant(PIString(v));}
|
||||
template<> inline PIVariant PIVariant::fromValue(const bool & v) {return PIVariant(v);}
|
||||
@@ -430,8 +516,6 @@ template<> inline PIVariant PIVariant::fromValue(const short & v) {return PIVari
|
||||
template<> inline PIVariant PIVariant::fromValue(const ushort & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const int & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const uint & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const long & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const ulong & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const llong & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const ullong & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const float & v) {return PIVariant(v);}
|
||||
@@ -448,12 +532,32 @@ template<> inline PIVariant PIVariant::fromValue(const PIDate & v) {return PIVar
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIDateTime & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PISystemTime & v) {return PIVariant(v);}
|
||||
|
||||
template<> inline PIVariant::Type PIVariant::getType<bool>() {return PIVariant::Bool;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<char>() {return PIVariant::Char;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<uchar>() {return PIVariant::UChar;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<short>() {return PIVariant::Short;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<ushort>() {return PIVariant::UShort;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<int>() {return PIVariant::Int;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<uint>() {return PIVariant::UInt;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<llong>() {return PIVariant::LLong;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<ullong>() {return PIVariant::ULLong;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<float>() {return PIVariant::Float;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<double>() {return PIVariant::Double;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<ldouble>() {return PIVariant::LDouble;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<complexd>() {return PIVariant::Complexd;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<complexld>() {return PIVariant::Complexld;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIBitArray>() {return PIVariant::BitArray;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIByteArray>() {return PIVariant::ByteArray;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIString>() {return PIVariant::String;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIStringList>() {return PIVariant::StringList;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PITime>() {return PIVariant::Time;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIDate>() {return PIVariant::Date;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIDateTime>() {return PIVariant::DateTime;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PISystemTime>() {return PIVariant::SystemTime;}
|
||||
|
||||
inline PICout operator <<(PICout s, const PIVariant & v) {
|
||||
s.space(); s.setControl(0, true);
|
||||
s << "PIVariant(" << PIVariant::typeName(v.type()) << ", ";
|
||||
if (v.type() == PIVariant::Custom) s << v._vcustom.size() << " bytes";
|
||||
else s << v.toString();
|
||||
s << ")";
|
||||
s << "PIVariant(" << v.typeName() << ", " << v.toString() << ")";
|
||||
s.restoreControl(); return s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user