XJ music engine  1.9.6
In-game runtime engine for XJ music.
Template.h
Go to the documentation of this file.
1 // Copyright (c) XJ Music Inc. (https://xjmusic.com) All Rights Reserved.
2 
3 #ifndef XJMUSIC_TEMPLATE_H
4 #define XJMUSIC_TEMPLATE_H
5 
6 #include <string>
7 
8 #include "ContentEntity.h"
9 #include "TemplateConfig.h"
11 
12 namespace XJ {
13 
14  class Template : public ContentEntity {
15  public:
16 
17  Template() = default;
18 
20  std::string name;
22  std::string shipKey;
23  bool isDeleted{false};
25  };
26 
32  inline void from_json(const json &json, Template &entity) {
33  EntityUtils::setRequired(json, "id", entity.id);
34  EntityUtils::setRequired(json, "projectId", entity.projectId);
35  EntityUtils::setIfNotNull(json, "name", entity.name);
36  EntityUtils::setIfNotNull(json, "shipKey", entity.shipKey);
37  EntityUtils::setIfNotNull(json, "isDeleted", entity.isDeleted);
38  EntityUtils::setIfNotNull(json, "updatedAt", entity.updatedAt);
39 
40  if (json.contains("config") && json.at("config").is_string()) {
41  const auto configStr = json.at("config").get<std::string>();
42  entity.config = TemplateConfig(configStr);
43  }
44  }
45 
46 }// namespace XJ
47 
48 #endif//XJMUSIC_TEMPLATE_H
nlohmann::json json
Definition: EntityUtils.h:14
Definition: ContentEntity.h:12
UUID id
Definition: ContentEntity.h:17
static long long currentTimeMillis()
Definition: EntityUtils.h:62
static void setIfNotNull(const json &json, const std::string &key, std::string &value)
Definition: EntityUtils.cpp:27
static void setRequired(const json &json, const std::string &key, UUID &value)
Definition: EntityUtils.cpp:16
Definition: TemplateConfig.h:16
Definition: Template.h:14
long long updatedAt
Definition: Template.h:24
std::string name
Definition: Template.h:20
TemplateConfig config
Definition: Template.h:21
std::string shipKey
Definition: Template.h:22
UUID projectId
Definition: Template.h:19
Template()=default
bool isDeleted
Definition: Template.h:23
Definition: ActiveAudio.h:11
std::string UUID
Definition: EntityUtils.h:28
void from_json(const json &json, Instrument &entity)
Definition: Instrument.h:106