2024-01-12 23:39:41 +00:00
|
|
|
//SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
|
|
|
|
//SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#include "asset.h"
|
|
|
|
|
|
|
|
DB::Asset::Asset ():
|
2024-01-22 18:21:55 +00:00
|
|
|
id(0),
|
|
|
|
owner(0),
|
|
|
|
currency(0),
|
2024-01-12 23:39:41 +00:00
|
|
|
title(),
|
|
|
|
icon(),
|
2024-01-22 18:21:55 +00:00
|
|
|
color(0),
|
|
|
|
archived(false)
|
2024-01-12 23:39:41 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
DB::Asset::Asset (const std::vector<std::any>& vec):
|
2024-01-22 18:21:55 +00:00
|
|
|
id(std::any_cast<uint32_t>(vec[0])),
|
|
|
|
owner(std::any_cast<uint32_t>(vec[1])),
|
|
|
|
currency(std::any_cast<uint32_t>(vec[2])),
|
2024-01-12 23:39:41 +00:00
|
|
|
title(std::any_cast<const std::string&>(vec[3])),
|
|
|
|
icon(std::any_cast<const std::string&>(vec[4])),
|
2024-01-22 18:21:55 +00:00
|
|
|
color(std::any_cast<uint32_t>(vec[5])),
|
|
|
|
archived(std::any_cast<uint8_t>(vec[6]))
|
2024-01-12 23:39:41 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
void DB::Asset::parse (const std::vector<std::any>& vec) {
|
2024-01-22 18:21:55 +00:00
|
|
|
id = std::any_cast<uint32_t>(vec[0]);
|
|
|
|
owner = std::any_cast<uint32_t>(vec[1]);
|
|
|
|
currency = std::any_cast<uint32_t>(vec[2]);
|
2024-01-12 23:39:41 +00:00
|
|
|
title = std::any_cast<const std::string&>(vec[3]);
|
|
|
|
icon = std::any_cast<const std::string&>(vec[4]);
|
2024-01-22 18:21:55 +00:00
|
|
|
color = std::any_cast<uint32_t>(vec[5]);
|
|
|
|
archived = std::any_cast<uint8_t>(vec[6]);
|
2024-01-12 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nlohmann::json DB::Asset::toJSON () const {
|
|
|
|
nlohmann::json result = nlohmann::json::object();
|
|
|
|
|
|
|
|
result["id"] = id;
|
|
|
|
//result["owner"] = owner;
|
2024-03-28 23:20:21 +00:00
|
|
|
result["currency"] = currency;
|
2024-01-12 23:39:41 +00:00
|
|
|
result["title"] = title;
|
|
|
|
result["icon"] = icon;
|
2024-01-22 18:21:55 +00:00
|
|
|
result["color"] = color;
|
2024-01-12 23:39:41 +00:00
|
|
|
result["archived"] = archived;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|