mirror of
https://github.com/UltraCoderRU/telebotxx.git
synced 2026-01-28 04:05:13 +00:00
Source code reformated.
This commit is contained in:
parent
81bb25f4fe
commit
592751a50c
23 changed files with 1118 additions and 1069 deletions
|
|
@ -6,8 +6,8 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class Attachment
|
||||
{
|
||||
public:
|
||||
|
|
@ -212,6 +212,7 @@ namespace telebotxx
|
|||
void swap(Audio& lhs, Audio& rhs);
|
||||
void swap(Document& lhs, Document& rhs);
|
||||
void swap(Sticker& lhs, Sticker& rhs);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_ATTACHMENT_HPP
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef TELEBOTXX_BOTAPI_H
|
||||
#define TELEBOTXX_BOTAPI_H
|
||||
#ifndef TELEBOTXX_BOTAPI_HPP
|
||||
#define TELEBOTXX_BOTAPI_HPP
|
||||
|
||||
#include "User.hpp"
|
||||
#include "Message.hpp"
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
template <typename RequestType, typename T>
|
||||
void setRequestOption(RequestType& request, T t)
|
||||
{
|
||||
|
|
@ -89,6 +89,7 @@ namespace telebotxx
|
|||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_BOTAPI_H
|
||||
#endif // TELEBOTXX_BOTAPI_HPP
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
#include <memory>
|
||||
#include <cstdint>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class Chat
|
||||
{
|
||||
public:
|
||||
|
|
@ -63,6 +63,7 @@ namespace telebotxx
|
|||
void swap(Chat& lhs, Chat& rhs);
|
||||
|
||||
Chat::Type chatTypeFromString(const std::string& str);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_CHAT_HPP
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class ParseError : public std::invalid_argument
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#ifndef TELEBOTXX_LOGGING_HPP
|
||||
#define TELEBOTXX_LOGGING_HPP
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
extern bool debugMode;
|
||||
|
||||
/// \brief Enable/disable debug output
|
||||
void setDebugMode(bool enabled);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_LOGGING_HPP
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class MessageEntity
|
||||
{
|
||||
public:
|
||||
|
|
@ -180,6 +180,7 @@ namespace telebotxx
|
|||
};
|
||||
|
||||
void swap(Message& lhs, Message& rhs);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_MESSAGE_HPP
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class ChatId
|
||||
{
|
||||
public:
|
||||
|
|
@ -126,6 +126,7 @@ namespace telebotxx
|
|||
Url url_;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_REQUEST_OPTIONS_HPP
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
#include <telebotxx/RequestOptions.hpp>
|
||||
#include <telebotxx/Message.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class SendMessageRequest
|
||||
{
|
||||
public:
|
||||
|
|
@ -33,6 +31,7 @@ namespace telebotxx
|
|||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_SEND_MESSAGE_REQUEST_HPP
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
#include <telebotxx/RequestOptions.hpp>
|
||||
#include <telebotxx/Message.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class SendPhotoRequest
|
||||
{
|
||||
public:
|
||||
|
|
@ -20,6 +18,7 @@ namespace telebotxx
|
|||
void setCaption(const Caption& caption);
|
||||
void setDisableNotification(const DisableNotification& disableNotification);
|
||||
void setReplyToMessageId(const ReplyTo& replyToMessageId);
|
||||
|
||||
void setOption(const Caption& caption);
|
||||
void setOption(const DisableNotification& disableNotification);
|
||||
void setOption(const ReplyTo& replyToMessageId);
|
||||
|
|
@ -30,6 +29,7 @@ namespace telebotxx
|
|||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_SEND_PHOTO_REQUEST_HPP
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class Update
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
class User
|
||||
{
|
||||
public:
|
||||
|
|
@ -55,6 +55,7 @@ namespace telebotxx
|
|||
using UserPtr = std::shared_ptr<User>;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const User& user);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_USER_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <telebotxx/Attachment.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
Attachment::Attachment(Type type)
|
||||
: attachmentType_(type)
|
||||
|
|
@ -8,7 +8,9 @@ Attachment::Attachment(Type type)
|
|||
}
|
||||
|
||||
Attachment::Attachment(const Attachment&) = default;
|
||||
|
||||
Attachment::Attachment(Attachment&&) = default;
|
||||
|
||||
Attachment::~Attachment() = default;
|
||||
|
||||
Attachment::Type Attachment::getType() const
|
||||
|
|
@ -31,7 +33,9 @@ PhotoSize::PhotoSize()
|
|||
}
|
||||
|
||||
PhotoSize::PhotoSize(const PhotoSize&) = default;
|
||||
|
||||
PhotoSize::PhotoSize(PhotoSize&&) = default;
|
||||
|
||||
PhotoSize::~PhotoSize() = default;
|
||||
|
||||
const std::string& PhotoSize::getFileId() const
|
||||
|
|
@ -97,7 +101,9 @@ PhotoSizeArray::PhotoSizeArray()
|
|||
}
|
||||
|
||||
PhotoSizeArray::PhotoSizeArray(const PhotoSizeArray&) = default;
|
||||
|
||||
PhotoSizeArray::PhotoSizeArray(PhotoSizeArray&&) = default;
|
||||
|
||||
PhotoSizeArray::~PhotoSizeArray() = default;
|
||||
|
||||
const std::vector<PhotoSize>& PhotoSizeArray::getArray() const
|
||||
|
|
@ -132,7 +138,9 @@ Audio::Audio()
|
|||
}
|
||||
|
||||
Audio::Audio(const Audio&) = default;
|
||||
|
||||
Audio::Audio(Audio&&) = default;
|
||||
|
||||
Audio::~Audio() = default;
|
||||
|
||||
const std::string& Audio::getFileId() const
|
||||
|
|
@ -222,7 +230,9 @@ Document::Document()
|
|||
}
|
||||
|
||||
Document::Document(const Document&) = default;
|
||||
|
||||
Document::Document(Document&&) = default;
|
||||
|
||||
Document::~Document() = default;
|
||||
|
||||
const std::string& Document::getFileId() const
|
||||
|
|
@ -301,7 +311,9 @@ Sticker::Sticker()
|
|||
}
|
||||
|
||||
Sticker::Sticker(const Sticker&) = default;
|
||||
|
||||
Sticker::Sticker(Sticker&&) = default;
|
||||
|
||||
Sticker::~Sticker() = default;
|
||||
|
||||
const std::string& Sticker::getFileId() const
|
||||
|
|
@ -384,27 +396,29 @@ const Sticker& Sticker::operator=(Sticker other) noexcept
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void telebotxx::swap(PhotoSize& lhs, PhotoSize& rhs)
|
||||
void swap(PhotoSize& lhs, PhotoSize& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
void telebotxx::swap(PhotoSizeArray& lhs, PhotoSizeArray& rhs)
|
||||
void swap(PhotoSizeArray& lhs, PhotoSizeArray& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
void telebotxx::swap(Audio& lhs, Audio& rhs)
|
||||
void swap(Audio& lhs, Audio& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
void telebotxx::swap(Document& lhs, Document& rhs)
|
||||
void swap(Document& lhs, Document& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
void telebotxx::swap(Sticker& lhs, Sticker& rhs)
|
||||
void swap(Sticker& lhs, Sticker& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <cpr/cpr.h>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
class BotApi::Impl
|
||||
{
|
||||
|
|
@ -181,3 +181,5 @@ std::string BotApi::getTelegramMainUrl() const
|
|||
{
|
||||
return impl_->getTelegramMainUrl();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
10
src/Chat.cpp
10
src/Chat.cpp
|
|
@ -1,7 +1,7 @@
|
|||
#include <telebotxx/Chat.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
Chat::Chat()
|
||||
: id_(-1),
|
||||
|
|
@ -11,7 +11,9 @@ Chat::Chat()
|
|||
}
|
||||
|
||||
Chat::Chat(const Chat&) = default;
|
||||
|
||||
Chat::Chat(Chat&&) = default;
|
||||
|
||||
Chat::~Chat() = default;
|
||||
|
||||
std::int64_t Chat::getId() const
|
||||
|
|
@ -102,12 +104,12 @@ const Chat& Chat::operator=(Chat other) noexcept
|
|||
return *this;
|
||||
}
|
||||
|
||||
void telebotxx::swap(Chat& lhs, Chat& rhs)
|
||||
void swap(Chat& lhs, Chat& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
Chat::Type telebotxx::chatTypeFromString(const std::string& str)
|
||||
Chat::Type chatTypeFromString(const std::string& str)
|
||||
{
|
||||
if (str == "private")
|
||||
return Chat::Type::Private;
|
||||
|
|
@ -120,3 +122,5 @@ Chat::Type telebotxx::chatTypeFromString(const std::string& str)
|
|||
else
|
||||
throw std::invalid_argument("Unknown chat type");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
namespace telebotxx {
|
||||
namespace impl {
|
||||
|
||||
template<typename T> bool is(const rapidjson::Value& obj);
|
||||
template<> bool is<int>(const rapidjson::Value& obj) { return obj.IsInt(); }
|
||||
template<> bool is<std::int64_t>(const rapidjson::Value& obj) { return obj.IsInt64(); }
|
||||
|
|
@ -24,6 +23,7 @@ namespace telebotxx
|
|||
template<> const std::int64_t null() { return 0; }
|
||||
template<> const bool null() { return false; }
|
||||
template<> const std::string null() { return ""; }
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -312,4 +312,5 @@ namespace telebotxx
|
|||
throw ApiError(code, description);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
const bool REQUIRED = true;
|
||||
const bool OPTIONAL = false;
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ namespace telebotxx
|
|||
/// Throws an exception if error code recieved.
|
||||
/// \param doc reference to JSON document
|
||||
void checkResponse(const rapidjson::Document& doc);
|
||||
|
||||
}
|
||||
|
||||
#endif // TELEBOTXX_JSON_OBJECTS_HPP
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#include <telebotxx/Logging.hpp>
|
||||
|
||||
namespace telebotxx
|
||||
{
|
||||
namespace telebotxx {
|
||||
|
||||
bool debugMode = false;
|
||||
|
||||
void setDebugMode(bool enabled)
|
||||
{
|
||||
debugMode = enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <telebotxx/Message.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
MessageEntity::MessageEntity()
|
||||
: type_(Type::Mention),
|
||||
|
|
@ -10,7 +10,9 @@ MessageEntity::MessageEntity()
|
|||
}
|
||||
|
||||
MessageEntity::MessageEntity(const MessageEntity&) = default;
|
||||
|
||||
MessageEntity::MessageEntity(MessageEntity&&) = default;
|
||||
|
||||
MessageEntity::~MessageEntity() = default;
|
||||
|
||||
MessageEntity::Type MessageEntity::getType() const
|
||||
|
|
@ -79,7 +81,7 @@ const MessageEntity& MessageEntity::operator=(MessageEntity other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
MessageEntity::Type telebotxx::messageEntityTypeFromString(const std::string& str)
|
||||
MessageEntity::Type messageEntityTypeFromString(const std::string& str)
|
||||
{
|
||||
if (str == "mention")
|
||||
return MessageEntity::Type::Mention;
|
||||
|
|
@ -113,7 +115,9 @@ Message::Message()
|
|||
}
|
||||
|
||||
Message::Message(const Message&) = default;
|
||||
|
||||
Message::Message(Message&&) = default;
|
||||
|
||||
Message::~Message() = default;
|
||||
|
||||
int Message::getId() const
|
||||
|
|
@ -391,7 +395,9 @@ const Message& Message::operator=(Message other) noexcept
|
|||
return *this;
|
||||
}
|
||||
|
||||
void telebotxx::swap(Message& lhs, Message& rhs)
|
||||
void swap(Message& lhs, Message& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <telebotxx/RequestOptions.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
ChatId::ChatId(int id)
|
||||
: type_(Type::Id), id_(id)
|
||||
|
|
@ -235,3 +235,5 @@ const Url& Photo::getUrl() const
|
|||
{
|
||||
return url_;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
#include <rapidjson/writer.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
class SendMessageRequest::Impl
|
||||
{
|
||||
|
|
@ -61,7 +62,8 @@ public:
|
|||
if (parseMode_)
|
||||
{
|
||||
writer.String("parse_mode");
|
||||
writer.String((parseMode_ == ParseMode::Markdown) ? "Markdown" : (parseMode_ == ParseMode::Html) ? "HTML" : "Plain");
|
||||
writer.String(
|
||||
(parseMode_ == ParseMode::Markdown) ? "Markdown" : (parseMode_ == ParseMode::Html) ? "HTML" : "Plain");
|
||||
}
|
||||
|
||||
// Add disable_web_page_preview
|
||||
|
|
@ -173,3 +175,5 @@ Message SendMessageRequest::execute()
|
|||
{
|
||||
return impl_->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include <telebotxx/SendPhotoRequest.hpp>
|
||||
|
||||
#include <telebotxx/Logging.hpp>
|
||||
#include "JsonObjects.hpp"
|
||||
|
||||
|
|
@ -8,8 +7,9 @@
|
|||
#include <rapidjson/writer.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
class SendPhotoRequest::Impl
|
||||
{
|
||||
|
|
@ -137,3 +137,5 @@ Message SendPhotoRequest::execute()
|
|||
{
|
||||
return impl_->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <telebotxx/Update.hpp>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
Update::Update(int id, Type type)
|
||||
: id_(id),
|
||||
|
|
@ -80,3 +80,5 @@ const EditedMessageUpdate& EditedMessageUpdate::operator=(EditedMessageUpdate ot
|
|||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <telebotxx/User.hpp>
|
||||
#include <sstream>
|
||||
|
||||
using namespace telebotxx;
|
||||
namespace telebotxx {
|
||||
|
||||
User::User()
|
||||
: id_(-1)
|
||||
|
|
@ -9,7 +9,9 @@ User::User()
|
|||
}
|
||||
|
||||
User::User(const User&) = default;
|
||||
|
||||
User::User(User&&) = default;
|
||||
|
||||
User::~User() = default;
|
||||
|
||||
int User::getId() const
|
||||
|
|
@ -73,8 +75,10 @@ const User& User::operator=(User other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
std::ostream& telebotxx::operator<<(std::ostream& os, const User& user)
|
||||
std::ostream& operator<<(std::ostream& os, const User& user)
|
||||
{
|
||||
os << user.toString();
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue