diff options
author | Florian Scheibner <flo.de@hotmail.de> | 2015-11-12 14:27:07 +0100 |
---|---|---|
committer | Florian Scheibner <flo.de@hotmail.de> | 2015-11-12 14:27:07 +0100 |
commit | 4c34c9623735cdd7d11c333e54ad8723abb1be8b (patch) | |
tree | a94eddd9bfd36030b7864b3af4b437996cc6709c /include | |
parent | 7179cc9bd0d43bf0cf645bcb3247c1183dd8c818 (diff) |
Fix getMessages call
do not request "result" subitem twice
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/TgTypeParser.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index 759dc2f..f7c9791 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -110,6 +110,15 @@ public: } template<typename T> + std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data) const { + std::vector<std::shared_ptr<T>> result; + for (const std::pair<const std::string, boost::property_tree::ptree>& innerTreeItem : data) { + result.push_back((this->*parseFunc)(innerTreeItem.second)); + } + return result; + } + + template<typename T> std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data, const std::string& keyName) const { std::vector<std::shared_ptr<T>> result; auto treeItem = data.find(keyName); |