From 6a3c8387da208ac2ffa4757dfafe1600a693b24f Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Tue, 15 Sep 2015 18:18:49 +0300 Subject: Fix formatting + some minor improvements --- src/TgTypeParser.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/TgTypeParser.cpp') 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("file_id"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson(&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("file_id"); result->width = data.get("width"); result->height = data.get("height"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson(&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("width"); result->height = data.get("height"); result->duration = data.get("duration"); - if(data.find("thumb") != data.not_found()) { - result->thumb = parseJsonAndGetPhotoSize(data.find("thumb")->second); - } + result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); return result; -- cgit v1.2.3