Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
audio.hpp
1 #ifndef CPPGRAM_AUDIO_HPP
2 #define CPPGRAM_AUDIO_HPP
3 
4 #include <experimental/optional>
5 #include <string>
6 
7 #include <json/json.h>
8 
9 namespace cppgram
10 {
11 namespace types
12 {
20 class Audio
21 {
24  public:
26  std::string file_id;
27 
29  uint_fast32_t duration;
30 
32  std::experimental::optional<std::string> performer,
33 
35  title,
36 
38  mime_type;
39 
41  std::experimental::optional<uint_fast32_t> file_size;
42 
43  Audio( Json::Value &json_audio )
44  : file_id( json_audio["file_id"].asString() )
45  , duration( json_audio["duration"].asUInt() )
46  {
47  if ( !json_audio["performer"].isNull() )
48  {
49  performer.emplace( json_audio["performer"].asString() );
50  }
51 
52  if ( !json_audio["title"].isNull() )
53  {
54  title.emplace( json_audio["title"].asString() );
55  }
56 
57  if ( !json_audio["mime_type"].isNull() )
58  {
59  mime_type.emplace( json_audio["mime_type"].asString() );
60  }
61 
62  if ( !json_audio["file_size"].isNull() )
63  {
64  file_size.emplace( json_audio["file_size"].asUInt() );
65  }
66  };
67 };
68 }
69 }
70 
71 #endif
std::experimental::optional< std::string > mime_type
Optional. MIME type of the file as defined by sender
Definition: audio.hpp:32
uint_fast32_t duration
Duration of the audio in seconds as defined by sender.
Definition: audio.hpp:29
std::experimental::optional< std::string > title
Optional. Title of the audio as defined by sender or by audio tags
Definition: audio.hpp:32
std::experimental::optional< uint_fast32_t > file_size
Optional. File size
Definition: audio.hpp:41
main namespace for Cppgram
std::experimental::optional< std::string > performer
Optional. Performer of the audio as defined by sender or by audio tags
Definition: audio.hpp:32
std::string file_id
Unique identifier for this file.
Definition: audio.hpp:26
Audio message sent by a user.
Definition: audio.hpp:20