tgbotxx  1.1.6.9
Telegram Bot C++ Library
GameHighScore.hpp
Go to the documentation of this file.
1 #pragma once
4 
5 namespace tgbotxx {
8  struct GameHighScore {
9  GameHighScore() = default;
10  explicit GameHighScore(const nl::json& json) {
11  fromJson(json);
12  }
13 
15  std::int32_t position{};
16 
19 
21  std::int32_t score{};
22 
23 
26  nl::json toJson() const {
27  nl::json json = nl::json::object();
28  OBJECT_SERIALIZE_FIELD(json, "position", position);
29  OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
30  OBJECT_SERIALIZE_FIELD(json, "score", score);
31  return json;
32  }
33 
35  void fromJson(const nl::json& json) {
36  OBJECT_DESERIALIZE_FIELD(json, "position", position, 0, false);
37  OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
38  OBJECT_DESERIALIZE_FIELD(json, "score", score, 0, false);
39  }
40  };
41 }
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition: Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition: Object.hpp:70
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition: Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition: Object.hpp:44
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
This object represents one row of the high scores table for a game. https://core.telegram....
std::int32_t score
Score.
nl::json toJson() const
Serializes this object to JSON.
Ptr< User > user
User.
std::int32_t position
Position in high score table for the game.
GameHighScore(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.