pica/database/schema/asset.cpp

45 lines
1.2 KiB
C++

//SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#include "asset.h"
DB::Asset::Asset ():
id(),
owner(),
currency(),
title(),
icon(),
archived()
{}
DB::Asset::Asset (const std::vector<std::any>& vec):
id(std::any_cast<unsigned int>(vec[0])),
owner(std::any_cast<unsigned int>(vec[1])),
currency(std::any_cast<unsigned int>(vec[2])),
title(std::any_cast<const std::string&>(vec[3])),
icon(std::any_cast<const std::string&>(vec[4])),
archived(std::any_cast<uint8_t>(vec[5]))
{}
void DB::Asset::parse (const std::vector<std::any>& vec) {
id = std::any_cast<unsigned int>(vec[0]);
owner = std::any_cast<unsigned int>(vec[1]);
currency = std::any_cast<unsigned int>(vec[2]);
title = std::any_cast<const std::string&>(vec[3]);
icon = std::any_cast<const std::string&>(vec[4]);
archived = std::any_cast<uint8_t>(vec[5]);
}
nlohmann::json DB::Asset::toJSON () const {
nlohmann::json result = nlohmann::json::object();
result["id"] = id;
//result["owner"] = owner;
//result["currency"] = currency;
result["title"] = title;
result["icon"] = icon;
result["archived"] = archived;
return result;
}