summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Morozenkov <reo7sp@users.noreply.github.com>2016-11-05 21:35:01 +0300
committerGitHub <noreply@github.com>2016-11-05 21:35:01 +0300
commit305471cb6a60b6033babf11f662ba93205acce23 (patch)
tree94517ab1bc9d0570648ae6bbbc0aa810fe274dbd
parent1dc0ee29b3ba8150cc57757b60cabed6e37c5aaf (diff)
parent54843ab5d5ddfa695f6873b0adb53ec333b9491f (diff)
Merge pull request #26 from andijcr/master
added json->MessageEntity
-rw-r--r--include/tgbot/TgTypeParser.h1
-rw-r--r--src/TgTypeParser.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index 17e9553..9e5a1d7 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -73,6 +73,7 @@ public:
std::string parseChat(const Chat::Ptr& object) const;
User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const;
std::string parseUser(const User::Ptr& object) const;
+ MessageEntity::Ptr parseJsonAndGetEntity(const boost::property_tree::ptree& data) const;
Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const;
std::string parseMessage(const Message::Ptr& object) const;
PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const;
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 05a287d..63ff3ce 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -102,6 +102,15 @@ string TgTypeParser::parseUser(const User::Ptr& object) const {
return result;
}
+MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{
+ MessageEntity::Ptr result(new MessageEntity);
+ result->type=data.get<string>("type");
+ result->offset=data.get<int32_t>("offset");
+ result->length=data.get<int32_t>("length");
+ result->url=data.get<string>("url", "");
+ return result;
+}
+
Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
Message::Ptr result(new Message);
result->messageId = data.get<int32_t>("message_id");