Arithmetic operators for DynamicAny

This commit is contained in:
Aleksandar Fabijanic
2007-09-05 23:38:12 +00:00
parent 0a65eefd9a
commit d9c5b827a5
6 changed files with 1072 additions and 46 deletions

View File

@@ -101,6 +101,10 @@ public:
virtual void convert(Timestamp& val) const = 0;
virtual bool isArray() const = 0;
virtual bool isStruct() const = 0;
virtual bool isInteger() const = 0;
virtual bool isSigned() const = 0;
virtual bool isNumeric() const = 0;
virtual bool isString() const = 0;
#ifndef POCO_LONG_IS_64_BIT
void convert(long& val) const;
@@ -289,6 +293,26 @@ public:
return typeid(T);
}
bool isInteger() const
{
return std::numeric_limits<T>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<T>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<T>::is_specialized;
}
bool isString() const
{
return type() == typeid(std::string);
}
void convert(Int8&) const
{
throw NotImplementedException("No DynamicAnyHolder specialization for type", typeid(T).name());
@@ -503,6 +527,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<Int8>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<Int8>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<Int8>::is_specialized;
}
bool isString() const
{
return false;
}
private:
Int8 _val;
};
@@ -627,6 +671,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<Int16>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<Int16>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<Int16>::is_specialized;
}
bool isString() const
{
return false;
}
private:
Int16 _val;
};
@@ -751,6 +815,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<Int32>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<Int32>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<Int32>::is_specialized;
}
bool isString() const
{
return false;
}
private:
Int32 _val;
};
@@ -875,6 +959,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<Int64>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<Int64>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<Int64>::is_specialized;
}
bool isString() const
{
return false;
}
private:
Int64 _val;
};
@@ -999,6 +1103,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<UInt8>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<UInt8>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<UInt8>::is_specialized;
}
bool isString() const
{
return false;
}
private:
UInt8 _val;
};
@@ -1123,6 +1247,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<UInt16>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<UInt16>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<UInt16>::is_specialized;
}
bool isString() const
{
return false;
}
private:
UInt16 _val;
};
@@ -1247,6 +1391,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<UInt32>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<UInt32>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<UInt32>::is_specialized;
}
bool isString() const
{
return false;
}
private:
UInt32 _val;
};
@@ -1377,6 +1541,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<UInt64>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<UInt64>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<UInt64>::is_specialized;
}
bool isString() const
{
return false;
}
private:
UInt64 _val;
};
@@ -1499,6 +1683,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<bool>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<bool>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<bool>::is_specialized;
}
bool isString() const
{
return false;
}
private:
bool _val;
};
@@ -1624,6 +1828,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<float>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<float>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<float>::is_specialized;
}
bool isString() const
{
return false;
}
private:
float _val;
};
@@ -1755,6 +1979,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<double>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<double>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<double>::is_specialized;
}
bool isString() const
{
return false;
}
private:
double _val;
};
@@ -1877,6 +2121,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<char>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<char>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<char>::is_specialized;
}
bool isString() const
{
return false;
}
private:
char _val;
};
@@ -2029,6 +2293,26 @@ public:
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return true;
}
private:
std::string _val;
};
@@ -2156,6 +2440,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<long>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<long>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<long>::is_specialized;
}
bool isString() const
{
return false;
}
private:
long _val;
};
@@ -2280,6 +2584,26 @@ public:
return false;
}
bool isInteger() const
{
return std::numeric_limits<unsigned long>::is_integer;
}
bool isSigned() const
{
return std::numeric_limits<unsigned long>::is_signed;
}
bool isNumeric() const
{
return std::numeric_limits<unsigned long>::is_specialized;
}
bool isString() const
{
return false;
}
private:
unsigned long _val;
};
@@ -2369,7 +2693,7 @@ public:
{
// Serialize in JSON format: note: although this a vector<T>, the code only
// supports vector<DynamicAny>. We can't make this a total specialization,
// because of an otherwise cyclic dependency between DynamicAny and DynamicAnyHolder
// because of the cyclic dependency between DynamicAny and DynamicAnyHolder
// JSON format definition: [ n times: elem ',' ], no ',' for last elem
val.append("[ ");
@@ -2424,6 +2748,26 @@ public:
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
T& operator[](typename std::vector<T>::size_type n)
{
return _val.operator[](n);
@@ -2556,6 +2900,26 @@ public:
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
private:
DateTime _val;
};
@@ -2678,6 +3042,26 @@ public:
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
private:
LocalDateTime _val;
};
@@ -2800,6 +3184,26 @@ public:
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
return false;
}
private:
Timestamp _val;
};