mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
Added operator for QFlags
This commit is contained in:
@@ -77,6 +77,15 @@ std::enable_if_t<std::is_enum<ENUM>::value, QJsonObject>
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Specialized JSON serialization for QFlags generated enum
|
||||||
|
//! \ingroup JSON
|
||||||
|
template<class ENUM>
|
||||||
|
QJsonObject &operator<<(QJsonObject &json, std::pair<QString, const QFlags<ENUM> &> value)
|
||||||
|
{
|
||||||
|
json.insert(value.first, QJsonValue(static_cast<int>(value.second)));
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief Specialized JSON deserialization for enum
|
//! \brief Specialized JSON deserialization for enum
|
||||||
//! \ingroup JSON
|
//! \ingroup JSON
|
||||||
template<class ENUM>
|
template<class ENUM>
|
||||||
@@ -87,6 +96,15 @@ const &operator>>(const QJsonValue &json, ENUM &value)
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Specialized JSON deserialization for QFlags enum
|
||||||
|
//! \ingroup JSON
|
||||||
|
template<class ENUM>
|
||||||
|
const QJsonValue &operator>>(const QJsonValue &json, QFlags<ENUM> &value)
|
||||||
|
{
|
||||||
|
value = static_cast<QFlags<ENUM>>(json.toInt());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief Specialized JSON deserialization for enum
|
//! \brief Specialized JSON deserialization for enum
|
||||||
//! \ingroup JSON
|
//! \ingroup JSON
|
||||||
template<class ENUM>
|
template<class ENUM>
|
||||||
@@ -97,6 +115,15 @@ const &operator>>(const QJsonValueRef &json, ENUM &value)
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Specialized JSON deserialization for QFlags enum
|
||||||
|
//! \ingroup JSON
|
||||||
|
template<class ENUM>
|
||||||
|
const QJsonValueRef &operator>>(const QJsonValueRef &json, QFlags<ENUM> &value)
|
||||||
|
{
|
||||||
|
value = static_cast<QFlags<ENUM>>(json.toInt());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief Specialized JSON deserialization for pair
|
//! \brief Specialized JSON deserialization for pair
|
||||||
//! \ingroup JSON
|
//! \ingroup JSON
|
||||||
template<class FIRST, class SECOND>
|
template<class FIRST, class SECOND>
|
||||||
|
|||||||
Reference in New Issue
Block a user