diff options
author | JellyBrick <shlee1503@naver.com> | 2018-05-26 17:46:51 +0900 |
---|---|---|
committer | JellyBrick <shlee1503@naver.com> | 2018-05-26 17:46:51 +0900 |
commit | b79bd701400fb8bf8a845f8a24d78e82f182bb2f (patch) | |
tree | ed669eac33388c4b8f7e47f9037ddef3ad927d87 /src/TgTypeParser.cpp | |
parent | 987adf188619011acff2052301245e4df22a38d2 (diff) |
Improve performance
Diffstat (limited to 'src/TgTypeParser.cpp')
-rw-r--r-- | src/TgTypeParser.cpp | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 84a83df..1b80d7f 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -33,7 +33,7 @@ TgTypeParser& TgTypeParser::getInstance() { } Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const { - Chat::Ptr result(new Chat); + auto result(make_shared<Chat>()); result->id = data.get<int64_t>("id"); string type = data.get<string>("type"); if (type == "private") { @@ -80,7 +80,7 @@ string TgTypeParser::parseChat(const Chat::Ptr& object) const { } User::Ptr TgTypeParser::parseJsonAndGetUser(const ptree& data) const { - User::Ptr result(new User); + auto result(make_shared<User>()); result->id = data.get<int32_t>("id"); result->firstName = data.get<string>("first_name"); result->lastName = data.get("last_name", ""); @@ -104,7 +104,7 @@ string TgTypeParser::parseUser(const User::Ptr& object) const { } MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{ - MessageEntity::Ptr result(new MessageEntity); + auto result(make_shared<MessageEntity>()); result->type=data.get<string>("type"); result->offset=data.get<int32_t>("offset"); result->length=data.get<int32_t>("length"); @@ -114,7 +114,7 @@ MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{ } Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const { - Message::Ptr result(new Message); + auto result(make_shared<Message>()); result->messageId = data.get<int32_t>("message_id"); result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->date = data.get<int32_t>("date"); @@ -189,7 +189,7 @@ string TgTypeParser::parseMessage(const Message::Ptr& object) const { } PhotoSize::Ptr TgTypeParser::parseJsonAndGetPhotoSize(const ptree& data) const { - PhotoSize::Ptr result(new PhotoSize); + auto result(make_shared<PhotoSize>()); result->fileId = data.get<string>("file_id"); result->width = data.get<int32_t>("width"); result->height = data.get<int32_t>("height"); @@ -213,7 +213,7 @@ string TgTypeParser::parsePhotoSize(const PhotoSize::Ptr& object) const { } Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const ptree& data) const { - Audio::Ptr result(new Audio); + auto result(make_shared<Audio>()); result->fileId = data.get<string>("file_id"); result->duration = data.get<int32_t>("duration"); result->performer = data.get<string>("performer", ""); @@ -239,7 +239,7 @@ string TgTypeParser::parseAudio(const Audio::Ptr& object) const { } Document::Ptr TgTypeParser::parseJsonAndGetDocument(const ptree& data) const { - Document::Ptr result(new Document); + auto result(make_shared<Document>()); result->fileId = data.get<string>("file_id"); result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->fileName = data.get("file_name", ""); @@ -265,7 +265,7 @@ string TgTypeParser::parseDocument(const Document::Ptr& object) const { } Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const { - Sticker::Ptr result(new Sticker); + auto result(make_shared<Sticker>()); result->fileId = data.get<string>("file_id"); result->width = data.get<int32_t>("width"); result->height = data.get<int32_t>("height"); @@ -293,7 +293,7 @@ string TgTypeParser::parseSticker(const Sticker::Ptr& object) const { } Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const { - Video::Ptr result(new Video); + auto result(make_shared<Video>()); result->fileId = data.get<string>("file_id"); result->width = data.get<int32_t>("width"); result->height = data.get<int32_t>("height"); @@ -323,7 +323,7 @@ string TgTypeParser::parseVideo(const Video::Ptr& object) const { } Contact::Ptr TgTypeParser::parseJsonAndGetContact(const ptree& data) const { - Contact::Ptr result(new Contact); + auto result(make_shared<Contact>()); result->phoneNumber = data.get<string>("phone_number"); result->firstName = data.get<string>("first_name"); result->lastName = data.get("last_name", ""); @@ -347,7 +347,7 @@ string TgTypeParser::parseContact(const Contact::Ptr& object) const { } Location::Ptr TgTypeParser::parseJsonAndGetLocation(const ptree& data) const { - Location::Ptr result(new Location); + auto result(make_shared<Location>()); result->longitude = data.get<float>("longitude", 0); result->latitude = data.get<float>("latitude", 0); return result; @@ -367,7 +367,7 @@ string TgTypeParser::parseLocation(const Location::Ptr& object) const { } Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const ptree& data) const { - Update::Ptr result(new Update); + auto result(make_shared<Update>()); result->updateId = data.get<int32_t>("update_id"); result->message = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "message"); result->editedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "edited_message"); @@ -399,7 +399,7 @@ string TgTypeParser::parseUpdate(const Update::Ptr& object) const { } UserProfilePhotos::Ptr TgTypeParser::parseJsonAndGetUserProfilePhotos(const ptree& data) const { - UserProfilePhotos::Ptr result(new UserProfilePhotos); + auto result(make_shared<UserProfilePhotos>()); result->totalCount = data.get<int32_t>("total_count"); result->photos = parseJsonAndGet2DArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photos"); return result; @@ -419,7 +419,7 @@ string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object } File::Ptr TgTypeParser::parseJsonAndGetFile(const boost::property_tree::ptree& data) const { - File::Ptr result(new File); + auto result(make_shared<File>()); result->fileId = data.get<string>("file_id"); result->fileSize = data.get<int32_t>("file_size", 0); result->filePath = data.get<string>("file_path", ""); @@ -441,7 +441,7 @@ string TgTypeParser::parseFile(const File::Ptr& object) const { } ReplyKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const { - ReplyKeyboardMarkup::Ptr result(new ReplyKeyboardMarkup); + auto result(make_shared<ReplyKeyboardMarkup>()); for (const boost::property_tree::ptree::value_type& item : data.find("keyboard")->second){ result->keyboard.push_back(parseJsonAndGetArray<KeyboardButton>(&TgTypeParser::parseJsonAndGetKeyboardButton, item.second)); } @@ -479,7 +479,7 @@ std::string TgTypeParser::parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Pt } KeyboardButton::Ptr TgTypeParser::parseJsonAndGetKeyboardButton(const boost::property_tree::ptree& data) const { - KeyboardButton::Ptr result(new KeyboardButton); + auto result(make_shared<KeyboardButton>()); result->text = data.get<string>("text"); result->requestContact = data.get<bool>("request_contact", false); result->requestLocation = data.get<bool>("request_location", false); @@ -501,7 +501,7 @@ std::string TgTypeParser::parseKeyboardButton(const KeyboardButton::Ptr& object) } ReplyKeyboardRemove::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardRemove(const boost::property_tree::ptree& data) const { - ReplyKeyboardRemove::Ptr result(new ReplyKeyboardRemove); + auto result(make_shared<ReplyKeyboardRemove>()); result->selective = data.get<bool>("selective", false); return result; } @@ -520,7 +520,7 @@ std::string TgTypeParser::parseReplyKeyboardRemove(const ReplyKeyboardRemove::Pt } ForceReply::Ptr TgTypeParser::parseJsonAndGetForceReply(const boost::property_tree::ptree& data) const { - ForceReply::Ptr result(new ForceReply); + auto result(make_shared<ForceReply>()); result->selective = data.get<bool>("selective"); return result; } @@ -539,7 +539,7 @@ std::string TgTypeParser::parseForceReply(const ForceReply::Ptr& object) const { } ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const { - ChatMember::Ptr result(new ChatMember); + auto result(make_shared<ChatMember>()); result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user"); result->status = data.get<string>("status"); return result; @@ -559,7 +559,7 @@ std::string TgTypeParser::parseChatMember(const ChatMember::Ptr& object) const { } ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const { - ResponseParameters::Ptr result(new ResponseParameters); + auto result(make_shared<ResponseParameters>()); result->migrateToChatId = data.get<int32_t>("migrate_to_chat_id", 0); result->retryAfter = data.get<int32_t>("retry_after", 0); return result; @@ -588,7 +588,7 @@ GenericReply::Ptr TgTypeParser::parseJsonAndGetGenericReply(const boost::propert } else if (data.find("inline_keyboard") != data.not_found()) { return static_pointer_cast<GenericReply>(parseJsonAndGetInlineKeyboardMarkup(data)); } - return GenericReply::Ptr(new GenericReply); + return make_shared<GenericReply>(); } std::string TgTypeParser::parseGenericReply(const GenericReply::Ptr& object) const { @@ -608,7 +608,7 @@ std::string TgTypeParser::parseGenericReply(const GenericReply::Ptr& object) con } InlineQuery::Ptr TgTypeParser::parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const { - InlineQuery::Ptr result(new InlineQuery); + auto result(make_shared<InlineQuery>()); result->id = data.get<string>("id"); result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location"); @@ -773,7 +773,7 @@ std::string TgTypeParser::parseInlineQueryResult(const InlineQueryResult::Ptr& o InlineQueryResultCachedAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedAudio(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedAudio::Ptr result(new InlineQueryResultCachedAudio); + auto result(make_shared<InlineQueryResultCachedAudio>()); result->audioFileId = data.get<string>("audio_file_id"); return result; } @@ -792,7 +792,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedAudio(const InlineQueryRes InlineQueryResultCachedDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedDocument(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedDocument::Ptr result(new InlineQueryResultCachedDocument); + auto result(make_shared<InlineQueryResultCachedDocument>()); result->documentFileId = data.get<string>("document_file_id"); result->description = data.get<string>("description", ""); return result; @@ -814,7 +814,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedDocument(const InlineQuery InlineQueryResultCachedGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedGif(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedGif::Ptr result(new InlineQueryResultCachedGif); + auto result(make_shared<InlineQueryResultCachedGif>()); result->gifFileId = data.get<string>("gif_file_id"); return result; } @@ -834,7 +834,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedGif(const InlineQueryResul InlineQueryResultCachedMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedMpeg4Gif(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedMpeg4Gif::Ptr result(new InlineQueryResultCachedMpeg4Gif); + auto result(make_shared<InlineQueryResultCachedMpeg4Gif>()); result->mpeg4FileId = data.get<string>("mpeg4_file_id"); return result; } @@ -854,7 +854,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedMpeg4Gif(const InlineQuery InlineQueryResultCachedPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedPhoto(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedPhoto::Ptr result(new InlineQueryResultCachedPhoto); + auto result(make_shared<InlineQueryResultCachedPhoto>()); result->photoFileId = data.get<string>("photo_file_id"); result->description = data.get<string>("description", ""); return result; @@ -876,7 +876,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedPhoto(const InlineQueryRes InlineQueryResultCachedSticker::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedSticker(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedSticker::Ptr result(new InlineQueryResultCachedSticker); + auto result(make_shared<InlineQueryResultCachedSticker>()); result->stickerFileId = data.get<string>("sticker_file_id"); return result; } @@ -895,7 +895,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedSticker(const InlineQueryR InlineQueryResultCachedVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedVideo(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedVideo::Ptr result(new InlineQueryResultCachedVideo); + auto result(make_shared<InlineQueryResultCachedVideo>()); result->videoFileId = data.get<string>("video_file_id"); result->description = data.get<string>("description", ""); return result; @@ -917,7 +917,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedVideo(const InlineQueryRes InlineQueryResultCachedVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCachedVoice(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultCachedVoice::Ptr result(new InlineQueryResultCachedVoice); + auto result(make_shared<InlineQueryResultCachedVoice>()); result->voiceFileId = data.get<string>("voice_file_id"); return result; } @@ -936,7 +936,7 @@ std::string TgTypeParser::parseInlineQueryResultCachedVoice(const InlineQueryRes InlineQueryResultArticle::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultArticle(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultArticle::Ptr result(new InlineQueryResultArticle); + auto result(make_shared<InlineQueryResultArticle>()); result->url = data.get<string>("url", ""); result->hideUrl = data.get("hide_url", false); result->description = data.get<string>("description", ""); @@ -965,7 +965,7 @@ std::string TgTypeParser::parseInlineQueryResultArticle(const InlineQueryResultA InlineQueryResultAudio::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultAudio(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultAudio::Ptr result(new InlineQueryResultAudio); + auto result(make_shared<InlineQueryResultAudio>()); result->audioUrl = data.get<string>("audio_url"); result->performer = data.get<string>("performer", ""); result->audioDuration = data.get<int32_t>("audio_duration", 0); @@ -989,7 +989,7 @@ std::string TgTypeParser::parseInlineQueryResultAudio(const InlineQueryResultAud InlineQueryResultContact::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultContact(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultContact::Ptr result(new InlineQueryResultContact); + auto result(make_shared<InlineQueryResultContact>()); result->phoneNumber = data.get<string>("phone_number"); result->firstName = data.get<string>("first_name"); result->lastName = data.get<string>("last_name", ""); @@ -1019,7 +1019,7 @@ std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultC InlineQueryResultGame::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGame(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultGame::Ptr result(new InlineQueryResultGame); + auto result(make_shared<InlineQueryResultGame>()); result->gameShortName = data.get<string>("game_short_name"); return result; } @@ -1038,7 +1038,7 @@ std::string TgTypeParser::parseInlineQueryResultGame(const InlineQueryResultGame InlineQueryResultDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultDocument(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultDocument::Ptr result(new InlineQueryResultDocument); + auto result(make_shared<InlineQueryResultDocument>()); result->documentUrl = data.get<string>("document_url"); result->mimeType = data.get<string>("mime_type"); result->description = data.get<string>("description", ""); @@ -1067,7 +1067,7 @@ std::string TgTypeParser::parseInlineQueryResultDocument(const InlineQueryResult InlineQueryResultLocation::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultLocation(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultLocation::Ptr result(new InlineQueryResultLocation); + auto result(make_shared<InlineQueryResultLocation>()); result->latitude = data.get<float>("latitude"); result->longitude = data.get<float>("longitude"); result->thumbUrl = data.get<string>("thumb_url", ""); @@ -1095,7 +1095,7 @@ std::string TgTypeParser::parseInlineQueryResultLocation(const InlineQueryResult InlineQueryResultVenue::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVenue(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultVenue::Ptr result(new InlineQueryResultVenue); + auto result(make_shared<InlineQueryResultVenue>()); result->latitude = data.get<float>("latitude"); result->longitude = data.get<float>("longitude"); result->address = data.get<string>("address"); @@ -1126,7 +1126,7 @@ std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVen InlineQueryResultVoice::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVoice(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultVoice::Ptr result(new InlineQueryResultVoice); + auto result(make_shared<InlineQueryResultVoice>()); result->voiceUrl = data.get<string>("voice_url"); result->voiceDuration = data.get<int32_t>("voice_duration", 0); return result; @@ -1147,7 +1147,7 @@ std::string TgTypeParser::parseInlineQueryResultVoice(const InlineQueryResultVoi InlineQueryResultPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultPhoto(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultPhoto::Ptr result(new InlineQueryResultPhoto); + auto result(make_shared<InlineQueryResultPhoto>()); result->photoUrl = data.get<string>("photo_url", ""); result->thumbUrl = data.get<string>("thumb_url"); result->photoWidth = data.get("photo_width", 0); @@ -1174,7 +1174,7 @@ std::string TgTypeParser::parseInlineQueryResultPhoto(const InlineQueryResultPho InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultGif::Ptr result(new InlineQueryResultGif); + auto result(make_shared<InlineQueryResultGif>()); result->gifUrl = data.get<string>("gif_url", ""); result->gifWidth = data.get("gif_width", 0); result->gifHeight = data.get("gif_height", 0); @@ -1198,7 +1198,7 @@ std::string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif:: InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpeg4Gif(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultMpeg4Gif::Ptr result(new InlineQueryResultMpeg4Gif); + auto result(make_shared<InlineQueryResultMpeg4Gif>()); result->mpeg4Url = data.get<string>("mpeg4_url"); result->mpeg4Width = data.get("mpeg4_width", 0); result->mpeg4Height = data.get("mpeg4_height", 0); @@ -1223,7 +1223,7 @@ std::string TgTypeParser::parseInlineQueryResultMpeg4Gif(const InlineQueryResult InlineQueryResultVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVideo(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGgetInlineQueryResult(). - InlineQueryResultVideo::Ptr result(new InlineQueryResultVideo); + auto result(make_shared<InlineQueryResultVideo>()); result->videoUrl = data.get<string>("video_url"); result->mimeType = data.get<string>("mime_type"); result->thumbUrl = data.get<string>("thumb_url"); @@ -1253,7 +1253,7 @@ std::string TgTypeParser::parseInlineQueryResultVideo(const InlineQueryResultVid } ChosenInlineResult::Ptr TgTypeParser::parseJsonAndGetChosenInlineResult(const boost::property_tree::ptree& data) const { - ChosenInlineResult::Ptr result(new ChosenInlineResult); + auto result(make_shared<ChosenInlineResult>()); result->resultId = data.get<string>("result_id"); result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location"); @@ -1278,7 +1278,7 @@ std::string TgTypeParser::parseChosenInlineResult(const ChosenInlineResult::Ptr& } CallbackQuery::Ptr TgTypeParser::parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const { - CallbackQuery::Ptr result(new CallbackQuery); + auto result(make_shared<CallbackQuery>()); result->id = data.get<string>("id"); result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->message = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "message"); @@ -1309,7 +1309,7 @@ std::string TgTypeParser::parseCallbackQuery(const CallbackQuery::Ptr& object) c } InlineKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardMarkup(const boost::property_tree::ptree& data) const { - InlineKeyboardMarkup::Ptr result(new InlineKeyboardMarkup); + auto result(make_shared<InlineKeyboardMarkup>()); for (const boost::property_tree::ptree::value_type& item : data.find("inline_keyboard")->second){ result->inlineKeyboard.push_back(parseJsonAndGetArray<InlineKeyboardButton>(&TgTypeParser::parseJsonAndGetInlineKeyboardButton, item.second)); } @@ -1339,7 +1339,7 @@ std::string TgTypeParser::parseInlineKeyboardMarkup(const InlineKeyboardMarkup:: } InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(const boost::property_tree::ptree& data) const { - InlineKeyboardButton::Ptr result(new InlineKeyboardButton); + auto result(make_shared<InlineKeyboardButton>()); result->text = data.get<string>("text"); result->url = data.get<string>("url", ""); result->callbackData = data.get<string>("callback_data", ""); @@ -1364,7 +1364,7 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton:: } WebhookInfo::Ptr TgTypeParser::parseJsonAndGetWebhookInfo(const boost::property_tree::ptree& data) const { - WebhookInfo::Ptr result(new WebhookInfo); + auto result(make_shared<WebhookInfo>()); result->url = data.get<string>("url"); result->hasCustomCertificate = data.get<bool>("has_custom_certificate"); result->pendingUpdateCount = data.get<int32_t>("pending_update_count"); @@ -1451,7 +1451,7 @@ std::string TgTypeParser::parseInputMessageContent(const InputMessageContent::Pt InputTextMessageContent::Ptr TgTypeParser::parseJsonAndGetInputTextMessageContent(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMessageContent(). - InputTextMessageContent::Ptr result(new InputTextMessageContent); + auto result(make_shared<InputTextMessageContent>()); result->messageText = data.get<string>("message_text"); result->parseMode = data.get<string>("parse_mode", ""); result->disableWebPagePreview = data.get<bool>("disable_web_page_preview", false); @@ -1473,7 +1473,7 @@ std::string TgTypeParser::parseInputTextMessageContent(const InputTextMessageCon InputLocationMessageContent::Ptr TgTypeParser::parseJsonAndGetInputLocationMessageContent(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMessageContent(). - InputLocationMessageContent::Ptr result(new InputLocationMessageContent); + auto result(make_shared<InputLocationMessageContent>()); result->latitude = data.get<float>("latitude"); result->longitude = data.get<float>("longitude"); return result; @@ -1493,7 +1493,7 @@ std::string TgTypeParser::parseInputLocationMessageContent(const InputLocationMe InputVenueMessageContent::Ptr TgTypeParser::parseJsonAndGetInputVenueMessageContent(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMessageContent(). - InputVenueMessageContent::Ptr result(new InputVenueMessageContent); + auto result(make_shared<InputVenueMessageContent>()); result->latitude = data.get<float>("latitude"); result->longitude = data.get<float>("longitude"); result->title = data.get<string>("title"); @@ -1519,7 +1519,7 @@ std::string TgTypeParser::parseInputVenueMessageContent(const InputVenueMessageC InputContactMessageContent::Ptr TgTypeParser::parseJsonAndGetInputContactMessageContent(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMessageContent(). - InputContactMessageContent::Ptr result(new InputContactMessageContent); + auto result(make_shared<InputContactMessageContent>()); result->phoneNumber = data.get<string>("phone_number"); result->firstName = data.get<string>("first_name"); result->lastName = data.get<string>("last_name", ""); |