From 7abb2509b87ef1344da97ae734211715f291cfa2 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 23 Oct 2022 16:08:28 +0200 Subject: Pass strings not as references with boost::variant (#237) --- include/tgbot/Api.h | 144 ++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'include') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index c811730..9dd2f5e 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -174,7 +174,7 @@ public: * @return On success, the sent Message is returned. */ - Message::Ptr sendMessage(boost::variant chatId, + Message::Ptr sendMessage(boost::variant chatId, const std::string& text, bool disableWebPagePreview = false, std::int32_t replyToMessageId = 0, @@ -198,8 +198,8 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr forwardMessage(boost::variant chatId, - boost::variant fromChatId, + Message::Ptr forwardMessage(boost::variant chatId, + boost::variant fromChatId, std::int32_t messageId, bool disableNotification = false, bool protectContent = false) const; @@ -225,8 +225,8 @@ public: * * @return Returns the MessageId of the sent message on success. */ - MessageId::Ptr copyMessage(boost::variant chatId, - boost::variant fromChatId, + MessageId::Ptr copyMessage(boost::variant chatId, + boost::variant fromChatId, std::int32_t messageId, const std::string& caption = "", const std::string& parseMode = "", @@ -253,8 +253,8 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendPhoto(boost::variant chatId, - boost::variant photo, + Message::Ptr sendPhoto(boost::variant chatId, + boost::variant photo, const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), @@ -289,13 +289,13 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendAudio(boost::variant chatId, - boost::variant audio, + Message::Ptr sendAudio(boost::variant chatId, + boost::variant audio, const std::string& caption = "", std::int32_t duration = 0, const std::string& performer = "", const std::string& title = "", - boost::variant thumb = "", + boost::variant thumb = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), const std::string& parseMode = "", @@ -324,9 +324,9 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendDocument(boost::variant chatId, - boost::variant document, - boost::variant thumb = "", + Message::Ptr sendDocument(boost::variant chatId, + boost::variant document, + boost::variant thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), @@ -360,13 +360,13 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendVideo(boost::variant chatId, - boost::variant video, + Message::Ptr sendVideo(boost::variant chatId, + boost::variant video, bool supportsStreaming = false, std::int32_t duration = 0, std::int32_t width = 0, std::int32_t height = 0, - boost::variant thumb = "", + boost::variant thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), @@ -398,12 +398,12 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendAnimation(boost::variant chatId, - boost::variant animation, + Message::Ptr sendAnimation(boost::variant chatId, + boost::variant animation, std::int32_t duration = 0, std::int32_t width = 0, std::int32_t height = 0, - boost::variant thumb = "", + boost::variant thumb = "", const std::string& caption = "", std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), @@ -433,8 +433,8 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendVoice(boost::variant chatId, - boost::variant voice, + Message::Ptr sendVoice(boost::variant chatId, + boost::variant voice, const std::string& caption = "", std::int32_t duration = 0, std::int32_t replyToMessageId = 0, @@ -463,13 +463,13 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendVideoNote(boost::variant chatId, - boost::variant videoNote, + Message::Ptr sendVideoNote(boost::variant chatId, + boost::variant videoNote, std::int64_t replyToMessageId = 0, bool disableNotification = false, std::int32_t duration = 0, std::int32_t length = 0, - boost::variant thumb = "", + boost::variant thumb = "", GenericReply::Ptr replyMarkup = std::make_shared(), bool allowSendingWithoutReply = false, bool protectContent = false) const; @@ -488,7 +488,7 @@ public: * * @return On success, an array of Messages that were sent is returned. */ - std::vector sendMediaGroup(boost::variant chatId, + std::vector sendMediaGroup(boost::variant chatId, const std::vector& media, bool disableNotification = false, std::int32_t replyToMessageId = 0, @@ -513,7 +513,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendLocation(boost::variant chatId, + Message::Ptr sendLocation(boost::variant chatId, float latitude, float longitude, std::int32_t livePeriod = 0, @@ -545,7 +545,7 @@ public: */ Message::Ptr editMessageLiveLocation(float latitude, float longitude, - boost::variant chatId = "", + boost::variant chatId = "", std::int32_t messageId = 0, const std::string& inlineMessageId = "", InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared(), @@ -563,7 +563,7 @@ public: * * @return On success, the edited Message is returned. */ - Message::Ptr stopMessageLiveLocation(boost::variant chatId = "", + Message::Ptr stopMessageLiveLocation(boost::variant chatId = "", std::int32_t messageId = 0, const std::string& inlineMessageId = "", InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared()) const; @@ -588,7 +588,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendVenue(boost::variant chatId, + Message::Ptr sendVenue(boost::variant chatId, float latitude, float longitude, const std::string& title, @@ -619,7 +619,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendContact(boost::variant chatId, + Message::Ptr sendContact(boost::variant chatId, const std::string& phoneNumber, const std::string& firstName, const std::string& lastName = "", @@ -654,7 +654,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendPoll(boost::variant chatId, + Message::Ptr sendPoll(boost::variant chatId, const std::string& question, const std::vector& options, bool disableNotification = false, @@ -686,7 +686,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendDice(boost::variant chatId, + Message::Ptr sendDice(boost::variant chatId, bool disableNotification = false, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), @@ -755,7 +755,7 @@ public: * * @return Returns True on success. */ - bool banChatMember(boost::variant chatId, + bool banChatMember(boost::variant chatId, std::int64_t userId, std::int32_t untilDate = 0, bool revokeMessages = true) const; @@ -775,7 +775,7 @@ public: * * @return Returns True on success. */ - bool unbanChatMember(boost::variant chatId, + bool unbanChatMember(boost::variant chatId, std::int64_t userId, bool onlyIfBanned = false) const; @@ -792,7 +792,7 @@ public: * * @return Returns True on success. */ - bool restrictChatMember(boost::variant chatId, + bool restrictChatMember(boost::variant chatId, std::int64_t userId, ChatPermissions::Ptr permissions, std::int64_t untilDate = 0) const; @@ -819,7 +819,7 @@ public: * * @return Returns True on success. */ - bool promoteChatMember(boost::variant chatId, + bool promoteChatMember(boost::variant chatId, std::int64_t userId, bool canChangeInfo = false, bool canPostMessages = false, @@ -842,7 +842,7 @@ public: * * @return Returns True on success. */ - bool setChatAdministratorCustomTitle(boost::variant chatId, + bool setChatAdministratorCustomTitle(boost::variant chatId, std::int64_t userId, const std::string& customTitle) const; @@ -857,7 +857,7 @@ public: * * @return Returns True on success. */ - bool banChatSenderChat(boost::variant chatId, + bool banChatSenderChat(boost::variant chatId, std::int64_t senderChatId) const; /** @@ -870,7 +870,7 @@ public: * * @return Returns True on success. */ - bool unbanChatSenderChat(boost::variant chatId, + bool unbanChatSenderChat(boost::variant chatId, std::int64_t senderChatId) const; /** @@ -883,7 +883,7 @@ public: * * @return Returns True on success. */ - bool setChatPermissions(boost::variant chatId, + bool setChatPermissions(boost::variant chatId, ChatPermissions::Ptr permissions) const; /** @@ -900,7 +900,7 @@ public: * * @return Returns the new invite link as String on success. */ - std::string exportChatInviteLink(boost::variant chatId) const; + std::string exportChatInviteLink(boost::variant chatId) const; /** * @brief Use this method to create an additional invite link for a chat. @@ -916,7 +916,7 @@ public: * * @return Returns the new invite link as ChatInviteLink object. */ - ChatInviteLink::Ptr createChatInviteLink(boost::variant chatId, + ChatInviteLink::Ptr createChatInviteLink(boost::variant chatId, std::int32_t expireDate = 0, std::int32_t memberLimit = 0, const std::string& name = "", @@ -936,7 +936,7 @@ public: * * @return Returns the edited invite link as a ChatInviteLink object. */ - ChatInviteLink::Ptr editChatInviteLink(boost::variant chatId, + ChatInviteLink::Ptr editChatInviteLink(boost::variant chatId, const std::string& inviteLink, std::int32_t expireDate = 0, std::int32_t memberLimit = 0, @@ -954,7 +954,7 @@ public: * * @return Returns the revoked invite link as ChatInviteLink object. */ - ChatInviteLink::Ptr revokeChatInviteLink(boost::variant chatId, + ChatInviteLink::Ptr revokeChatInviteLink(boost::variant chatId, const std::string& inviteLink) const; /** @@ -967,7 +967,7 @@ public: * * @return Returns True on success. */ - bool approveChatJoinRequest(boost::variant chatId, + bool approveChatJoinRequest(boost::variant chatId, std::int64_t userId) const; /** @@ -980,7 +980,7 @@ public: * * @return True on success. */ - bool declineChatJoinRequest(boost::variant chatId, + bool declineChatJoinRequest(boost::variant chatId, std::int64_t userId) const; /** @@ -994,7 +994,7 @@ public: * * @return Returns True on success. */ - bool setChatPhoto(boost::variant chatId, + bool setChatPhoto(boost::variant chatId, InputFile::Ptr photo) const; /** @@ -1007,7 +1007,7 @@ public: * * @return Returns True on success. */ - bool deleteChatPhoto(boost::variant chatId) const; + bool deleteChatPhoto(boost::variant chatId) const; /** * @brief Use this method to change the title of a chat. @@ -1020,7 +1020,7 @@ public: * * @return Returns True on success. */ - bool setChatTitle(boost::variant chatId, + bool setChatTitle(boost::variant chatId, const std::string& title) const; /** @@ -1033,7 +1033,7 @@ public: * * @return Returns True on success. */ - bool setChatDescription(boost::variant chatId, + bool setChatDescription(boost::variant chatId, const std::string& description = "") const; /** @@ -1047,7 +1047,7 @@ public: * * @return Returns True on success. */ - bool pinChatMessage(boost::variant chatId, + bool pinChatMessage(boost::variant chatId, std::int32_t messageId, bool disableNotification = false) const; @@ -1061,7 +1061,7 @@ public: * * @return Returns True on success. */ - bool unpinChatMessage(boost::variant chatId, + bool unpinChatMessage(boost::variant chatId, std::int32_t messageId = 0) const; /** @@ -1073,7 +1073,7 @@ public: * * @return Returns True on success. */ - bool unpinAllChatMessages(boost::variant chatId) const; + bool unpinAllChatMessages(boost::variant chatId) const; /** * @brief Use this method for your bot to leave a group, supergroup or channel. @@ -1082,7 +1082,7 @@ public: * * @return Returns True on success. */ - bool leaveChat(boost::variant chatId) const; + bool leaveChat(boost::variant chatId) const; /** * @brief Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). @@ -1091,7 +1091,7 @@ public: * * @return Returns a Chat object on success. */ - Chat::Ptr getChat(boost::variant chatId) const; + Chat::Ptr getChat(boost::variant chatId) const; /** * @brief Use this method to get a list of administrators in a chat, which aren't bots. @@ -1100,7 +1100,7 @@ public: * * @return Returns an Array of ChatMember objects. */ - std::vector getChatAdministrators(boost::variant chatId) const; + std::vector getChatAdministrators(boost::variant chatId) const; /** * @brief Use this method to get the number of members in a chat. @@ -1109,7 +1109,7 @@ public: * * @return Returns Int on success. */ - std::int32_t getChatMemberCount(boost::variant chatId) const; + std::int32_t getChatMemberCount(boost::variant chatId) const; /** * @brief Use this method to get information about a member of a chat. @@ -1119,7 +1119,7 @@ public: * * @return Returns a ChatMember object on success. */ - ChatMember::Ptr getChatMember(boost::variant chatId, + ChatMember::Ptr getChatMember(boost::variant chatId, std::int64_t userId) const; /** @@ -1133,7 +1133,7 @@ public: * * @return Returns True on success. */ - bool setChatStickerSet(boost::variant chatId, + bool setChatStickerSet(boost::variant chatId, const std::string& stickerSetName) const; /** @@ -1146,7 +1146,7 @@ public: * * @return Returns True on success. */ - bool deleteChatStickerSet(boost::variant chatId) const; + bool deleteChatStickerSet(boost::variant chatId) const; /** * @brief Use this method to send answers to callback queries sent from inline keyboards. @@ -1267,7 +1267,7 @@ public: * @return On success, if the edited message is not an inline message, the edited Message is returned, otherwise nullptr is returned. */ Message::Ptr editMessageText(const std::string& text, - boost::variant chatId = 0, + boost::variant chatId = 0, std::int32_t messageId = 0, const std::string& inlineMessageId = "", const std::string& parseMode = "", @@ -1288,7 +1288,7 @@ public: * * @return On success, if the edited message is not an inline message, the edited Message is returned, otherwise nullptr is returned. */ - Message::Ptr editMessageCaption(boost::variant chatId = 0, + Message::Ptr editMessageCaption(boost::variant chatId = 0, std::int32_t messageId = 0, const std::string& caption = "", const std::string& inlineMessageId = "", @@ -1311,7 +1311,7 @@ public: * @return On success, if the edited message is not an inline message, the edited Message is returned, otherwise nullptr is returned. */ Message::Ptr editMessageMedia(InputMedia::Ptr media, - boost::variant chatId = 0, + boost::variant chatId = 0, std::int32_t messageId = 0, const std::string& inlineMessageId = "", GenericReply::Ptr replyMarkup = std::make_shared()) const; @@ -1326,7 +1326,7 @@ public: * * @return On success, if the edited message is not an inline message, the edited Message is returned, otherwise nullptr is returned. */ - Message::Ptr editMessageReplyMarkup(boost::variant chatId = 0, + Message::Ptr editMessageReplyMarkup(boost::variant chatId = 0, std::int32_t messageId = 0, const std::string& inlineMessageId = "", GenericReply::Ptr replyMarkup = std::make_shared()) const; @@ -1340,7 +1340,7 @@ public: * * @return On success, the stopped Poll is returned. */ - Poll::Ptr stopPoll(boost::variant chatId, + Poll::Ptr stopPoll(boost::variant chatId, std::int64_t messageId, InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared()) const; @@ -1360,7 +1360,7 @@ public: * * @return Returns True on success. */ - bool deleteMessage(boost::variant chatId, + bool deleteMessage(boost::variant chatId, std::int32_t messageId) const; /** @@ -1376,8 +1376,8 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendSticker(boost::variant chatId, - boost::variant sticker, + Message::Ptr sendSticker(boost::variant chatId, + boost::variant sticker, std::int32_t replyToMessageId = 0, GenericReply::Ptr replyMarkup = std::make_shared(), bool disableNotification = false, @@ -1436,7 +1436,7 @@ public: const std::string& title, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr, - boost::variant pngSticker = "", + boost::variant pngSticker = "", InputFile::Ptr tgsSticker = nullptr, InputFile::Ptr webmSticker = nullptr, const std::string& stickerType = "") const; @@ -1463,7 +1463,7 @@ public: const std::string& name, const std::string& emojis, MaskPosition::Ptr maskPosition = nullptr, - boost::variant pngSticker = "", + boost::variant pngSticker = "", InputFile::Ptr tgsSticker = nullptr, InputFile::Ptr webmSticker = nullptr) const; @@ -1501,7 +1501,7 @@ public: */ bool setStickerSetThumb(const std::string& name, std::int64_t userId, - boost::variant thumb = "") const; + boost::variant thumb = "") const; /** * @brief Use this method to send answers to an inline query. @@ -1570,7 +1570,7 @@ public: * * @return On success, the sent Message is returned. */ - Message::Ptr sendInvoice(boost::variant chatId, + Message::Ptr sendInvoice(boost::variant chatId, const std::string& title, const std::string& description, const std::string& payload, -- cgit v1.2.3