summaryrefslogtreecommitdiffstats
path: root/src/qjsonvalue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qjsonvalue.cpp')
-rw-r--r--src/qjsonvalue.cpp53
1 files changed, 20 insertions, 33 deletions
diff --git a/src/qjsonvalue.cpp b/src/qjsonvalue.cpp
index 803f4fa..f20221e 100644
--- a/src/qjsonvalue.cpp
+++ b/src/qjsonvalue.cpp
@@ -68,7 +68,7 @@ static const Private::Base emptyObject = { { qToLittleEndian(sizeof(Private::Bas
\list
\o bool QJsonValue::Bool
- \o double QJsonValue::Number
+ \o double QJsonValue::Double
\o string QJsonValue::String
\o array QJsonValue::Array
\o object QJsonValue::Object
@@ -111,8 +111,8 @@ QJsonValue::QJsonValue(Private::Data *data, Private::Base *base, const Private::
case Bool:
b = v.toBoolean();
break;
- case Number:
- dbl = v.toNumber(base);
+ case Double:
+ dbl = v.toDouble(base);
break;
case String: {
QString s = v.toString(base);
@@ -140,20 +140,20 @@ QJsonValue::QJsonValue(bool b)
}
/*!
- Creates a value of type Number, with value \a n.
+ Creates a value of type Double, with value \a n.
*/
QJsonValue::QJsonValue(double n)
- : t(Number), d(0)
+ : t(Double), d(0)
{
this->dbl = n;
}
/*!
\overload
- Creates a value of type Number, with value \a n.
+ Creates a value of type Double, with value \a n.
*/
QJsonValue::QJsonValue(int n)
- : t(Number), d(0)
+ : t(Double), d(0)
{
this->dbl = n;
}
@@ -270,7 +270,7 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other)
\o QVariant::Double
\o QVariant::LongLong
\o QVariant::ULongLong
- \o QVariant::UInt to Number
+ \o QVariant::UInt to Double
\o QVariant::String to String
\o QVariant::StringList
\o QVariant::VariantList to Array
@@ -288,7 +288,6 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
case QVariant::Bool:
return QJsonValue(variant.toBool());
case QVariant::Int:
- return QJsonValue(variant.toInt());
case QVariant::Double:
case QVariant::LongLong:
case QVariant::ULongLong:
@@ -318,7 +317,7 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
\value Null QVariant()
\value Bool QVariant::Bool
- \value Number QVariant::Double
+ \value Double QVariant::Double
\value String QVariant::String
\value Array QVariantList
\value Object QVariantMap
@@ -331,7 +330,7 @@ QVariant QJsonValue::toVariant() const
switch (t) {
case Bool:
return b;
- case Number:
+ case Double:
return dbl;
case String:
return toString();
@@ -353,7 +352,7 @@ QVariant QJsonValue::toVariant() const
\value Null A Null value
\value Bool A boolean value. Use toBool() to convert to a bool.
- \value Number A number. Use toNumber() to convert to a double.
+ \value Double A double. Use toDouble() to convert to a double.
\value String A string. Use toString() to convert to a QString.
\value Array An array. Use toArray() to convert to a QJsonArray.
\value Object An object. Use toObject() to convert to a QJsonObject.
@@ -387,28 +386,16 @@ bool QJsonValue::toBool() const
/*!
Converts the value to a double and returns it.
- If type() is not Number, 0. will be returned.
+ If type() is not Double, 0. will be returned.
*/
-double QJsonValue::toNumber() const
+double QJsonValue::toDouble() const
{
- if (t != Number)
+ if (t != Double)
return 0;
return dbl;
}
/*!
- Converts the value to an int and returns it.
-
- If type() is not Number, 0. will be returned.
- */
-int QJsonValue::toInt() const
-{
- if (t != Number)
- return 0;
- return (int)dbl;
-}
-
-/*!
Converts the value to a QString and returns it.
If type() is not String, a QString() will be returned.
@@ -461,7 +448,7 @@ bool QJsonValue::operator==(const QJsonValue &other) const
break;
case Bool:
return b == other.b;
- case Number:
+ case Double:
return dbl == other.dbl;
case String:
return toString() == other.toString();
@@ -504,7 +491,7 @@ int QJsonValue::requiredStorage(bool *compressed) const
{
*compressed = false;
switch (t) {
- case Number:
+ case Double:
if (Private::compressedNumber(dbl) != INT_MAX) {
*compressed = true;
return 0;
@@ -537,7 +524,7 @@ uint QJsonValue::valueToStore(uint offset) const
break;
case Bool:
return b;
- case Number: {
+ case Double: {
int c = Private::compressedNumber(dbl);
if (c != INT_MAX)
return c;
@@ -556,7 +543,7 @@ uint QJsonValue::valueToStore(uint offset) const
void QJsonValue::copyData(char *dest, bool compressed) const
{
switch (t) {
- case Number:
+ case Double:
if (!compressed) {
*((quint64 *)dest) = qToLittleEndian(ui);
}
@@ -646,8 +633,8 @@ QDebug operator<<(QDebug dbg, const QtJson::QJsonValue &o)
case QtJson::QJsonValue::Bool:
dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ")";
break;
- case QtJson::QJsonValue::Number:
- dbg.nospace() << "QJsonValue(number, " << o.toNumber() << ")";
+ case QtJson::QJsonValue::Double:
+ dbg.nospace() << "QJsonValue(double, " << o.toDouble() << ")";
break;
case QtJson::QJsonValue::String:
dbg.nospace() << "QJsonValue(string, " << o.toString() << ")";