aegis.cpp
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
asset.hpp
1 //
2 // asset.hpp
3 // *********
4 //
5 // Copyright (c) 2019 Sharon W (sharon at aegis dot gg)
6 //
7 // Distributed under the MIT License. (See accompanying file LICENSE)
8 //
9 
10 #pragma once
11 
12 #include "aegis/config.hpp"
13 #include <nlohmann/json.hpp>
14 
15 namespace aegis
16 {
17 
18 namespace gateway
19 {
20 
21 namespace objects
22 {
23 
26 struct asset
27 {
28  std::string large_image;
29  std::string large_text;
30  std::string small_image;
31  std::string small_text;
32 };
33 
35 inline void from_json(const nlohmann::json& j, asset& m)
36 {
37  if (j.count("large_image") && !j["large_image"].is_null())
38  m.large_image = j["large_image"].get<std::string>();
39  if (j.count("large_text") && !j["large_text"].is_null())
40  m.large_text = j["large_text"].get<std::string>();
41  if (j.count("small_image") && !j["small_image"].is_null())
42  m.small_image = j["small_image"].get<std::string>();
43  if (j.count("small_text") && !j["small_text"].is_null())
44  m.small_text = j["small_text"].get<std::string>();
45 }
46 
47 inline void to_json(nlohmann::json& j, const asset& m)
48 {
49  if (!m.large_image.empty())
50  j["large_image"] = m.large_image;
51  if (!m.large_text.empty())
52  j["large_text"] = m.large_text;
53  if (!m.small_image.empty())
54  j["small_image"] = m.small_image;
55  if (!m.small_text.empty())
56  j["small_text"] = m.small_text;
57 }
59 
60 }
61 
62 }
63 
64 }
Definition: asset.hpp:26