#ifndef __SHADOWRUNDB_H__ #define __SHADOWRUNDB_H__ #include #include #include #include #include "json.hpp" #include "utils.hpp" namespace shadowrun { enum class Type { Unknown = 0, Info = 1, Attributes = 2, Skills = 3, Connections = 4, RangedWeapons = 5, MeleeWeapons = 6, Cyberware = 7, Bioware = 8, PositiveQualities = 9, NegativeQualities = 10, Notes = 11, Inventory = 12, KnowledgeSkills = 13, Specializations = 14, }; struct ShadowrunCharacter { int id; std::string name; std::string created_at; // SQLite stores DATETIME as TEXT }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ShadowrunCharacter, id, name, created_at) inline ShadowrunCharacter newShadowrunCharacter(const std::string& name){ return ShadowrunCharacter {-1, name, utils::currentTime()}; } struct ShadowrunCharacterData { int id; int character_id; int type; std::string json; std::string created_at; std::string updated_at; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ShadowrunCharacterData, id, character_id, type, json, created_at, updated_at); inline ShadowrunCharacterData newShadowrunCharacterData(int character_id, Type type, const std::string json){ std::string time = utils::currentTime(); return ShadowrunCharacterData { .id = -1, .character_id = character_id, .type = static_cast(type), .json = json, .created_at = time, .updated_at = time, }; } int64_t createCharacter(const std::string& name); std::vector getCharacters(); std::optional getChracter(int id); std::vector getChracterData(int character_id); int storeCharacterData(const ShadowrunCharacterData& data); int storeCharacterData(int characterId, const Type type, const std::string& json); } #endif // __SHADOWRUNDB_H__