mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-30 13:47:10 +01:00
Merge pull request #1882 from Burgch/uint64-dynamic-var
Add support for (unsigned) long long when long is 64bit
This commit is contained in:
@@ -186,6 +186,16 @@ public:
|
|||||||
void convert(unsigned long& val) const;
|
void convert(unsigned long& val) const;
|
||||||
/// Calls convert(UInt32).
|
/// Calls convert(UInt32).
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
virtual void convert(long long& val) const;
|
||||||
|
/// Throws BadCastException. Must be overriden in a type
|
||||||
|
/// specialization in order to suport the conversion.
|
||||||
|
|
||||||
|
virtual void convert(unsigned long long & val) const;
|
||||||
|
/// Throws BadCastException. Must be overriden in a type
|
||||||
|
/// specialization in order to suport the conversion.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void convert(bool& val) const;
|
virtual void convert(bool& val) const;
|
||||||
@@ -522,6 +532,19 @@ inline void VarHolder::convert(unsigned long& val) const
|
|||||||
val = tmp;
|
val = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
inline void VarHolder::convert(long long& /*val*/) const
|
||||||
|
{
|
||||||
|
throw BadCastException("Can not convert to long long");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void VarHolder::convert(unsigned long long& /*val*/) const
|
||||||
|
{
|
||||||
|
throw BadCastException("Can not convert to unsigned long long");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void VarHolder::convert(bool& /*val*/) const
|
inline void VarHolder::convert(bool& /*val*/) const
|
||||||
@@ -753,6 +776,20 @@ public:
|
|||||||
convertSignedToUnsigned(_val, val);
|
convertSignedToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -895,6 +932,20 @@ public:
|
|||||||
convertSignedToUnsigned(_val, val);
|
convertSignedToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1035,6 +1086,20 @@ public:
|
|||||||
convertSignedToUnsigned(_val, val);
|
convertSignedToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1173,6 +1238,20 @@ public:
|
|||||||
convertSignedToUnsigned(_val, val);
|
convertSignedToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1326,6 +1405,20 @@ public:
|
|||||||
val = _val;
|
val = _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<long long>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1464,6 +1557,20 @@ public:
|
|||||||
val = _val;
|
val = _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<long long>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1602,6 +1709,20 @@ public:
|
|||||||
val = _val;
|
val = _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1740,6 +1861,20 @@ public:
|
|||||||
val = _val;
|
val = _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != 0);
|
val = (_val != 0);
|
||||||
@@ -1899,6 +2034,20 @@ public:
|
|||||||
val = static_cast<UInt64>(_val ? 1 : 0);
|
val = static_cast<UInt64>(_val ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<long long>(_val ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<unsigned long long>(_val ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = _val;
|
val = _val;
|
||||||
@@ -2035,6 +2184,20 @@ public:
|
|||||||
convertSignedFloatToUnsigned(_val, val);
|
convertSignedFloatToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
convertToSmaller(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedFloatToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = !(_val <= std::numeric_limits<float>::min() &&
|
val = !(_val <= std::numeric_limits<float>::min() &&
|
||||||
@@ -2174,6 +2337,20 @@ public:
|
|||||||
convertSignedFloatToUnsigned(_val, val);
|
convertSignedFloatToUnsigned(_val, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
convertToSmaller(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedFloatToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = !(_val <= std::numeric_limits<double>::min() &&
|
val = !(_val <= std::numeric_limits<double>::min() &&
|
||||||
@@ -2319,6 +2496,20 @@ public:
|
|||||||
val = static_cast<UInt8>(_val);
|
val = static_cast<UInt8>(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<long long>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<unsigned long long>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
val = (_val != '\0');
|
val = (_val != '\0');
|
||||||
@@ -2463,6 +2654,20 @@ public:
|
|||||||
val = NumberParser::parseUnsigned64(_val);
|
val = NumberParser::parseUnsigned64(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = NumberParser::parse64(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = NumberParser::parseUnsigned64(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
if (_val.empty())
|
if (_val.empty())
|
||||||
@@ -2641,6 +2846,20 @@ public:
|
|||||||
val = NumberParser::parseUnsigned64(toStdString());
|
val = NumberParser::parseUnsigned64(toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = NumberParser::parse64(toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = NumberParser::parseUnsigned64(toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
static const std::string VAL_FALSE("false");
|
static const std::string VAL_FALSE("false");
|
||||||
@@ -3043,6 +3262,305 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#else // if defined (POCO_LONG_IS_64_BIT)
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class VarHolderImpl<long long>: public VarHolder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VarHolderImpl(long long val): _val(val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~VarHolderImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::type_info& type() const
|
||||||
|
{
|
||||||
|
return typeid(long long);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int8& val) const
|
||||||
|
{
|
||||||
|
convertToSmaller(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int16& val) const
|
||||||
|
{
|
||||||
|
convertToSmaller(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int32& val) const
|
||||||
|
{
|
||||||
|
convertToSmaller(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int64& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<Int64>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt8& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt16& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt32& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt64& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
convertSignedToUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(bool& val) const
|
||||||
|
{
|
||||||
|
val = (_val != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(float& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<float>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(double& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<double>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(char& val) const
|
||||||
|
{
|
||||||
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(std::string& val) const
|
||||||
|
{
|
||||||
|
val = NumberFormatter::format(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
||||||
|
{
|
||||||
|
return cloneHolder(pVarHolder, _val);
|
||||||
|
}
|
||||||
|
|
||||||
|
const long long& value() const
|
||||||
|
{
|
||||||
|
return _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isArray() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isStruct() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInteger() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<long long>::is_integer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSigned() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<long long>::is_signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNumeric() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<long long>::is_specialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isString() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VarHolderImpl();
|
||||||
|
VarHolderImpl(const VarHolderImpl&);
|
||||||
|
VarHolderImpl& operator = (const VarHolderImpl&);
|
||||||
|
|
||||||
|
long long _val;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class VarHolderImpl<unsigned long long>: public VarHolder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VarHolderImpl(unsigned long long val): _val(val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~VarHolderImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::type_info& type() const
|
||||||
|
{
|
||||||
|
return typeid(unsigned long long);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int8& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int16& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int32& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(Int64& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt8& val) const
|
||||||
|
{
|
||||||
|
convertToSmallerUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt16& val) const
|
||||||
|
{
|
||||||
|
convertToSmallerUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt32& val) const
|
||||||
|
{
|
||||||
|
convertToSmallerUnsigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(UInt64& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<UInt64>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
convertUnsignedToSigned(_val, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(bool& val) const
|
||||||
|
{
|
||||||
|
val = (_val != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(float& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<float>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(double& val) const
|
||||||
|
{
|
||||||
|
val = static_cast<double>(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(char& val) const
|
||||||
|
{
|
||||||
|
UInt8 tmp;
|
||||||
|
convert(tmp);
|
||||||
|
val = static_cast<char>(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(std::string& val) const
|
||||||
|
{
|
||||||
|
val = NumberFormatter::format(_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
||||||
|
{
|
||||||
|
return cloneHolder(pVarHolder, _val);
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned long long& value() const
|
||||||
|
{
|
||||||
|
return _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isArray() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isStruct() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInteger() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<unsigned long long>::is_integer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSigned() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<unsigned long long>::is_signed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNumeric() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<unsigned long long>::is_specialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isString() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VarHolderImpl();
|
||||||
|
VarHolderImpl(const VarHolderImpl&);
|
||||||
|
VarHolderImpl& operator = (const VarHolderImpl&);
|
||||||
|
|
||||||
|
unsigned long long _val;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // 64bit
|
#endif // 64bit
|
||||||
|
|
||||||
|
|
||||||
@@ -3293,6 +3811,20 @@ public:
|
|||||||
val = _val.timestamp().epochMicroseconds();
|
val = _val.timestamp().epochMicroseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.timestamp().epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.timestamp().epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
{
|
{
|
||||||
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||||
@@ -3409,6 +3941,20 @@ public:
|
|||||||
val = _val.timestamp().epochMicroseconds();
|
val = _val.timestamp().epochMicroseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.timestamp().epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.timestamp().epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
{
|
{
|
||||||
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||||
@@ -3525,6 +4071,20 @@ public:
|
|||||||
val = _val.epochMicroseconds();
|
val = _val.epochMicroseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
void convert(long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void convert(unsigned long long& val) const
|
||||||
|
{
|
||||||
|
val = _val.epochMicroseconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
{
|
{
|
||||||
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT);
|
||||||
|
|||||||
@@ -150,7 +150,59 @@ public:
|
|||||||
/// If prefix is true, "0x" prefix is prepended to the
|
/// If prefix is true, "0x" prefix is prepended to the
|
||||||
/// resulting string.
|
/// resulting string.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
static std::string format(long long value);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation.
|
||||||
|
|
||||||
|
static std::string format(long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation,
|
||||||
|
/// right justified in a field having at least the specified width.
|
||||||
|
|
||||||
|
static std::string format0(long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width.
|
||||||
|
|
||||||
|
static std::string formatHex(long long value, bool prefix = false);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||||
|
/// If prefix is true, "0x" prefix is prepended to the
|
||||||
|
/// resulting string.
|
||||||
|
/// The value is treated as unsigned.
|
||||||
|
|
||||||
|
static std::string formatHex(long long value, int width, bool prefix = false);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width.
|
||||||
|
/// The value is treated as unsigned.
|
||||||
|
/// If prefix is true, "0x" prefix is prepended to the resulting string.
|
||||||
|
|
||||||
|
static std::string format(unsigned long long value);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation.
|
||||||
|
|
||||||
|
static std::string format(unsigned long long value, int width);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation,
|
||||||
|
/// right justified in a field having at least the specified width.
|
||||||
|
|
||||||
|
static std::string format0(unsigned long long value, int width);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least the
|
||||||
|
/// specified width.
|
||||||
|
|
||||||
|
static std::string formatHex(unsigned long long value, bool prefix = false);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||||
|
/// If prefix is true, "0x" prefix is prepended to the
|
||||||
|
/// resulting string.
|
||||||
|
|
||||||
|
static std::string formatHex(unsigned long long value, int width, bool prefix = false);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width. If prefix is true, "0x" prefix is
|
||||||
|
/// prepended to the resulting string.
|
||||||
|
|
||||||
|
#else // ifndef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
static std::string format(Int64 value);
|
static std::string format(Int64 value);
|
||||||
/// Formats a 64-bit integer value in decimal notation.
|
/// Formats a 64-bit integer value in decimal notation.
|
||||||
@@ -200,7 +252,9 @@ public:
|
|||||||
/// the specified width. If prefix is true, "0x" prefix is
|
/// the specified width. If prefix is true, "0x" prefix is
|
||||||
/// prepended to the resulting string.
|
/// prepended to the resulting string.
|
||||||
|
|
||||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#endif // ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
#endif // ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
static std::string format(float value);
|
static std::string format(float value);
|
||||||
/// Formats a float value in decimal floating-point notation,
|
/// Formats a float value in decimal floating-point notation,
|
||||||
@@ -325,7 +379,53 @@ public:
|
|||||||
/// right justified and zero-padded in a field having at least the
|
/// right justified and zero-padded in a field having at least the
|
||||||
/// specified width.
|
/// specified width.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
static void append(std::string& str, long long value);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation.
|
||||||
|
|
||||||
|
static void append(std::string& str, long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation,
|
||||||
|
/// right justified in a field having at least the specified width.
|
||||||
|
|
||||||
|
static void append0(std::string& str, long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in decimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width.
|
||||||
|
|
||||||
|
static void appendHex(std::string& str, long long value);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||||
|
/// The value is treated as unsigned.
|
||||||
|
|
||||||
|
static void appendHex(std::string& str, long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width.
|
||||||
|
/// The value is treated as unsigned.
|
||||||
|
|
||||||
|
static void append(std::string& str, unsigned long long value);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation.
|
||||||
|
|
||||||
|
static void append(std::string& str, unsigned long long value, int width);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation,
|
||||||
|
/// right justified in a field having at least the specified width.
|
||||||
|
|
||||||
|
static void append0(std::string& str, unsigned long long value, int width);
|
||||||
|
/// Formats an unsigned 64-bit integer value in decimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least the
|
||||||
|
/// specified width.
|
||||||
|
|
||||||
|
static void appendHex(std::string& str, unsigned long long value);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||||
|
|
||||||
|
static void appendHex(std::string& str, unsigned long long value, int width);
|
||||||
|
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||||
|
/// right justified and zero-padded in a field having at least
|
||||||
|
/// the specified width.
|
||||||
|
|
||||||
|
#else // ifndef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
static void append(std::string& str, Int64 value);
|
static void append(std::string& str, Int64 value);
|
||||||
/// Formats a 64-bit integer value in decimal notation.
|
/// Formats a 64-bit integer value in decimal notation.
|
||||||
@@ -369,7 +469,9 @@ public:
|
|||||||
/// right justified and zero-padded in a field having at least
|
/// right justified and zero-padded in a field having at least
|
||||||
/// the specified width.
|
/// the specified width.
|
||||||
|
|
||||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#endif // ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
#endif // ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
static void append(std::string& str, float value);
|
static void append(std::string& str, float value);
|
||||||
/// Formats a float value in decimal floating-point notation,
|
/// Formats a float value in decimal floating-point notation,
|
||||||
@@ -570,7 +672,92 @@ inline std::string NumberFormatter::formatHex(unsigned long value, int width, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format(long long value)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
intToStr(value, 10, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format(long long value, int width)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
intToStr(value, 10, result, false, width, ' ');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format0(long long value, int width)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
intToStr(value, 10, result, false, width, '0');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::formatHex(long long value, bool prefix)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format(unsigned long long value)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(value, 10, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format(unsigned long long value, int width)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(value, 10, result, false, width, ' ');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::format0(unsigned long long value, int width)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(value, 10, result, false, width, '0');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(value, 0x10, result, prefix);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else // ifndef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
|
||||||
inline std::string NumberFormatter::format(Int64 value)
|
inline std::string NumberFormatter::format(Int64 value)
|
||||||
@@ -653,7 +840,9 @@ inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool pref
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#endif // ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
#endif // ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
|
||||||
inline std::string NumberFormatter::format(float value)
|
inline std::string NumberFormatter::format(float value)
|
||||||
|
|||||||
@@ -234,7 +234,102 @@ void NumberFormatter::appendHex(std::string& str, unsigned long value, int width
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append(std::string& str, long long value)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
intToStr(value, 10, result, sz);
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append(std::string& str, long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
intToStr(value, 10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append0(std::string& str, long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
intToStr(value, 10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::appendHex(std::string& str, long long value)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz);
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::appendHex(std::string& str, long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append(std::string& str, unsigned long long value)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(value, 10, result, sz);
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append(std::string& str, unsigned long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(value, 10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::append0(std::string& str, unsigned long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(value, 10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::appendHex(std::string& str, unsigned long long value)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(value, 0x10, result, sz);
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NumberFormatter::appendHex(std::string& str, unsigned long long value, int width)
|
||||||
|
{
|
||||||
|
char result[NF_MAX_INT_STRING_LEN];
|
||||||
|
std::size_t sz = NF_MAX_INT_STRING_LEN;
|
||||||
|
uIntToStr(value, 0x10, result, sz, false, width, '0');
|
||||||
|
str.append(result, sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else // ifndef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
|
||||||
void NumberFormatter::append(std::string& str, Int64 value)
|
void NumberFormatter::append(std::string& str, Int64 value)
|
||||||
@@ -327,7 +422,9 @@ void NumberFormatter::appendHex(std::string& str, UInt64 value, int width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#endif // ifdef POCO_LONG_IS_64_BIT
|
||||||
|
|
||||||
|
#endif // ifdef POCO_HAVE_INT64
|
||||||
|
|
||||||
|
|
||||||
void NumberFormatter::append(std::string& str, float value)
|
void NumberFormatter::append(std::string& str, float value)
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ void NumberFormatterTest::testFormat()
|
|||||||
|
|
||||||
assert (NumberFormatter::format((UInt64) 123) == "123");
|
assert (NumberFormatter::format((UInt64) 123) == "123");
|
||||||
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
||||||
|
#if defined(POCO_LONG_IS_64_BIT)
|
||||||
|
assert (NumberFormatter::format((long long) 123) == "123");
|
||||||
|
assert (NumberFormatter::format((long long) -123) == "-123");
|
||||||
|
assert (NumberFormatter::format((long long) -123, 5) == " -123");
|
||||||
|
|
||||||
|
assert (NumberFormatter::format((unsigned long long) 123) == "123");
|
||||||
|
assert (NumberFormatter::format((unsigned long long) 123, 5) == " 123");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sizeof(void*) == 4)
|
if (sizeof(void*) == 4)
|
||||||
@@ -83,6 +91,11 @@ void NumberFormatterTest::testFormat0()
|
|||||||
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
|
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
|
||||||
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
|
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
|
||||||
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
|
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
|
||||||
|
#if defined(POCO_LONG_IS_64_BIT)
|
||||||
|
assert (NumberFormatter::format0((long long) 123, 5) == "00123");
|
||||||
|
assert (NumberFormatter::format0((long long) -123, 5) == "-0123");
|
||||||
|
assert (NumberFormatter::format0((unsigned long long) 123, 5) == "00123");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +143,17 @@ void NumberFormatterTest::testFormatHex()
|
|||||||
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
||||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
||||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
||||||
|
#if defined(POCO_LONG_IS_64_BIT)
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0x12) == "12");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0xab) == "AB");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0x12, 4) == "0012");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0xab, 4) == "00AB");
|
||||||
|
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0x12) == "12");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0xab) == "AB");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 4) == "0012");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 4) == "00AB");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert (NumberFormatter::formatHex(0x12, true) == "0x12");
|
assert (NumberFormatter::formatHex(0x12, true) == "0x12");
|
||||||
@@ -174,6 +198,21 @@ void NumberFormatterTest::testFormatHex()
|
|||||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
|
assert (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
|
||||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
|
assert (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
|
||||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
|
assert (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
|
||||||
|
#if defined(POCO_LONG_IS_64_BIT)
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0x12, true) == "0x12");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0xab, true) == "0xAB");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0x12, 4, true) == "0x12");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0xab, 4, true) == "0xAB");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0x12, 6, true) == "0x0012");
|
||||||
|
assert (NumberFormatter::formatHex((long long) 0xab, 6, true) == "0x00AB");
|
||||||
|
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0x12, true) == "0x12");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0xab, true) == "0xAB");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 4, true) == "0x12");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 4, true) == "0xAB");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0x12, 6, true) == "0x0012");
|
||||||
|
assert (NumberFormatter::formatHex((unsigned long long) 0xab, 6, true) == "0x00AB");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,16 @@ void VarTest::testInt8()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -189,10 +195,16 @@ void VarTest::testInt16()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -277,10 +289,16 @@ void VarTest::testInt32()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -365,10 +383,16 @@ void VarTest::testInt64()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -453,10 +477,16 @@ void VarTest::testUInt8()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -541,10 +571,16 @@ void VarTest::testUInt16()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -629,10 +665,16 @@ void VarTest::testUInt32()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -717,10 +759,16 @@ void VarTest::testUInt64()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -805,10 +853,16 @@ void VarTest::testBool()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 1);
|
assert (s14 == 1);
|
||||||
assert (s15 == 1);
|
assert (s15 == 1);
|
||||||
|
assert (s16 == 1);
|
||||||
|
assert (s17 == 1);
|
||||||
assert (s1 == "true");
|
assert (s1 == "true");
|
||||||
assert (s2 == 1);
|
assert (s2 == 1);
|
||||||
assert (s3 == 1);
|
assert (s3 == 1);
|
||||||
@@ -876,10 +930,16 @@ void VarTest::testChar()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == " ");
|
assert (s1 == " ");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -950,10 +1010,16 @@ void VarTest::testFloat()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -1042,10 +1108,16 @@ void VarTest::testDouble()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -1130,10 +1202,16 @@ void VarTest::testString()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -1215,10 +1293,16 @@ void VarTest::testLong()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -1303,10 +1387,16 @@ void VarTest::testULong()
|
|||||||
a1.convert(s13);
|
a1.convert(s13);
|
||||||
long s14;
|
long s14;
|
||||||
unsigned long s15;
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
a1.convert(s14);
|
a1.convert(s14);
|
||||||
a1.convert(s15);
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
assert (s14 == 32);
|
assert (s14 == 32);
|
||||||
assert (s15 == 32);
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
assert (s1 == "32");
|
assert (s1 == "32");
|
||||||
assert (s2 == 32);
|
assert (s2 == 32);
|
||||||
assert (s3 == 32);
|
assert (s3 == 32);
|
||||||
@@ -1355,6 +1445,193 @@ void VarTest::testULong()
|
|||||||
assert (a3 == 64);
|
assert (a3 == 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VarTest::testLongLong()
|
||||||
|
{
|
||||||
|
long long src = 32;
|
||||||
|
Var a1 = src;
|
||||||
|
|
||||||
|
assert (a1.type() == typeid(long long));
|
||||||
|
|
||||||
|
std::string s1;
|
||||||
|
Poco::Int8 s2;
|
||||||
|
Poco::Int16 s3;
|
||||||
|
Poco::Int32 s4;
|
||||||
|
Poco::Int64 s5;
|
||||||
|
Poco::UInt8 s6;
|
||||||
|
Poco::UInt16 s7;
|
||||||
|
Poco::UInt32 s8;
|
||||||
|
Poco::UInt64 s9;
|
||||||
|
float s10;
|
||||||
|
double s11;
|
||||||
|
bool s12;
|
||||||
|
char s13;
|
||||||
|
a1.convert(s1);
|
||||||
|
a1.convert(s2);
|
||||||
|
a1.convert(s3);
|
||||||
|
a1.convert(s4);
|
||||||
|
a1.convert(s5);
|
||||||
|
a1.convert(s6);
|
||||||
|
a1.convert(s7);
|
||||||
|
a1.convert(s8);
|
||||||
|
a1.convert(s9);
|
||||||
|
a1.convert(s10);
|
||||||
|
a1.convert(s11);
|
||||||
|
a1.convert(s12);
|
||||||
|
a1.convert(s13);
|
||||||
|
long s14;
|
||||||
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
|
a1.convert(s14);
|
||||||
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
|
assert (s14 == 32);
|
||||||
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
|
assert (s1 == "32");
|
||||||
|
assert (s2 == 32);
|
||||||
|
assert (s3 == 32);
|
||||||
|
assert (s4 == 32);
|
||||||
|
assert (s5 == 32);
|
||||||
|
assert (s6 == 32);
|
||||||
|
assert (s7 == 32);
|
||||||
|
assert (s8 == 32);
|
||||||
|
assert (s9 == 32);
|
||||||
|
assert (s10 == 32.0f);
|
||||||
|
assert (s11 == 32.0);
|
||||||
|
assert (s12);
|
||||||
|
assert (s13 == ' ');
|
||||||
|
Var a2(a1);
|
||||||
|
std::string t2;
|
||||||
|
a2.convert(t2);
|
||||||
|
assert (s1 == t2);
|
||||||
|
|
||||||
|
long long value = a1.extract<long long>();
|
||||||
|
assert (value == 32);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Int16 value2; value2 = a1.extract<Int16>();
|
||||||
|
fail("bad cast - must throw");
|
||||||
|
}
|
||||||
|
catch (Poco::BadCastException&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Var a3 = a1 + 1;
|
||||||
|
assert (a3 == 33);
|
||||||
|
a3 = a1 - 1;
|
||||||
|
assert (a3 == 31);
|
||||||
|
a3 += 1;
|
||||||
|
assert (a3 == 32);
|
||||||
|
a3 -= 1;
|
||||||
|
assert (a3 == 31);
|
||||||
|
a3 = a1 / 2;
|
||||||
|
assert (a3 == 16);
|
||||||
|
a3 = a1 * 2;
|
||||||
|
assert (a3 == 64);
|
||||||
|
a3 /= 2;
|
||||||
|
assert (a3 == 32);
|
||||||
|
a3 *= 2;
|
||||||
|
assert (a3 == 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void VarTest::testULongLong()
|
||||||
|
{
|
||||||
|
unsigned long long src = 32;
|
||||||
|
Var a1 = src;
|
||||||
|
|
||||||
|
assert (a1.type() == typeid(unsigned long long));
|
||||||
|
|
||||||
|
std::string s1;
|
||||||
|
Poco::Int8 s2;
|
||||||
|
Poco::Int16 s3;
|
||||||
|
Poco::Int32 s4;
|
||||||
|
Poco::Int64 s5;
|
||||||
|
Poco::UInt8 s6;
|
||||||
|
Poco::UInt16 s7;
|
||||||
|
Poco::UInt32 s8;
|
||||||
|
Poco::UInt64 s9;
|
||||||
|
float s10;
|
||||||
|
double s11;
|
||||||
|
bool s12;
|
||||||
|
char s13;
|
||||||
|
a1.convert(s1);
|
||||||
|
a1.convert(s2);
|
||||||
|
a1.convert(s3);
|
||||||
|
a1.convert(s4);
|
||||||
|
a1.convert(s5);
|
||||||
|
a1.convert(s6);
|
||||||
|
a1.convert(s7);
|
||||||
|
a1.convert(s8);
|
||||||
|
a1.convert(s9);
|
||||||
|
a1.convert(s10);
|
||||||
|
a1.convert(s11);
|
||||||
|
a1.convert(s12);
|
||||||
|
a1.convert(s13);
|
||||||
|
long s14;
|
||||||
|
unsigned long s15;
|
||||||
|
long long s16;
|
||||||
|
unsigned long long s17;
|
||||||
|
a1.convert(s14);
|
||||||
|
a1.convert(s15);
|
||||||
|
a1.convert(s16);
|
||||||
|
a1.convert(s17);
|
||||||
|
assert (s14 == 32);
|
||||||
|
assert (s15 == 32);
|
||||||
|
assert (s16 == 32);
|
||||||
|
assert (s17 == 32);
|
||||||
|
assert (s1 == "32");
|
||||||
|
assert (s2 == 32);
|
||||||
|
assert (s3 == 32);
|
||||||
|
assert (s4 == 32);
|
||||||
|
assert (s5 == 32);
|
||||||
|
assert (s6 == 32);
|
||||||
|
assert (s7 == 32);
|
||||||
|
assert (s8 == 32);
|
||||||
|
assert (s9 == 32);
|
||||||
|
assert (s10 == 32.0f);
|
||||||
|
assert (s11 == 32.0);
|
||||||
|
assert (s12);
|
||||||
|
assert (s13 == ' ');
|
||||||
|
Var a2(a1);
|
||||||
|
std::string t2;
|
||||||
|
a2.convert(t2);
|
||||||
|
assert (s1 == t2);
|
||||||
|
|
||||||
|
unsigned long long value = a1.extract<unsigned long long>();
|
||||||
|
assert (value == 32);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Int16 value2; value2 = a1.extract<Int16>();
|
||||||
|
fail("bad cast - must throw");
|
||||||
|
}
|
||||||
|
catch (Poco::BadCastException&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Var a3 = a1 + 1;
|
||||||
|
assert (a3 == 33);
|
||||||
|
a3 = a1 - 1;
|
||||||
|
assert (a3 == 31);
|
||||||
|
a3 += 1;
|
||||||
|
assert (a3 == 32);
|
||||||
|
a3 -= 1;
|
||||||
|
assert (a3 == 31);
|
||||||
|
a3 = a1 / 2;
|
||||||
|
assert (a3 == 16);
|
||||||
|
a3 = a1 * 2;
|
||||||
|
assert (a3 == 64);
|
||||||
|
a3 /= 2;
|
||||||
|
assert (a3 == 32);
|
||||||
|
a3 *= 2;
|
||||||
|
assert (a3 == 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VarTest::testUDT()
|
void VarTest::testUDT()
|
||||||
{
|
{
|
||||||
@@ -1756,9 +2033,11 @@ void VarTest::testIsStruct()
|
|||||||
char s13('c');
|
char s13('c');
|
||||||
long s14(232323);
|
long s14(232323);
|
||||||
unsigned long s15(21233232u);
|
unsigned long s15(21233232u);
|
||||||
std::vector<Var> s16;
|
long long s16(-23823838);
|
||||||
Struct<std::string> s17;
|
unsigned long s17(2328328382u);
|
||||||
Struct<int> s18;
|
std::vector<Var> s18;
|
||||||
|
Struct<std::string> s19;
|
||||||
|
Struct<int> s20;
|
||||||
|
|
||||||
Var d1(s1);
|
Var d1(s1);
|
||||||
Var d2(s2);
|
Var d2(s2);
|
||||||
@@ -1778,6 +2057,8 @@ void VarTest::testIsStruct()
|
|||||||
Var d16(s16);
|
Var d16(s16);
|
||||||
Var d17(s17);
|
Var d17(s17);
|
||||||
Var d18(s18);
|
Var d18(s18);
|
||||||
|
Var d19(s19);
|
||||||
|
Var d20(s20);
|
||||||
|
|
||||||
assert (!d1.isStruct());
|
assert (!d1.isStruct());
|
||||||
assert (!d2.isStruct());
|
assert (!d2.isStruct());
|
||||||
@@ -1795,8 +2076,10 @@ void VarTest::testIsStruct()
|
|||||||
assert (!d14.isStruct());
|
assert (!d14.isStruct());
|
||||||
assert (!d15.isStruct());
|
assert (!d15.isStruct());
|
||||||
assert (!d16.isStruct());
|
assert (!d16.isStruct());
|
||||||
assert (d17.isStruct());
|
assert (!d17.isStruct());
|
||||||
assert (d18.isStruct());
|
assert (!d18.isStruct());
|
||||||
|
assert (d19.isStruct());
|
||||||
|
assert (d20.isStruct());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1817,8 +2100,10 @@ void VarTest::testIsArray()
|
|||||||
char s13('c');
|
char s13('c');
|
||||||
long s14(232323);
|
long s14(232323);
|
||||||
unsigned long s15(21233232u);
|
unsigned long s15(21233232u);
|
||||||
std::vector<Var> s16;
|
long long s16(-23823838);
|
||||||
DynamicStruct s17;
|
unsigned long long s17(2328328382u);
|
||||||
|
std::vector<Var> s18;
|
||||||
|
DynamicStruct s19;
|
||||||
|
|
||||||
Var d0;
|
Var d0;
|
||||||
Var d1(s1);
|
Var d1(s1);
|
||||||
@@ -1838,6 +2123,8 @@ void VarTest::testIsArray()
|
|||||||
Var d15(s15);
|
Var d15(s15);
|
||||||
Var d16(s16);
|
Var d16(s16);
|
||||||
Var d17(s17);
|
Var d17(s17);
|
||||||
|
Var d18(s18);
|
||||||
|
Var d19(s19);
|
||||||
|
|
||||||
assert (!d0.isArray());
|
assert (!d0.isArray());
|
||||||
assert (!d1.isArray());
|
assert (!d1.isArray());
|
||||||
@@ -1855,8 +2142,10 @@ void VarTest::testIsArray()
|
|||||||
assert (!d13.isArray());
|
assert (!d13.isArray());
|
||||||
assert (!d14.isArray());
|
assert (!d14.isArray());
|
||||||
assert (!d15.isArray());
|
assert (!d15.isArray());
|
||||||
assert (d16.isArray());
|
assert (!d16.isArray());
|
||||||
assert (!d17.isArray());
|
assert (!d17.isArray());
|
||||||
|
assert (d18.isArray());
|
||||||
|
assert (!d19.isArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1877,10 +2166,12 @@ void VarTest::testArrayIdxOperator()
|
|||||||
char s13('c');
|
char s13('c');
|
||||||
long s14(232323);
|
long s14(232323);
|
||||||
unsigned long s15(21233232u);
|
unsigned long s15(21233232u);
|
||||||
std::vector<Var> s16;
|
long long s16(-23823838);
|
||||||
s16.push_back(s1);
|
unsigned long long s17(2328328382u);
|
||||||
s16.push_back(s2);
|
std::vector<Var> s18;
|
||||||
DynamicStruct s17;
|
s18.push_back(s1);
|
||||||
|
s18.push_back(s2);
|
||||||
|
DynamicStruct s19;
|
||||||
|
|
||||||
Var d1(s1);
|
Var d1(s1);
|
||||||
Var d2(s2);
|
Var d2(s2);
|
||||||
@@ -1899,6 +2190,8 @@ void VarTest::testArrayIdxOperator()
|
|||||||
Var d15(s15);
|
Var d15(s15);
|
||||||
Var d16(s16);
|
Var d16(s16);
|
||||||
Var d17(s17);
|
Var d17(s17);
|
||||||
|
Var d18(s18);
|
||||||
|
Var d19(s19);
|
||||||
|
|
||||||
testGetIdxMustThrow(d1, 0);
|
testGetIdxMustThrow(d1, 0);
|
||||||
testGetIdxNoThrow(d2, 0);
|
testGetIdxNoThrow(d2, 0);
|
||||||
@@ -1915,8 +2208,10 @@ void VarTest::testArrayIdxOperator()
|
|||||||
testGetIdxNoThrow(d13, 0);
|
testGetIdxNoThrow(d13, 0);
|
||||||
testGetIdxNoThrow(d14, 0);
|
testGetIdxNoThrow(d14, 0);
|
||||||
testGetIdxNoThrow(d15, 0);
|
testGetIdxNoThrow(d15, 0);
|
||||||
testGetIdx(d16, 0, s1);
|
testGetIdxNoThrow(d16, 0);
|
||||||
testGetIdx(d16, 1, s2);
|
testGetIdxNoThrow(d17, 0);
|
||||||
|
testGetIdx(d18, 0, s1);
|
||||||
|
testGetIdx(d18, 1, s2);
|
||||||
|
|
||||||
testGetIdxMustThrow(d1, 1);
|
testGetIdxMustThrow(d1, 1);
|
||||||
testGetIdxMustThrow(d2, 1);
|
testGetIdxMustThrow(d2, 1);
|
||||||
@@ -1933,7 +2228,9 @@ void VarTest::testArrayIdxOperator()
|
|||||||
testGetIdxMustThrow(d13, 1);
|
testGetIdxMustThrow(d13, 1);
|
||||||
testGetIdxMustThrow(d14, 1);
|
testGetIdxMustThrow(d14, 1);
|
||||||
testGetIdxMustThrow(d15, 1);
|
testGetIdxMustThrow(d15, 1);
|
||||||
|
testGetIdxMustThrow(d16, 1);
|
||||||
testGetIdxMustThrow(d17, 1);
|
testGetIdxMustThrow(d17, 1);
|
||||||
|
testGetIdxMustThrow(d19, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2533,6 +2830,9 @@ void VarTest::testEmpty()
|
|||||||
#ifdef POCO_LONG_IS_64_BIT
|
#ifdef POCO_LONG_IS_64_BIT
|
||||||
testEmptyComparisons<unsigned long>();
|
testEmptyComparisons<unsigned long>();
|
||||||
testEmptyComparisons<long>();
|
testEmptyComparisons<long>();
|
||||||
|
#else
|
||||||
|
testEmptyComparisons<unsigned long long>();
|
||||||
|
testEmptyComparisons<long long>();
|
||||||
#endif
|
#endif
|
||||||
testEmptyComparisons<float>();
|
testEmptyComparisons<float>();
|
||||||
testEmptyComparisons<double>();
|
testEmptyComparisons<double>();
|
||||||
@@ -2644,6 +2944,8 @@ CppUnit::Test* VarTest::suite()
|
|||||||
CppUnit_addTest(pSuite, VarTest, testDouble);
|
CppUnit_addTest(pSuite, VarTest, testDouble);
|
||||||
CppUnit_addTest(pSuite, VarTest, testLong);
|
CppUnit_addTest(pSuite, VarTest, testLong);
|
||||||
CppUnit_addTest(pSuite, VarTest, testULong);
|
CppUnit_addTest(pSuite, VarTest, testULong);
|
||||||
|
CppUnit_addTest(pSuite, VarTest, testLongLong);
|
||||||
|
CppUnit_addTest(pSuite, VarTest, testULongLong);
|
||||||
CppUnit_addTest(pSuite, VarTest, testString);
|
CppUnit_addTest(pSuite, VarTest, testString);
|
||||||
CppUnit_addTest(pSuite, VarTest, testUDT);
|
CppUnit_addTest(pSuite, VarTest, testUDT);
|
||||||
CppUnit_addTest(pSuite, VarTest, testConversionOperator);
|
CppUnit_addTest(pSuite, VarTest, testConversionOperator);
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public:
|
|||||||
void testDouble();
|
void testDouble();
|
||||||
void testLong();
|
void testLong();
|
||||||
void testULong();
|
void testULong();
|
||||||
|
void testLongLong();
|
||||||
|
void testULongLong();
|
||||||
void testString();
|
void testString();
|
||||||
void testUDT();
|
void testUDT();
|
||||||
void testConversionOperator();
|
void testConversionOperator();
|
||||||
|
|||||||
Reference in New Issue
Block a user