git-svn-id: svn://db.shs.com.ru/pip@764 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Variant type
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
||||
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -237,6 +237,8 @@ public:
|
||||
pivPoint /** PIPoint */ ,
|
||||
pivRect /** PIRect */ ,
|
||||
pivIODevice /** PIVariantTypes::IODevice */ ,
|
||||
pivMathVector /** PIMathVectord */ ,
|
||||
pivMathMatrix /** PIMathMatrixd */ ,
|
||||
pivCustom /** Custom */ = 0xFF
|
||||
};
|
||||
|
||||
@@ -329,6 +331,12 @@ public:
|
||||
//! Constructs variant from rect
|
||||
PIVariant(const PIRectd & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from MathVector
|
||||
PIVariant(const PIMathVectord & v) {initType(v);}
|
||||
|
||||
//! Constructs variant from MathMatrix
|
||||
PIVariant(const PIMathMatrixd & v) {initType(v);}
|
||||
|
||||
|
||||
//! Set variant content and type to string
|
||||
void setValue(const char * v) {setValue(PIString(v));}
|
||||
@@ -414,6 +422,13 @@ public:
|
||||
//! Set variant content and type to rect
|
||||
void setValue(const PIRectd & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to math vector
|
||||
void setValue(const PIMathVectord & v) {initType(v);}
|
||||
|
||||
//! Set variant content and type to math matrix
|
||||
void setValue(const PIMathMatrixd & v) {initType(v);}
|
||||
|
||||
|
||||
//! Set current value from string without change type
|
||||
void setValueFromString(const PIString & v);
|
||||
|
||||
@@ -439,6 +454,8 @@ public:
|
||||
PIVariantTypes::IODevice toIODevice() const;
|
||||
PIPointd toPoint() const;
|
||||
PIRectd toRect() const;
|
||||
PIMathVectord toMathVector() const;
|
||||
PIMathMatrixd toMathMatrix() const;
|
||||
|
||||
|
||||
/** \brief Returns variant content as custom type
|
||||
@@ -530,6 +547,10 @@ public:
|
||||
PIVariant & operator =(const PIPointd & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const PIRectd & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const PIMathVectord & v) {setValue(v); return *this;}
|
||||
//! Assign operator
|
||||
PIVariant & operator =(const PIMathMatrixd & v) {setValue(v); return *this;}
|
||||
|
||||
|
||||
//! Compare operator
|
||||
@@ -688,6 +709,8 @@ template<> inline PIVariant PIVariant::fromValue(const PIVariantTypes::Color & v
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIVariantTypes::IODevice & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIPointd & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIRectd & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIMathVectord & v) {return PIVariant(v);}
|
||||
template<> inline PIVariant PIVariant::fromValue(const PIMathMatrixd & v) {return PIVariant(v);}
|
||||
|
||||
template<> inline PIVariant::Type PIVariant::getType<bool>() {return PIVariant::pivBool;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<char>() {return PIVariant::pivChar;}
|
||||
@@ -716,6 +739,8 @@ template<> inline PIVariant::Type PIVariant::getType<PIVariantTypes::Color>() {r
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIVariantTypes::IODevice>() {return PIVariant::pivIODevice;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIPointd>() {return PIVariant::pivPoint;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIRectd>() {return PIVariant::pivRect;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIMathVectord>() {return PIVariant::pivMathVector;}
|
||||
template<> inline PIVariant::Type PIVariant::getType<PIMathMatrixd>() {return PIVariant::pivMathMatrix;}
|
||||
|
||||
REGISTER_VARIANT(bool)
|
||||
REGISTER_VARIANT(char)
|
||||
@@ -744,6 +769,9 @@ REGISTER_NS_VARIANT(PIVariantTypes, Color)
|
||||
REGISTER_NS_VARIANT(PIVariantTypes, IODevice)
|
||||
REGISTER_VARIANT(PIPointd)
|
||||
REGISTER_VARIANT(PIRectd)
|
||||
REGISTER_VARIANT(PIMathVectord)
|
||||
REGISTER_VARIANT(PIMathMatrixd)
|
||||
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVariant & v) {
|
||||
s << v._content << int(v._type);
|
||||
|
||||
Reference in New Issue
Block a user