diff options
author | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-09-15 18:18:49 +0300 |
---|---|---|
committer | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-09-15 18:18:49 +0300 |
commit | 6a3c8387da208ac2ffa4757dfafe1600a693b24f (patch) | |
tree | a8cfbfd46643784ede5ddfc0ce6dcd5f39d533d2 /src/TgTypeParser.cpp | |
parent | 370df9853702bf9666b8dfa2e4254b9e236b2789 (diff) |
Fix formatting + some minor improvements
Diffstat (limited to 'src/TgTypeParser.cpp')
-rw-r--r-- | src/TgTypeParser.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index d4f4340..141aebd 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -187,9 +187,7 @@ string TgTypeParser::parseAudio(const Audio::Ptr& object) const { Document::Ptr TgTypeParser::parseJsonAndGetDocument(const ptree& data) const { Document::Ptr result(new Document); result->fileId = data.get<string>("file_id"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->fileName = data.get("file_name", ""); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); @@ -217,9 +215,7 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const { result->fileId = data.get<string>("file_id"); result->width = data.get<int32_t>("width"); result->height = data.get<int32_t>("height"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->fileSize = data.get("file_size", 0); return result; } @@ -246,9 +242,7 @@ Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const { result->width = data.get<int32_t>("width"); result->height = data.get<int32_t>("height"); result->duration = data.get<int32_t>("duration"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); return result; |