tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
PollOption.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
8 struct PollOption {
9 PollOption() = default;
10 explicit PollOption(const nl::json& json) {
11 fromJson(json);
12 }
13
15 std::string text;
16
18 std::vector<Ptr<MessageEntity>> textEntities;
19
21 std::int32_t voterCount{};
22
25 nl::json toJson() const {
26 nl::json json = nl::json::object();
27 OBJECT_SERIALIZE_FIELD(json, "text", text);
28 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities);
29 OBJECT_SERIALIZE_FIELD(json, "voter_count", voterCount);
30 return json;
31 }
32
34 void fromJson(const nl::json& json) {
35 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
36 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities, true);
37 OBJECT_DESERIALIZE_FIELD(json, "voter_count", voterCount, 0, false);
38 }
39 };
40}
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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:46
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
This object contains information about one answer option in a poll. https://core.telegram....
Definition PollOption.hpp:8
std::vector< Ptr< MessageEntity > > textEntities
Optional. Special entities that appear in the option text. Currently, only custom emoji entities are ...
std::string text
Option text, 1-100 characters.
std::int32_t voterCount
Number of users that voted for this option.
PollOption(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.