forked from qt-creator/qt-creator
Axivion: Use type aliases from updated Axivion Dashboard DTO generator
Change-Id: I4e27c90d643d4e4ca33fde8dc0ae6e62e6a78fb6 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -150,9 +150,9 @@ void DashboardWidget::updateUi()
|
||||
// not use the issue counts, thus the QtCreator Axivion Plugin
|
||||
// is going to stop using them, too.
|
||||
if (last.issueCounts.isMap()) {
|
||||
for (const auto &issueCount : last.issueCounts.getMap()) {
|
||||
for (const Dto::Any::MapEntry &issueCount : last.issueCounts.getMap()) {
|
||||
if (issueCount.second.isMap()) {
|
||||
const auto &counts = issueCount.second.getMap();
|
||||
const Dto::Any::Map &counts = issueCount.second.getMap();
|
||||
qint64 total = extract_value(counts, QStringLiteral(u"Total"));
|
||||
allTotal += total;
|
||||
qint64 added = extract_value(counts, QStringLiteral(u"Added"));
|
||||
|
@@ -17,7 +17,8 @@
|
||||
#include <utility>
|
||||
|
||||
template<typename Input, typename Output>
|
||||
static Output concat(const std::initializer_list<const Input> &args) {
|
||||
static Output concat(const std::initializer_list<const Input> &args)
|
||||
{
|
||||
size_t size = 0;
|
||||
for (const Input &arg : args)
|
||||
size += arg.size();
|
||||
@@ -28,14 +29,17 @@ static Output concat(const std::initializer_list<const Input> &args) {
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string concat(const std::initializer_list<const std::string_view> &args) {
|
||||
std::string concat(const std::initializer_list<const std::string_view> &args)
|
||||
{
|
||||
return concat<std::string_view, std::string>(args);
|
||||
}
|
||||
|
||||
QString concat(const std::initializer_list<const QStringView> &args) {
|
||||
QString concat(const std::initializer_list<const QStringView> &args)
|
||||
{
|
||||
return concat<QStringView, QString>(args);
|
||||
}
|
||||
|
||||
QByteArray concat_bytes(const std::initializer_list<const QByteArrayView> &args) {
|
||||
QByteArray concat_bytes(const std::initializer_list<const QByteArrayView> &args)
|
||||
{
|
||||
return concat<QByteArrayView, QByteArray>(args);
|
||||
}
|
||||
|
@@ -597,11 +597,11 @@ namespace Axivion::Internal::Dto {
|
||||
}
|
||||
if (json.isObject())
|
||||
{
|
||||
return Any(deserialize_json<std::map<QString, Any>>(json));
|
||||
return Any(deserialize_json<Any::Map>(json));
|
||||
}
|
||||
if (json.isArray())
|
||||
{
|
||||
return Any(deserialize_json<std::vector<Any>>(json));
|
||||
return Any(deserialize_json<Any::Vector>(json));
|
||||
}
|
||||
if (json.isBool())
|
||||
{
|
||||
@@ -657,9 +657,9 @@ namespace Axivion::Internal::Dto {
|
||||
|
||||
Any::Any(double value) : data(std::move(value)) {}
|
||||
|
||||
Any::Any(std::map<QString, Any> value) : data(std::move(value)) {}
|
||||
Any::Any(Map value) : data(std::move(value)) {}
|
||||
|
||||
Any::Any(std::vector<Any> value) : data(std::move(value)) {}
|
||||
Any::Any(Vector value) : data(std::move(value)) {}
|
||||
|
||||
Any::Any(bool value) : data(std::move(value)) {}
|
||||
|
||||
@@ -702,12 +702,12 @@ namespace Axivion::Internal::Dto {
|
||||
return this->data.index() == 3;
|
||||
}
|
||||
|
||||
std::map<QString, Any> &Any::getMap()
|
||||
Any::Map &Any::getMap()
|
||||
{
|
||||
return std::get<3>(this->data);
|
||||
}
|
||||
|
||||
const std::map<QString, Any> &Any::getMap() const
|
||||
const Any::Map &Any::getMap() const
|
||||
{
|
||||
return std::get<3>(this->data);
|
||||
}
|
||||
@@ -717,12 +717,12 @@ namespace Axivion::Internal::Dto {
|
||||
return this->data.index() == 4;
|
||||
}
|
||||
|
||||
std::vector<Any> &Any::getList()
|
||||
Any::Vector &Any::getList()
|
||||
{
|
||||
return std::get<4>(this->data);
|
||||
}
|
||||
|
||||
const std::vector<Any> &Any::getList() const
|
||||
const Any::Vector &Any::getList() const
|
||||
{
|
||||
return std::get<4>(this->data);
|
||||
}
|
||||
|
@@ -62,18 +62,13 @@ namespace Axivion::Internal::Dto
|
||||
virtual ~Serializable() = default;
|
||||
};
|
||||
|
||||
class Any : public Serializable {
|
||||
private:
|
||||
std::variant<
|
||||
std::nullptr_t, // .index() == 0
|
||||
QString, // .index() == 1
|
||||
double, // .index() == 2
|
||||
std::map<QString, Any>, // .index() == 3
|
||||
std::vector<Any>, // .index() == 4
|
||||
bool // .index() == 5
|
||||
> data;
|
||||
|
||||
class Any : public Serializable
|
||||
{
|
||||
public:
|
||||
using Map = std::map<QString, Any>;
|
||||
using MapEntry = std::pair<const QString, Any>;
|
||||
using Vector = std::vector<Any>;
|
||||
|
||||
// Throws Axivion::Internal::Dto::invalid_dto_exception
|
||||
static Any deserialize(const QByteArray &json);
|
||||
|
||||
@@ -83,9 +78,9 @@ namespace Axivion::Internal::Dto
|
||||
|
||||
Any(double value);
|
||||
|
||||
Any(std::map<QString, Any> value);
|
||||
Any(Map value);
|
||||
|
||||
Any(std::vector<Any> value);
|
||||
Any(Vector value);
|
||||
|
||||
Any(bool value);
|
||||
|
||||
@@ -110,18 +105,18 @@ namespace Axivion::Internal::Dto
|
||||
bool isMap() const;
|
||||
|
||||
// Throws std::bad_variant_access
|
||||
std::map<QString, Any> &getMap();
|
||||
Map &getMap();
|
||||
|
||||
// Throws std::bad_variant_access
|
||||
const std::map<QString, Any> &getMap() const;
|
||||
const Map &getMap() const;
|
||||
|
||||
bool isList() const;
|
||||
|
||||
// Throws std::bad_variant_access
|
||||
std::vector<Any> &getList();
|
||||
Vector &getList();
|
||||
|
||||
// Throws std::bad_variant_access
|
||||
const std::vector<Any> &getList() const;
|
||||
const Vector &getList() const;
|
||||
|
||||
bool isBool() const;
|
||||
|
||||
@@ -132,9 +127,20 @@ namespace Axivion::Internal::Dto
|
||||
const bool &getBool() const;
|
||||
|
||||
virtual QByteArray serialize() const override;
|
||||
|
||||
private:
|
||||
std::variant<
|
||||
std::nullptr_t, // .index() == 0
|
||||
QString, // .index() == 1
|
||||
double, // .index() == 2
|
||||
Map, // .index() == 3
|
||||
Vector, // .index() == 4
|
||||
bool // .index() == 5
|
||||
> data;
|
||||
};
|
||||
|
||||
class ApiVersion {
|
||||
class ApiVersion
|
||||
{
|
||||
public:
|
||||
static const std::array<qint32, 4> number;
|
||||
static const QLatin1String string;
|
||||
|
Reference in New Issue
Block a user