diff options
author | Alexander Zaitsev <zamazan4ik@tut.by> | 2020-03-13 03:46:58 +0300 |
---|---|---|
committer | Alexander Zaitsev <zamazan4ik@tut.by> | 2020-03-13 03:46:58 +0300 |
commit | 806e7e5a3edf4fdf2b9c48469a7bc23307b200b0 (patch) | |
tree | cb73c1bd3d8a2cfaba3809b6a6f7fb134732118a /src | |
parent | d1c6a8062577f5ce58105afff2d0a1887bfff957 (diff) |
fix: use C++ fixed-width types instead of C types
- C++ standard doesn't guarantee that C-types without std namespace are available in global namespace. So the proper solution (since it's C++ library) is using C++ types instead of C
Tested:
- Local build
- By unit-tests
Diffstat (limited to 'src')
-rw-r--r-- | src/Api.cpp | 121 | ||||
-rw-r--r-- | src/net/HttpParser.cpp | 4 | ||||
-rw-r--r-- | src/net/TgLongPoll.cpp | 6 |
3 files changed, 68 insertions, 63 deletions
diff --git a/src/Api.cpp b/src/Api.cpp index 8ecd725..26e9ada 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1,5 +1,6 @@ #include "tgbot/Api.h" +#include <cstdint> #include <utility> #include "tgbot/TgTypeParser.h" @@ -18,7 +19,7 @@ User::Ptr Api::getMe() const { return _tgTypeParser.parseJsonAndGetUser(sendRequest("getMe")); } -Message::Ptr Api::sendMessage(int64_t chatId, const string& text, bool disableWebPagePreview, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendMessage(std::int64_t chatId, const string& text, bool disableWebPagePreview, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("chat_id", chatId); @@ -41,7 +42,7 @@ Message::Ptr Api::sendMessage(int64_t chatId, const string& text, bool disableWe return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendMessage", args)); } -Message::Ptr Api::forwardMessage(int64_t chatId, int64_t fromChatId, int32_t messageId, bool disableNotification) const { +Message::Ptr Api::forwardMessage(std::int64_t chatId, std::int64_t fromChatId, std::int32_t messageId, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(4); args.emplace_back("chat_id", chatId); @@ -53,7 +54,7 @@ Message::Ptr Api::forwardMessage(int64_t chatId, int64_t fromChatId, int32_t mes return _tgTypeParser.parseJsonAndGetMessage(sendRequest("forwardMessage", args)); } -Message::Ptr Api::sendPhoto(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> photo, const string& caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendPhoto(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> photo, const string& caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("chat_id", chatId); @@ -81,7 +82,7 @@ Message::Ptr Api::sendPhoto(int64_t chatId, const boost::variant<InputFile::Ptr, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPhoto", args)); } -Message::Ptr Api::sendAudio(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> audio, const string &caption, int32_t duration, const string& performer, const string& title, const boost::variant<InputFile::Ptr, std::string> thumb, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendAudio(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> audio, const string &caption, std::int32_t duration, const string& performer, const string& title, const boost::variant<InputFile::Ptr, std::string> thumb, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(11); args.emplace_back("chat_id", chatId); @@ -127,7 +128,7 @@ Message::Ptr Api::sendAudio(int64_t chatId, const boost::variant<InputFile::Ptr, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAudio", args)); } -Message::Ptr Api::sendDocument(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> document, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendDocument(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> document, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(8); args.emplace_back("chat_id", chatId); @@ -164,13 +165,13 @@ Message::Ptr Api::sendDocument(int64_t chatId, const boost::variant<InputFile::P return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendDocument", args)); } -Message::Ptr Api::sendInvoice(int64_t chatId, const std::string& title, const std::string& description, const std::string& payload, +Message::Ptr Api::sendInvoice(std::int64_t chatId, const std::string& title, const std::string& description, const std::string& payload, const std::string& providerToken, const std::string& startParameter, const std::string& currency, const std::vector<LabeledPrice::Ptr>& prices, - const std::string& providerData, const std::string& photoUrl, int32_t photoSize, - int32_t photoWidth, int32_t photoHeight, bool needName, + const std::string& providerData, const std::string& photoUrl, std::int32_t photoSize, + std::int32_t photoWidth, std::int32_t photoHeight, bool needName, bool needPhoneNumber, bool needEmail, bool needShippingAddress, bool sendPhoneNumberToProvider, bool sendEmailToProvider, bool isFlexible, - int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { + std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(23); args.emplace_back("chat_id", chatId); @@ -255,7 +256,7 @@ bool Api::answerPreCheckoutQuery(const std::string& preCheckoutQueryId, bool ok, } -Message::Ptr Api::sendSticker(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> sticker, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendSticker(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> sticker, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(5); args.emplace_back("chat_id", chatId); @@ -284,7 +285,7 @@ StickerSet::Ptr Api::getStickerSet(const string& name) const { return _tgTypeParser.parseJsonAndGetStickerSet(sendRequest("getStickerSet", args)); } -File::Ptr Api::uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker) const { +File::Ptr Api::uploadStickerFile(std::int32_t userId, const InputFile::Ptr pngSticker) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("user_id", userId); @@ -292,7 +293,7 @@ File::Ptr Api::uploadStickerFile(int32_t userId, const InputFile::Ptr pngSticker return _tgTypeParser.parseJsonAndGetFile(sendRequest("uploadStickerFile", args)); } -bool Api::createNewStickerSet(int32_t userId, const string& name, const string& title, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const { +bool Api::createNewStickerSet(std::int32_t userId, const string& name, const string& title, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("user_id", userId); @@ -314,7 +315,7 @@ bool Api::createNewStickerSet(int32_t userId, const string& name, const string& return sendRequest("createNewStickerSet", args).get<bool>("", false); } -bool Api::addStickerToSet(int32_t userId, const string& name, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const { +bool Api::addStickerToSet(std::int32_t userId, const string& name, const boost::variant<InputFile::Ptr, std::string> pngSticker, const string& emojis, MaskPosition::Ptr maskPosition) const { vector<HttpReqArg> args; args.reserve(6); args.emplace_back("user_id", userId); @@ -332,7 +333,7 @@ bool Api::addStickerToSet(int32_t userId, const string& name, const boost::varia return sendRequest("addStickerToSet", args).get<bool>("", false); } -bool Api::setStickerPositionInSet(const string& sticker, uint32_t position) const { +bool Api::setStickerPositionInSet(const string& sticker, std::uint32_t position) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("sticker", sticker); @@ -347,7 +348,7 @@ bool Api::deleteStickerFromSet(const string& sticker) const { return sendRequest("deleteStickerFromSet", args).get<bool>("", false); } -Message::Ptr Api::sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming, int32_t duration, int32_t width, int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendVideo(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> video, bool supportsStreaming, std::int32_t duration, std::int32_t width, std::int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string &caption, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(12); args.emplace_back("chat_id", chatId); @@ -396,7 +397,7 @@ Message::Ptr Api::sendVideo(int64_t chatId, const boost::variant<InputFile::Ptr, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideo", args)); } -Message::Ptr Api::sendAnimation(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> animation, int32_t duration, int32_t width, int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string& caption, int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendAnimation(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> animation, std::int32_t duration, std::int32_t width, std::int32_t height, const boost::variant<InputFile::Ptr, std::string> thumb, const string& caption, std::int32_t replyToMessageId, GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(11); args.emplace_back("chat_id", chatId); @@ -442,7 +443,7 @@ Message::Ptr Api::sendAnimation(int64_t chatId, const boost::variant<InputFile:: return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendAnimation", args)); } -Message::Ptr Api::sendVideoNote(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> videoNote, int64_t replyToMessageId, bool disableNotification, int32_t duration, int32_t length, const boost::variant<InputFile::Ptr, std::string> thumb, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendVideoNote(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> videoNote, std::int64_t replyToMessageId, bool disableNotification, std::int32_t duration, std::int32_t length, const boost::variant<InputFile::Ptr, std::string> thumb, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(8); args.emplace_back("chat_id", chatId); @@ -479,7 +480,7 @@ Message::Ptr Api::sendVideoNote(int64_t chatId, const boost::variant<InputFile:: return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVideoNote", args)); } -vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia::Ptr>& media, bool disableNotification, int32_t replyToMessageId) const { +vector<Message::Ptr> Api::sendMediaGroup(std::int64_t chatId, const vector<InputMedia::Ptr>& media, bool disableNotification, std::int32_t replyToMessageId) const { vector<HttpReqArg> args; args.reserve(4); args.emplace_back("chat_id", chatId); @@ -490,7 +491,7 @@ vector<Message::Ptr> Api::sendMediaGroup(int64_t chatId, const vector<InputMedia return _tgTypeParser.parseJsonAndGetArray<Message>(&TgTypeParser::parseJsonAndGetMessage, sendRequest("sendMediaGroup", args)); } -Message::Ptr Api::sendVoice(int64_t chatId, const boost::variant<InputFile::Ptr, std::string> voice, const string &caption, int duration, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { +Message::Ptr Api::sendVoice(std::int64_t chatId, const boost::variant<InputFile::Ptr, std::string> voice, const string &caption, int duration, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, const string& parseMode, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(8); args.emplace_back("chat_id", chatId); @@ -521,7 +522,7 @@ Message::Ptr Api::sendVoice(int64_t chatId, const boost::variant<InputFile::Ptr, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVoice", args)); } -Message::Ptr Api::sendGame(int64_t chatId, const std::string& gameShortName, int32_t replyToMessageId, const InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendGame(std::int64_t chatId, const std::string& gameShortName, std::int32_t replyToMessageId, const InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(5); args.emplace_back("chat_id", chatId); @@ -538,7 +539,7 @@ Message::Ptr Api::sendGame(int64_t chatId, const std::string& gameShortName, int return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendGame", args)); } -Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, uint32_t livePeriod, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { +Message::Ptr Api::sendLocation(std::int64_t chatId, float latitude, float longitude, std::uint32_t livePeriod, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("chat_id", chatId); @@ -559,7 +560,7 @@ Message::Ptr Api::sendLocation(int64_t chatId, float latitude, float longitude, return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendLocation", args)); } -Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { +Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, std::int64_t chatId, std::int32_t messageId, std::int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(6); args.emplace_back("latitude", latitude); @@ -579,7 +580,7 @@ Message::Ptr Api::editMessageLiveLocation(float latitude, float longitude, int64 return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); } -Message::Ptr Api::stopMessageLiveLocation(int64_t chatId, int32_t messageId, int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { +Message::Ptr Api::stopMessageLiveLocation(std::int64_t chatId, std::int32_t messageId, std::int32_t inlineMessageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(4); if (chatId) { @@ -597,7 +598,7 @@ Message::Ptr Api::stopMessageLiveLocation(int64_t chatId, int32_t messageId, int return _tgTypeParser.parseJsonAndGetMessage(sendRequest("editMessageLiveLocation", args)); } -bool Api::setChatStickerSet(int64_t chatId, const string& stickerSetName) const { +bool Api::setChatStickerSet(std::int64_t chatId, const string& stickerSetName) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -605,14 +606,14 @@ bool Api::setChatStickerSet(int64_t chatId, const string& stickerSetName) const return sendRequest("setChatStickerSet", args).get<bool>("", false); } -bool Api::deleteChatStickerSet(int64_t chatId) const { +bool Api::deleteChatStickerSet(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("deleteChatStickerSet", args).get<bool>("", false); } -Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, const string& foursquareType, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendVenue(std::int64_t chatId, float latitude, float longitude, const string& title, const string& address, const string& foursquareId, const string& foursquareType, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(10); args.emplace_back("chat_id", chatId); @@ -638,7 +639,7 @@ Message::Ptr Api::sendVenue(int64_t chatId, float latitude, float longitude, con return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendVenue", args)); } -Message::Ptr Api::sendContact(int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, const string& vcard, bool disableNotification, int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { +Message::Ptr Api::sendContact(std::int64_t chatId, const string& phoneNumber, const string& firstName, const string& lastName, const string& vcard, bool disableNotification, std::int32_t replyToMessageId, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(8); args.emplace_back("chat_id", chatId); @@ -662,7 +663,7 @@ Message::Ptr Api::sendContact(int64_t chatId, const string& phoneNumber, const s return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendContact", args)); } -void Api::sendChatAction(int64_t chatId, const string& action) const { +void Api::sendChatAction(std::int64_t chatId, const string& action) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -670,7 +671,7 @@ void Api::sendChatAction(int64_t chatId, const string& action) const { sendRequest("sendChatAction", args); } -UserProfilePhotos::Ptr Api::getUserProfilePhotos(int32_t userId, int32_t offset, int32_t limit) const { +UserProfilePhotos::Ptr Api::getUserProfilePhotos(std::int32_t userId, std::int32_t offset, std::int32_t limit) const { vector<HttpReqArg> args; args.reserve(3); args.emplace_back("user_id", userId); @@ -689,35 +690,35 @@ File::Ptr Api::getFile(const string &fileId) const { return _tgTypeParser.parseJsonAndGetFile(sendRequest("getFile", args)); } -bool Api::leaveChat(int64_t chatId) const { +bool Api::leaveChat(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("leaveChat", args).get<bool>("", false); } -Chat::Ptr Api::getChat(int64_t chatId) const { +Chat::Ptr Api::getChat(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return _tgTypeParser.parseJsonAndGetChat(sendRequest("getChat", args)); } -vector<ChatMember::Ptr> Api::getChatAdministrators(int64_t chatId) const { +vector<ChatMember::Ptr> Api::getChatAdministrators(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return _tgTypeParser.parseJsonAndGetArray<ChatMember>(&TgTypeParser::parseJsonAndGetChatMember, sendRequest("getChatAdministrators", args)); } -int32_t Api::getChatMembersCount(int64_t chatId) const { +int32_t Api::getChatMembersCount(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("getChatMembersCount", args).get<int32_t>("", 0); } -bool Api::answerCallbackQuery(const string & callbackQueryId, const string & text, bool showAlert, const string &url, int32_t cacheTime) const { +bool Api::answerCallbackQuery(const string & callbackQueryId, const string & text, bool showAlert, const string &url, std::int32_t cacheTime) const { vector<HttpReqArg> args; args.reserve(5); args.emplace_back("callback_query_id", callbackQueryId); @@ -736,7 +737,7 @@ bool Api::answerCallbackQuery(const string & callbackQueryId, const string & tex return sendRequest("answerCallbackQuery", args).get<bool>("", false); } -Message::Ptr Api::editMessageText(const string& text, int64_t chatId, int32_t messageId, const string& inlineMessageId, +Message::Ptr Api::editMessageText(const string& text, std::int64_t chatId, std::int32_t messageId, const string& inlineMessageId, const string& parseMode, bool disableWebPagePreview, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; @@ -768,7 +769,7 @@ Message::Ptr Api::editMessageText(const string& text, int64_t chatId, int32_t me } } -Message::Ptr Api::editMessageCaption(int64_t chatId, int32_t messageId, const string& caption, +Message::Ptr Api::editMessageCaption(std::int64_t chatId, std::int32_t messageId, const string& caption, const string& inlineMessageId, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; @@ -796,7 +797,7 @@ Message::Ptr Api::editMessageCaption(int64_t chatId, int32_t messageId, const st } } -Message::Ptr Api::editMessageReplyMarkup(int64_t chatId, int32_t messageId, const string& inlineMessageId, +Message::Ptr Api::editMessageReplyMarkup(std::int64_t chatId, std::int32_t messageId, const string& inlineMessageId, const GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; @@ -821,7 +822,7 @@ Message::Ptr Api::editMessageReplyMarkup(int64_t chatId, int32_t messageId, cons } } -Message::Ptr Api::editMessageMedia(InputMedia::Ptr media, int64_t chatId, int32_t messageId, const std::string& inlineMessageId, +Message::Ptr Api::editMessageMedia(InputMedia::Ptr media, std::int64_t chatId, std::int32_t messageId, const std::string& inlineMessageId, GenericReply::Ptr replyMarkup) const { vector<HttpReqArg> args; @@ -847,7 +848,7 @@ Message::Ptr Api::editMessageMedia(InputMedia::Ptr media, int64_t chatId, int32_ } } -ChatMember::Ptr Api::getChatMember(int64_t chatId, int32_t userId) const { +ChatMember::Ptr Api::getChatMember(std::int64_t chatId, std::int32_t userId) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -855,7 +856,7 @@ ChatMember::Ptr Api::getChatMember(int64_t chatId, int32_t userId) const { return _tgTypeParser.parseJsonAndGetChatMember(sendRequest("getChatMember", args)); } -vector<Update::Ptr> Api::getUpdates(int32_t offset, int32_t limit, int32_t timeout, const StringArrayPtr &allowedUpdates) const { +vector<Update::Ptr> Api::getUpdates(std::int32_t offset, std::int32_t limit, std::int32_t timeout, const StringArrayPtr &allowedUpdates) const { vector<HttpReqArg> args; args.reserve(4); if (offset) { @@ -876,7 +877,7 @@ vector<Update::Ptr> Api::getUpdates(int32_t offset, int32_t limit, int32_t timeo return _tgTypeParser.parseJsonAndGetArray<Update>(&TgTypeParser::parseJsonAndGetUpdate, sendRequest("getUpdates", args)); } -void Api::setWebhook(const string& url, const InputFile::Ptr certificate, int32_t maxConnection, const StringArrayPtr &allowedUpdates) const { +void Api::setWebhook(const string& url, const InputFile::Ptr certificate, std::int32_t maxConnection, const StringArrayPtr &allowedUpdates) const { vector<HttpReqArg> args; args.reserve(4); if (!url.empty()) { @@ -918,7 +919,7 @@ WebhookInfo::Ptr Api::getWebhookInfo() const { } bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector<InlineQueryResult::Ptr>& results, - int32_t cacheTime, bool isPersonal, const string& nextOffset, const string& switchPmText, const string& switchPmParameter) const { + std::int32_t cacheTime, bool isPersonal, const string& nextOffset, const string& switchPmText, const string& switchPmParameter) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("inline_query_id", inlineQueryId); @@ -942,7 +943,7 @@ bool Api::answerInlineQuery(const string& inlineQueryId, const std::vector<Inlin return sendRequest("answerInlineQuery", args).get<bool>("", false); } -bool Api::kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate) const { +bool Api::kickChatMember(std::int64_t chatId, std::int32_t userId, std::uint64_t untilDate) const { vector<HttpReqArg> args; args.reserve(3); args.emplace_back("chat_id", chatId); @@ -953,15 +954,15 @@ bool Api::kickChatMember(int64_t chatId, int32_t userId, uint64_t untilDate) con return sendRequest("kickChatMember", args).get<bool>("", false); } -bool Api::unbanChatMember(int64_t chatId, int32_t userId) const { +bool Api::unbanChatMember(std::int64_t chatId, std::int32_t userId) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); args.emplace_back("user_id", userId); return sendRequest("unbanChatMember", args).get<bool>("", false); } -bool Api::restrictChatMember(int64_t chatId, int32_t userId, TgBot::ChatPermissions::Ptr permissions, - uint64_t untilDate) const { +bool Api::restrictChatMember(std::int64_t chatId, std::int32_t userId, TgBot::ChatPermissions::Ptr permissions, + std::uint64_t untilDate) const { vector<HttpReqArg> args; args.reserve(4); args.emplace_back("chat_id", chatId); @@ -974,7 +975,7 @@ bool Api::restrictChatMember(int64_t chatId, int32_t userId, TgBot::ChatPermissi return sendRequest("restrictChatMember", args).get<bool>("", false); } -bool Api::promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo, bool canPostMessages, +bool Api::promoteChatMember(std::int64_t chatId, std::int32_t userId, bool canChangeInfo, bool canPostMessages, bool canEditMessages, bool canDeleteMessages, bool canInviteUsers, bool canPinMessages, bool canPromoteMembers) const { vector<HttpReqArg> args; args.reserve(9); @@ -1004,7 +1005,7 @@ bool Api::promoteChatMember(int64_t chatId, int32_t userId, bool canChangeInfo, return sendRequest("promoteChatMember", args).get<bool>("", false); } -bool Api::setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) const{ +bool Api::setChatPermissions(std::int64_t chatId, ChatPermissions::Ptr permissions) const{ vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -1012,14 +1013,14 @@ bool Api::setChatPermissions(int64_t chatId, ChatPermissions::Ptr permissions) c return sendRequest("setChatPermissions", args).get<bool>("", false); } -string Api::exportChatInviteLink(int64_t chatId) const { +string Api::exportChatInviteLink(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("exportChatInviteLink", args).get("", ""); } -bool Api::setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const { +bool Api::setChatPhoto(std::int64_t chatId, const InputFile::Ptr photo) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -1027,14 +1028,14 @@ bool Api::setChatPhoto(int64_t chatId, const InputFile::Ptr photo) const { return sendRequest("setChatPhoto", args).get<bool>("", false); } -bool Api::deleteChatPhoto(int64_t chatId) const { +bool Api::deleteChatPhoto(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("deleteChatPhoto", args).get<bool>("", false); } -bool Api::setChatTitle(int64_t chatId, const string& title) const { +bool Api::setChatTitle(std::int64_t chatId, const string& title) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -1042,7 +1043,7 @@ bool Api::setChatTitle(int64_t chatId, const string& title) const { return sendRequest("setChatTitle", args).get<bool>("", false); } -bool Api::setChatDescription(int64_t chatId, const string& description) const { +bool Api::setChatDescription(std::int64_t chatId, const string& description) const { vector<HttpReqArg> args; args.reserve(2); args.emplace_back("chat_id", chatId); @@ -1050,7 +1051,7 @@ bool Api::setChatDescription(int64_t chatId, const string& description) const { return sendRequest("setChatDescription", args).get<bool>("", false); } -bool Api::pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotification) const { +bool Api::pinChatMessage(std::int64_t chatId, std::int32_t messageId, bool disableNotification) const { vector<HttpReqArg> args; args.reserve(3); args.emplace_back("chat_id", chatId); @@ -1061,14 +1062,14 @@ bool Api::pinChatMessage(int64_t chatId, int32_t messageId, bool disableNotifica return sendRequest("pinChatMessage", args).get<bool>("", false); } -bool Api::unpinChatMessage(int64_t chatId) const { +bool Api::unpinChatMessage(std::int64_t chatId) const { vector<HttpReqArg> args; args.reserve(1); args.emplace_back("chat_id", chatId); return sendRequest("unpinChatMessage", args).get<bool>("", false); } -Message::Ptr Api::setGameScore(int32_t userId, int32_t score, bool force, bool disableEditMessage, int64_t chatId, int32_t messageId, const std::string& inlineMessageId) const { +Message::Ptr Api::setGameScore(std::int32_t userId, std::int32_t score, bool force, bool disableEditMessage, std::int64_t chatId, std::int32_t messageId, const std::string& inlineMessageId) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("user_id", userId); @@ -1091,7 +1092,7 @@ Message::Ptr Api::setGameScore(int32_t userId, int32_t score, bool force, bool d return _tgTypeParser.parseJsonAndGetMessage(sendRequest("setGameScore", args)); } -vector<GameHighScore::Ptr> Api::getGameHighScores(int32_t userId, int32_t score, bool force, bool disableEditMessage, int64_t chatId, int32_t messageId, const std::string& inlineMessageId) const { +vector<GameHighScore::Ptr> Api::getGameHighScores(std::int32_t userId, std::int32_t score, bool force, bool disableEditMessage, std::int64_t chatId, std::int32_t messageId, const std::string& inlineMessageId) const { vector<HttpReqArg> args; args.reserve(7); args.emplace_back("user_id", userId); @@ -1114,11 +1115,11 @@ vector<GameHighScore::Ptr> Api::getGameHighScores(int32_t userId, int32_t score, return _tgTypeParser.parseJsonAndGetArray<GameHighScore>(&TgTypeParser::parseJsonAndGetGameHighScore, sendRequest("getGameHighScores", args)); } -void Api::deleteMessage(int64_t chatId, int32_t messageId) const { +void Api::deleteMessage(std::int64_t chatId, std::int32_t messageId) const { sendRequest("deleteMessage", { HttpReqArg("chat_id", chatId), HttpReqArg("message_id", messageId) }); } -Message::Ptr Api::sendPoll(int64_t chat_id, std::string question, std::vector<std::string> options, bool disable_notification, int32_t reply_to_message_id,GenericReply::Ptr reply_markup) const { +Message::Ptr Api::sendPoll(std::int64_t chat_id, std::string question, std::vector<std::string> options, bool disable_notification, std::int32_t reply_to_message_id,GenericReply::Ptr reply_markup) const { vector<HttpReqArg> args; args.reserve(6); args.emplace_back("chat_id", chat_id); @@ -1144,7 +1145,7 @@ Message::Ptr Api::sendPoll(int64_t chat_id, std::string question, std::vector<st return _tgTypeParser.parseJsonAndGetMessage(sendRequest("sendPoll", args)); } -Poll::Ptr Api::stopPoll(int64_t chatId, int64_t messageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { +Poll::Ptr Api::stopPoll(std::int64_t chatId, std::int64_t messageId, const InlineKeyboardMarkup::Ptr replyMarkup) const { vector<HttpReqArg> args; args.reserve(3); args.emplace_back("chat_id", chatId); diff --git a/src/net/HttpParser.cpp b/src/net/HttpParser.cpp index b83ddf0..386a4d9 100644 --- a/src/net/HttpParser.cpp +++ b/src/net/HttpParser.cpp @@ -1,5 +1,7 @@ #include "tgbot/net/HttpParser.h" +#include <cstdint> + #include <boost/algorithm/string.hpp> #include "tgbot/tools/StringTools.h" @@ -78,7 +80,7 @@ string HttpParser::generateMultipartFormData(const vector<HttpReqArg>& args, con string HttpParser::generateMultipartBoundary(const vector<HttpReqArg>& args) const { string result; - srand((uint32_t) time(nullptr)); + srand((std::uint32_t) time(nullptr)); for (const HttpReqArg& item : args) { if (item.isFile) { while (result.empty() || item.value.find(result) != string::npos) { diff --git a/src/net/TgLongPoll.cpp b/src/net/TgLongPoll.cpp index 913ffdf..0138620 100644 --- a/src/net/TgLongPoll.cpp +++ b/src/net/TgLongPoll.cpp @@ -1,12 +1,14 @@ #include "tgbot/net/TgLongPoll.h" +#include <cstdint> + namespace TgBot { -TgLongPoll::TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t limit, int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowupdates) +TgLongPoll::TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowupdates) : _api(api), _eventHandler(eventHandler), _limit(limit), _timeout(timeout), _allowupdates(allowupdates) { } -TgLongPoll::TgLongPoll(const Bot& bot, int32_t limit, int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowupdates) : +TgLongPoll::TgLongPoll(const Bot& bot, std::int32_t limit, std::int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowupdates) : TgLongPoll(&bot.getApi(), &bot.getEventHandler(), limit, timeout, allowupdates) { } |