yatbcpp  0.0.1
Yet another Telegram Bot CPP Library
MessageEntity.cc
Go to the documentation of this file.
1 //
2 // Created by norbert on 23.08.17.
3 //
4 
5 #include <optional>
7 #include "types/MessageEntity.h"
8 
9 using namespace yatbcpp;
10 using namespace std;
11 
13 // Constructor Section //
15 
16 MessageEntity::MessageEntity(std::string type, int32_t offset, int32_t length):
17  type(type), offset(offset), length(length)
18 {
19 
20  if(type.compare("mention")){}
21  else if(type.compare("hashtag")){}
22  else if(type.compare("bot_command")){}
23  else if(type.compare("url")){}
24  else if(type.compare("email")){}
25  else if(type.compare("bold")){}
26  else if(type.compare("italic")){}
27  else if(type.compare("code")){}
28  else if(type.compare("pre")){}
29  else if(type.compare("text_link")){}
30  else if(type.compare("text_mention")){}
31  else{
32  throw essential_key_missing("MessageEntity::type <"+type+"> is not a type which was wished for");//TODO enum
33  }
34 
35 
36 }
37 
39  type(MessageEntity.type), offset(MessageEntity.offset), length(MessageEntity.length)
40 {
41  url = MessageEntity.url;
42  user = MessageEntity.user;
43 }
44 
45 
47 // Setter Section //
49 
50 void MessageEntity::setUrl(const optional<string> &url) {
51  if(type.compare("text_link")){
53  }
54  else{
55  throw essential_key_missing("For setting MessageEntity::url in MessageEntity::type::"+type+" is missing text_link");
56  }
57 
58 }
59 
60 void MessageEntity::setUser(const optional<User> &user) {
61  if(type.compare("text_mention”")){
63  }
64  else{
65  throw essential_key_missing("For setting MessageEntity::user in MessageEntity::type::"+type+" is missing text_mention");
66  }
67 }
68 
70 // Getter Section //
72 
73 const string &MessageEntity::getType() const {
74  return type;
75 }
76 
77 int32_t MessageEntity::getOffset() const {
78  return offset;
79 }
80 
81 int32_t MessageEntity::getLength() const {
82  return length;
83 }
84 
85 const optional<string> &MessageEntity::getUrl() const {
86  return url;
87 }
88 
89 const optional<User> &MessageEntity::getUser() const {
90  return user;
91 }
std::int32_t getOffset() const
const std::optional< std::string > & getUrl() const
const std::optional< User > & getUser() const
Definition: Bot.h:27
MessageEntity(std::string type, std::int32_t offset, std::int32_t length)
std::optional< std::string > url
Definition: MessageEntity.h:38
void setUrl(const std::optional< std::string > &url)
void setUser(const std::optional< User > &user)
std::optional< User > user
Definition: MessageEntity.h:39
const std::string & getType() const
std::int32_t getLength() const