mirror of
https://github.com/sebastiandine/Card-Collection-Manager-3.git
synced 2026-09-04 01:03:27 +00:00
major: initial release
* initial development * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * pipeline * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * ci/cd * pokemon * pokemon * pokemon * pokemon * pokemon * pokemon * improvements * improvements * ci/cd * ci/cd * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements * improvements --------- Co-authored-by: sdine <sdine@sdine.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
// Configuration: matches the persisted `config.json` schema used by this app.
|
||||
//
|
||||
// { "dataStorage": "/abs/path", "defaultGame": "Magic" }
|
||||
|
||||
#include "ccm/domain/Enums.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
struct Configuration {
|
||||
std::string dataStorage;
|
||||
Game defaultGame{Game::Magic};
|
||||
Theme theme{Theme::Light};
|
||||
|
||||
friend bool operator==(const Configuration&, const Configuration&) = default;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& j, const Configuration& c);
|
||||
void from_json(const nlohmann::json& j, Configuration& c);
|
||||
|
||||
} // namespace ccm
|
||||
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
// Game / Language / Condition enums.
|
||||
//
|
||||
// String spellings are kept identical to the established Rust serde defaults
|
||||
// (e.g. `NearMint`, `LightPlayed`, `Magic`, `Pokemon`) so existing JSON files
|
||||
// remain interchangeable.
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
enum class Game {
|
||||
Magic,
|
||||
Pokemon,
|
||||
};
|
||||
|
||||
enum class Language {
|
||||
English,
|
||||
German,
|
||||
French,
|
||||
Spanish,
|
||||
Italian,
|
||||
Chinese,
|
||||
Japanese,
|
||||
Russian,
|
||||
};
|
||||
|
||||
enum class Condition {
|
||||
Mint,
|
||||
NearMint,
|
||||
Excellent,
|
||||
Good,
|
||||
LightPlayed,
|
||||
Played,
|
||||
Poor,
|
||||
};
|
||||
|
||||
enum class Theme {
|
||||
Light,
|
||||
Dark,
|
||||
};
|
||||
|
||||
std::string_view to_string(Game g) noexcept;
|
||||
std::string_view to_string(Language l) noexcept;
|
||||
std::string_view to_string(Condition c) noexcept;
|
||||
std::string_view to_string(Theme t) noexcept;
|
||||
|
||||
std::optional<Game> gameFromString(std::string_view s) noexcept;
|
||||
std::optional<Language> languageFromString(std::string_view s) noexcept;
|
||||
std::optional<Condition> conditionFromString(std::string_view s) noexcept;
|
||||
std::optional<Theme> themeFromString(std::string_view s) noexcept;
|
||||
|
||||
const std::array<Game, 2>& allGames() noexcept;
|
||||
const std::array<Language, 8>& allLanguages() noexcept;
|
||||
const std::array<Condition, 7>& allConditions() noexcept;
|
||||
const std::array<Theme, 2>& allThemes() noexcept;
|
||||
|
||||
// nlohmann/json hooks - serialize as plain strings, matching Rust serde.
|
||||
void to_json(nlohmann::json& j, Game v);
|
||||
void from_json(const nlohmann::json& j, Game& v);
|
||||
|
||||
void to_json(nlohmann::json& j, Language v);
|
||||
void from_json(const nlohmann::json& j, Language& v);
|
||||
|
||||
void to_json(nlohmann::json& j, Condition v);
|
||||
void from_json(const nlohmann::json& j, Condition& v);
|
||||
|
||||
void to_json(nlohmann::json& j, Theme v);
|
||||
void from_json(const nlohmann::json& j, Theme& v);
|
||||
|
||||
} // namespace ccm
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
// MagicCard - faithful port of magic/card_services.rs::Card.
|
||||
// JSON layout remains stable so collection.json files stay interchangeable.
|
||||
|
||||
#include "ccm/domain/Enums.hpp"
|
||||
#include "ccm/domain/Set.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
struct MagicCard {
|
||||
std::uint32_t id{0};
|
||||
std::uint8_t amount{1};
|
||||
std::string name;
|
||||
Set set;
|
||||
std::string note;
|
||||
std::vector<std::string> images;
|
||||
Language language{Language::English};
|
||||
Condition condition{Condition::NearMint};
|
||||
bool foil{false};
|
||||
bool signed_{false}; // `signed` is a reserved keyword
|
||||
bool altered{false};
|
||||
|
||||
friend bool operator==(const MagicCard&, const MagicCard&) = default;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& j, const MagicCard& c);
|
||||
void from_json(const nlohmann::json& j, MagicCard& c);
|
||||
|
||||
} // namespace ccm
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
// PokemonCard - faithful port of pokemon/card_services.rs::Card.
|
||||
// Same established JSON shape (with `setNo` and `firstEdition` aliases).
|
||||
|
||||
#include "ccm/domain/Enums.hpp"
|
||||
#include "ccm/domain/Set.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
struct PokemonCard {
|
||||
std::uint32_t id{0};
|
||||
std::uint8_t amount{1};
|
||||
std::string name;
|
||||
Set set;
|
||||
std::string setNo;
|
||||
std::string note;
|
||||
std::vector<std::string> images;
|
||||
Language language{Language::English};
|
||||
Condition condition{Condition::NearMint};
|
||||
bool firstEdition{false};
|
||||
bool holo{false};
|
||||
bool signed_{false};
|
||||
bool altered{false};
|
||||
|
||||
friend bool operator==(const PokemonCard&, const PokemonCard&) = default;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& j, const PokemonCard& c);
|
||||
void from_json(const nlohmann::json& j, PokemonCard& c);
|
||||
|
||||
} // namespace ccm
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// Set: identifier of a printing run shared by both supported games.
|
||||
// JSON shape matches the original Rust Set struct exactly:
|
||||
// { "id": "...", "name": "...", "releaseDate": "YYYY/MM/DD" }
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ccm {
|
||||
|
||||
struct Set {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string releaseDate; // formatted as "YYYY/MM/DD"
|
||||
|
||||
friend bool operator==(const Set&, const Set&) = default;
|
||||
};
|
||||
|
||||
void to_json(nlohmann::json& j, const Set& s);
|
||||
void from_json(const nlohmann::json& j, Set& s);
|
||||
|
||||
} // namespace ccm
|
||||
Reference in New Issue
Block a user