diff options
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); |