back-port JSON and accompanying Foundation portions (JSONString, Dynamic::Var etc)

This commit is contained in:
Alex Fabijanic
2017-09-25 15:15:05 -05:00
parent 741fead666
commit 6efab2cd58
103 changed files with 22184 additions and 29859 deletions

View File

@@ -44,7 +44,7 @@ class Foundation_API Var
///
/// Loss of signedness is not allowed for numeric values. This means that if an attempt is made to convert
/// the internal value which is a negative signed integer to an unsigned integer type storage, a RangeException is thrown.
/// Overflow is not allowed, so if the internal value is a larger number than the target numeric type size can accomodate,
/// Overflow is not allowed, so if the internal value is a larger number than the target numeric type size can accommodate,
/// a RangeException is thrown.
///
/// Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms
@@ -269,16 +269,16 @@ public:
template <typename T>
Var& operator += (const T& other)
/// Addition asignment operator for addition/assignment of POD to Var.
/// Addition assignment operator for addition/assignment of POD to Var.
{
return *this = convert<T>() + other;
}
Var& operator += (const Var& other);
/// Addition asignment operator overload for Var
/// Addition assignment operator overload for Var
Var& operator += (const char* other);
/// Addition asignment operator overload for const char*
/// Addition assignment operator overload for const char*
template <typename T>
const Var operator - (const T& other) const
@@ -292,13 +292,13 @@ public:
template <typename T>
Var& operator -= (const T& other)
/// Subtraction asignment operator
/// Subtraction assignment operator
{
return *this = convert<T>() - other;
}
Var& operator -= (const Var& other);
/// Subtraction asignment operator overload for Var
/// Subtraction assignment operator overload for Var
template <typename T>
const Var operator * (const T& other) const
@@ -312,13 +312,13 @@ public:
template <typename T>
Var& operator *= (const T& other)
/// Multiplication asignment operator
/// Multiplication assignment operator
{
return *this = convert<T>() * other;
}
Var& operator *= (const Var& other);
/// Multiplication asignment operator overload for Var
/// Multiplication assignment operator overload for Var
template <typename T>
const Var operator / (const T& other) const
@@ -332,13 +332,13 @@ public:
template <typename T>
Var& operator /= (const T& other)
/// Division asignment operator
/// Division assignment operator
{
return *this = convert<T>() / other;
}
Var& operator /= (const Var& other);
/// Division asignment operator specialization for Var
/// Division assignment operator specialization for Var
template <typename T>
bool operator == (const T& other) const
@@ -435,7 +435,7 @@ public:
/// Logical AND operator operator overload for Var.
bool isArray() const;
/// Returns true if Var is not empty.
/// Returns true if Var is an array.
bool isVector() const;
/// Returns true if Var represents a vector.
@@ -477,8 +477,14 @@ public:
const std::type_info& type() const;
/// Returns the type information of the stored content.
//@ deprecated
void empty();
/// Empties Var.
/// This function is deprecated and will be removed.
/// Please use clear().
void clear();
/// Empties Var.
bool isEmpty() const;
/// Returns true if empty.
@@ -500,6 +506,15 @@ public:
bool isString() const;
/// Returns true if stored value is std::string.
bool isDate() const;
/// Returns true if stored value represents a date.
bool isTime() const;
/// Returns true if stored value represents time or date/time.
bool isDateTime() const;
/// Returns true if stored value represents a date/time.
std::size_t size() const;
/// Returns the size of this Var.
/// This function returns 0 when Var is empty, 1 for POD or the size (i.e. length)
@@ -842,6 +857,27 @@ inline bool Var::isString() const
}
inline bool Var::isDate() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDate() : false;
}
inline bool Var::isTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isTime() : false;
}
inline bool Var::isDateTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDateTime() : false;
}
inline std::size_t Var::size() const
{
VarHolder* pHolder = content();
@@ -890,28 +926,28 @@ inline char operator / (const char& other, const Var& da)
inline char operator += (char& other, const Var& da)
/// Addition asignment operator for adding Var to char
/// Addition assignment operator for adding Var to char
{
return other += da.convert<char>();
}
inline char operator -= (char& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from char
/// Subtraction assignment operator for subtracting Var from char
{
return other -= da.convert<char>();
}
inline char operator *= (char& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with char
/// Multiplication assignment operator for multiplying Var with char
{
return other *= da.convert<char>();
}
inline char operator /= (char& other, const Var& da)
/// Division asignment operator for dividing Var with char
/// Division assignment operator for dividing Var with char
{
return other /= da.convert<char>();
}
@@ -994,28 +1030,28 @@ inline Poco::Int8 operator / (const Poco::Int8& other, const Var& da)
inline Poco::Int8 operator += (Poco::Int8& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::Int8
/// Addition assignment operator for adding Var to Poco::Int8
{
return other += da.convert<Poco::Int8>();
}
inline Poco::Int8 operator -= (Poco::Int8& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::Int8
/// Subtraction assignment operator for subtracting Var from Poco::Int8
{
return other -= da.convert<Poco::Int8>();
}
inline Poco::Int8 operator *= (Poco::Int8& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::Int8
/// Multiplication assignment operator for multiplying Var with Poco::Int8
{
return other *= da.convert<Poco::Int8>();
}
inline Poco::Int8 operator /= (Poco::Int8& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::Int8
/// Division assignment operator for dividing Var with Poco::Int8
{
return other /= da.convert<Poco::Int8>();
}
@@ -1098,28 +1134,28 @@ inline Poco::UInt8 operator / (const Poco::UInt8& other, const Var& da)
inline Poco::UInt8 operator += (Poco::UInt8& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::UInt8
/// Addition assignment operator for adding Var to Poco::UInt8
{
return other += da.convert<Poco::UInt8>();
}
inline Poco::UInt8 operator -= (Poco::UInt8& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::UInt8
/// Subtraction assignment operator for subtracting Var from Poco::UInt8
{
return other -= da.convert<Poco::UInt8>();
}
inline Poco::UInt8 operator *= (Poco::UInt8& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::UInt8
/// Multiplication assignment operator for multiplying Var with Poco::UInt8
{
return other *= da.convert<Poco::UInt8>();
}
inline Poco::UInt8 operator /= (Poco::UInt8& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::UInt8
/// Division assignment operator for dividing Var with Poco::UInt8
{
return other /= da.convert<Poco::UInt8>();
}
@@ -1202,28 +1238,28 @@ inline Poco::Int16 operator / (const Poco::Int16& other, const Var& da)
inline Poco::Int16 operator += (Poco::Int16& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::Int16
/// Addition assignment operator for adding Var to Poco::Int16
{
return other += da.convert<Poco::Int16>();
}
inline Poco::Int16 operator -= (Poco::Int16& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::Int16
/// Subtraction assignment operator for subtracting Var from Poco::Int16
{
return other -= da.convert<Poco::Int16>();
}
inline Poco::Int16 operator *= (Poco::Int16& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::Int16
/// Multiplication assignment operator for multiplying Var with Poco::Int16
{
return other *= da.convert<Poco::Int16>();
}
inline Poco::Int16 operator /= (Poco::Int16& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::Int16
/// Division assignment operator for dividing Var with Poco::Int16
{
return other /= da.convert<Poco::Int16>();
}
@@ -1306,28 +1342,28 @@ inline Poco::UInt16 operator / (const Poco::UInt16& other, const Var& da)
inline Poco::UInt16 operator += (Poco::UInt16& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::UInt16
/// Addition assignment operator for adding Var to Poco::UInt16
{
return other += da.convert<Poco::UInt16>();
}
inline Poco::UInt16 operator -= (Poco::UInt16& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::UInt16
/// Subtraction assignment operator for subtracting Var from Poco::UInt16
{
return other -= da.convert<Poco::UInt16>();
}
inline Poco::UInt16 operator *= (Poco::UInt16& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::UInt16
/// Multiplication assignment operator for multiplying Var with Poco::UInt16
{
return other *= da.convert<Poco::UInt16>();
}
inline Poco::UInt16 operator /= (Poco::UInt16& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::UInt16
/// Division assignment operator for dividing Var with Poco::UInt16
{
return other /= da.convert<Poco::UInt16>();
}
@@ -1410,28 +1446,28 @@ inline Poco::Int32 operator / (const Poco::Int32& other, const Var& da)
inline Poco::Int32 operator += (Poco::Int32& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::Int32
/// Addition assignment operator for adding Var to Poco::Int32
{
return other += da.convert<Poco::Int32>();
}
inline Poco::Int32 operator -= (Poco::Int32& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::Int32
/// Subtraction assignment operator for subtracting Var from Poco::Int32
{
return other -= da.convert<Poco::Int32>();
}
inline Poco::Int32 operator *= (Poco::Int32& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::Int32
/// Multiplication assignment operator for multiplying Var with Poco::Int32
{
return other *= da.convert<Poco::Int32>();
}
inline Poco::Int32 operator /= (Poco::Int32& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::Int32
/// Division assignment operator for dividing Var with Poco::Int32
{
return other /= da.convert<Poco::Int32>();
}
@@ -1514,28 +1550,28 @@ inline Poco::UInt32 operator / (const Poco::UInt32& other, const Var& da)
inline Poco::UInt32 operator += (Poco::UInt32& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::UInt32
/// Addition assignment operator for adding Var to Poco::UInt32
{
return other += da.convert<Poco::UInt32>();
}
inline Poco::UInt32 operator -= (Poco::UInt32& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::UInt32
/// Subtraction assignment operator for subtracting Var from Poco::UInt32
{
return other -= da.convert<Poco::UInt32>();
}
inline Poco::UInt32 operator *= (Poco::UInt32& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::UInt32
/// Multiplication assignment operator for multiplying Var with Poco::UInt32
{
return other *= da.convert<Poco::UInt32>();
}
inline Poco::UInt32 operator /= (Poco::UInt32& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::UInt32
/// Division assignment operator for dividing Var with Poco::UInt32
{
return other /= da.convert<Poco::UInt32>();
}
@@ -1618,28 +1654,28 @@ inline Poco::Int64 operator / (const Poco::Int64& other, const Var& da)
inline Poco::Int64 operator += (Poco::Int64& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::Int64
/// Addition assignment operator for adding Var to Poco::Int64
{
return other += da.convert<Poco::Int64>();
}
inline Poco::Int64 operator -= (Poco::Int64& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::Int64
/// Subtraction assignment operator for subtracting Var from Poco::Int64
{
return other -= da.convert<Poco::Int64>();
}
inline Poco::Int64 operator *= (Poco::Int64& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::Int64
/// Multiplication assignment operator for multiplying Var with Poco::Int64
{
return other *= da.convert<Poco::Int64>();
}
inline Poco::Int64 operator /= (Poco::Int64& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::Int64
/// Division assignment operator for dividing Var with Poco::Int64
{
return other /= da.convert<Poco::Int64>();
}
@@ -1722,28 +1758,28 @@ inline Poco::UInt64 operator / (const Poco::UInt64& other, const Var& da)
inline Poco::UInt64 operator += (Poco::UInt64& other, const Var& da)
/// Addition asignment operator for adding Var to Poco::UInt64
/// Addition assignment operator for adding Var to Poco::UInt64
{
return other += da.convert<Poco::UInt64>();
}
inline Poco::UInt64 operator -= (Poco::UInt64& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from Poco::UInt64
/// Subtraction assignment operator for subtracting Var from Poco::UInt64
{
return other -= da.convert<Poco::UInt64>();
}
inline Poco::UInt64 operator *= (Poco::UInt64& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with Poco::UInt64
/// Multiplication assignment operator for multiplying Var with Poco::UInt64
{
return other *= da.convert<Poco::UInt64>();
}
inline Poco::UInt64 operator /= (Poco::UInt64& other, const Var& da)
/// Division asignment operator for dividing Var with Poco::UInt64
/// Division assignment operator for dividing Var with Poco::UInt64
{
return other /= da.convert<Poco::UInt64>();
}
@@ -1826,28 +1862,28 @@ inline float operator / (const float& other, const Var& da)
inline float operator += (float& other, const Var& da)
/// Addition asignment operator for adding Var to float
/// Addition assignment operator for adding Var to float
{
return other += da.convert<float>();
}
inline float operator -= (float& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from float
/// Subtraction assignment operator for subtracting Var from float
{
return other -= da.convert<float>();
}
inline float operator *= (float& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with float
/// Multiplication assignment operator for multiplying Var with float
{
return other *= da.convert<float>();
}
inline float operator /= (float& other, const Var& da)
/// Division asignment operator for dividing Var with float
/// Division assignment operator for dividing Var with float
{
return other /= da.convert<float>();
}
@@ -1930,28 +1966,28 @@ inline double operator / (const double& other, const Var& da)
inline double operator += (double& other, const Var& da)
/// Addition asignment operator for adding Var to double
/// Addition assignment operator for adding Var to double
{
return other += da.convert<double>();
}
inline double operator -= (double& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from double
/// Subtraction assignment operator for subtracting Var from double
{
return other -= da.convert<double>();
}
inline double operator *= (double& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with double
/// Multiplication assignment operator for multiplying Var with double
{
return other *= da.convert<double>();
}
inline double operator /= (double& other, const Var& da)
/// Division asignment operator for dividing Var with double
/// Division assignment operator for dividing Var with double
{
return other /= da.convert<double>();
}
@@ -2101,28 +2137,28 @@ inline long operator / (const long& other, const Var& da)
inline long operator += (long& other, const Var& da)
/// Addition asignment operator for adding Var to long
/// Addition assignment operator for adding Var to long
{
return other += da.convert<long>();
}
inline long operator -= (long& other, const Var& da)
/// Subtraction asignment operator for subtracting Var from long
/// Subtraction assignment operator for subtracting Var from long
{
return other -= da.convert<long>();
}
inline long operator *= (long& other, const Var& da)
/// Multiplication asignment operator for multiplying Var with long
/// Multiplication assignment operator for multiplying Var with long
{
return other *= da.convert<long>();
}
inline long operator /= (long& other, const Var& da)
/// Division asignment operator for dividing Var with long
/// Division assignment operator for dividing Var with long
{
return other /= da.convert<long>();
}