Source code reformated.

This commit is contained in:
Kirill Kirilenko 2017-02-15 20:22:18 +03:00
parent 81bb25f4fe
commit 592751a50c
23 changed files with 1118 additions and 1069 deletions

View file

@ -6,8 +6,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
namespace telebotxx namespace telebotxx {
{
class Attachment class Attachment
{ {
public: public:
@ -212,6 +212,7 @@ namespace telebotxx
void swap(Audio& lhs, Audio& rhs); void swap(Audio& lhs, Audio& rhs);
void swap(Document& lhs, Document& rhs); void swap(Document& lhs, Document& rhs);
void swap(Sticker& lhs, Sticker& rhs); void swap(Sticker& lhs, Sticker& rhs);
} }
#endif // TELEBOTXX_ATTACHMENT_HPP #endif // TELEBOTXX_ATTACHMENT_HPP

View file

@ -1,5 +1,5 @@
#ifndef TELEBOTXX_BOTAPI_H #ifndef TELEBOTXX_BOTAPI_HPP
#define TELEBOTXX_BOTAPI_H #define TELEBOTXX_BOTAPI_HPP
#include "User.hpp" #include "User.hpp"
#include "Message.hpp" #include "Message.hpp"
@ -10,8 +10,8 @@
#include <string> #include <string>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
template <typename RequestType, typename T> template <typename RequestType, typename T>
void setRequestOption(RequestType& request, T t) void setRequestOption(RequestType& request, T t)
{ {
@ -89,6 +89,7 @@ namespace telebotxx
class Impl; class Impl;
std::unique_ptr<Impl> impl_; std::unique_ptr<Impl> impl_;
}; };
} }
#endif // TELEBOTXX_BOTAPI_H #endif // TELEBOTXX_BOTAPI_HPP

View file

@ -5,8 +5,8 @@
#include <memory> #include <memory>
#include <cstdint> #include <cstdint>
namespace telebotxx namespace telebotxx {
{
class Chat class Chat
{ {
public: public:
@ -63,6 +63,7 @@ namespace telebotxx
void swap(Chat& lhs, Chat& rhs); void swap(Chat& lhs, Chat& rhs);
Chat::Type chatTypeFromString(const std::string& str); Chat::Type chatTypeFromString(const std::string& str);
} }
#endif // TELEBOTXX_CHAT_HPP #endif // TELEBOTXX_CHAT_HPP

View file

@ -3,8 +3,8 @@
#include <stdexcept> #include <stdexcept>
namespace telebotxx namespace telebotxx {
{
class ParseError : public std::invalid_argument class ParseError : public std::invalid_argument
{ {
public: public:

View file

@ -1,12 +1,13 @@
#ifndef TELEBOTXX_LOGGING_HPP #ifndef TELEBOTXX_LOGGING_HPP
#define TELEBOTXX_LOGGING_HPP #define TELEBOTXX_LOGGING_HPP
namespace telebotxx namespace telebotxx {
{
extern bool debugMode; extern bool debugMode;
/// \brief Enable/disable debug output /// \brief Enable/disable debug output
void setDebugMode(bool enabled); void setDebugMode(bool enabled);
} }
#endif // TELEBOTXX_LOGGING_HPP #endif // TELEBOTXX_LOGGING_HPP

View file

@ -9,8 +9,8 @@
#include <ctime> #include <ctime>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
class MessageEntity class MessageEntity
{ {
public: public:
@ -180,6 +180,7 @@ namespace telebotxx
}; };
void swap(Message& lhs, Message& rhs); void swap(Message& lhs, Message& rhs);
} }
#endif // TELEBOTXX_MESSAGE_HPP #endif // TELEBOTXX_MESSAGE_HPP

View file

@ -4,8 +4,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace telebotxx namespace telebotxx {
{
class ChatId class ChatId
{ {
public: public:
@ -126,6 +126,7 @@ namespace telebotxx
Url url_; Url url_;
}; };
}; };
} }
#endif // TELEBOTXX_REQUEST_OPTIONS_HPP #endif // TELEBOTXX_REQUEST_OPTIONS_HPP

View file

@ -4,13 +4,11 @@
#include <telebotxx/RequestOptions.hpp> #include <telebotxx/RequestOptions.hpp>
#include <telebotxx/Message.hpp> #include <telebotxx/Message.hpp>
#include <boost/optional.hpp>
#include <string> #include <string>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
class SendMessageRequest class SendMessageRequest
{ {
public: public:
@ -33,6 +31,7 @@ namespace telebotxx
class Impl; class Impl;
std::unique_ptr<Impl> impl_; std::unique_ptr<Impl> impl_;
}; };
} }
#endif // TELEBOTXX_SEND_MESSAGE_REQUEST_HPP #endif // TELEBOTXX_SEND_MESSAGE_REQUEST_HPP

View file

@ -4,13 +4,11 @@
#include <telebotxx/RequestOptions.hpp> #include <telebotxx/RequestOptions.hpp>
#include <telebotxx/Message.hpp> #include <telebotxx/Message.hpp>
#include <boost/optional.hpp>
#include <string> #include <string>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
class SendPhotoRequest class SendPhotoRequest
{ {
public: public:
@ -20,6 +18,7 @@ namespace telebotxx
void setCaption(const Caption& caption); void setCaption(const Caption& caption);
void setDisableNotification(const DisableNotification& disableNotification); void setDisableNotification(const DisableNotification& disableNotification);
void setReplyToMessageId(const ReplyTo& replyToMessageId); void setReplyToMessageId(const ReplyTo& replyToMessageId);
void setOption(const Caption& caption); void setOption(const Caption& caption);
void setOption(const DisableNotification& disableNotification); void setOption(const DisableNotification& disableNotification);
void setOption(const ReplyTo& replyToMessageId); void setOption(const ReplyTo& replyToMessageId);
@ -30,6 +29,7 @@ namespace telebotxx
class Impl; class Impl;
std::unique_ptr<Impl> impl_; std::unique_ptr<Impl> impl_;
}; };
} }
#endif // TELEBOTXX_SEND_PHOTO_REQUEST_HPP #endif // TELEBOTXX_SEND_PHOTO_REQUEST_HPP

View file

@ -6,8 +6,8 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
class Update class Update
{ {
public: public:

View file

@ -4,8 +4,8 @@
#include <string> #include <string>
#include <memory> #include <memory>
namespace telebotxx namespace telebotxx {
{
class User class User
{ {
public: public:
@ -55,6 +55,7 @@ namespace telebotxx
using UserPtr = std::shared_ptr<User>; using UserPtr = std::shared_ptr<User>;
std::ostream& operator<<(std::ostream& os, const User& user); std::ostream& operator<<(std::ostream& os, const User& user);
} }
#endif // TELEBOTXX_USER_H #endif // TELEBOTXX_USER_H

View file

@ -1,6 +1,6 @@
#include <telebotxx/Attachment.hpp> #include <telebotxx/Attachment.hpp>
using namespace telebotxx; namespace telebotxx {
Attachment::Attachment(Type type) Attachment::Attachment(Type type)
: attachmentType_(type) : attachmentType_(type)
@ -8,7 +8,9 @@ Attachment::Attachment(Type type)
} }
Attachment::Attachment(const Attachment&) = default; Attachment::Attachment(const Attachment&) = default;
Attachment::Attachment(Attachment&&) = default; Attachment::Attachment(Attachment&&) = default;
Attachment::~Attachment() = default; Attachment::~Attachment() = default;
Attachment::Type Attachment::getType() const Attachment::Type Attachment::getType() const
@ -31,7 +33,9 @@ PhotoSize::PhotoSize()
} }
PhotoSize::PhotoSize(const PhotoSize&) = default; PhotoSize::PhotoSize(const PhotoSize&) = default;
PhotoSize::PhotoSize(PhotoSize&&) = default; PhotoSize::PhotoSize(PhotoSize&&) = default;
PhotoSize::~PhotoSize() = default; PhotoSize::~PhotoSize() = default;
const std::string& PhotoSize::getFileId() const const std::string& PhotoSize::getFileId() const
@ -97,7 +101,9 @@ PhotoSizeArray::PhotoSizeArray()
} }
PhotoSizeArray::PhotoSizeArray(const PhotoSizeArray&) = default; PhotoSizeArray::PhotoSizeArray(const PhotoSizeArray&) = default;
PhotoSizeArray::PhotoSizeArray(PhotoSizeArray&&) = default; PhotoSizeArray::PhotoSizeArray(PhotoSizeArray&&) = default;
PhotoSizeArray::~PhotoSizeArray() = default; PhotoSizeArray::~PhotoSizeArray() = default;
const std::vector<PhotoSize>& PhotoSizeArray::getArray() const const std::vector<PhotoSize>& PhotoSizeArray::getArray() const
@ -132,7 +138,9 @@ Audio::Audio()
} }
Audio::Audio(const Audio&) = default; Audio::Audio(const Audio&) = default;
Audio::Audio(Audio&&) = default; Audio::Audio(Audio&&) = default;
Audio::~Audio() = default; Audio::~Audio() = default;
const std::string& Audio::getFileId() const const std::string& Audio::getFileId() const
@ -222,7 +230,9 @@ Document::Document()
} }
Document::Document(const Document&) = default; Document::Document(const Document&) = default;
Document::Document(Document&&) = default; Document::Document(Document&&) = default;
Document::~Document() = default; Document::~Document() = default;
const std::string& Document::getFileId() const const std::string& Document::getFileId() const
@ -301,7 +311,9 @@ Sticker::Sticker()
} }
Sticker::Sticker(const Sticker&) = default; Sticker::Sticker(const Sticker&) = default;
Sticker::Sticker(Sticker&&) = default; Sticker::Sticker(Sticker&&) = default;
Sticker::~Sticker() = default; Sticker::~Sticker() = default;
const std::string& Sticker::getFileId() const 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); lhs.swap(rhs);
} }
void telebotxx::swap(PhotoSizeArray& lhs, PhotoSizeArray& rhs) void swap(PhotoSizeArray& lhs, PhotoSizeArray& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
void telebotxx::swap(Audio& lhs, Audio& rhs) void swap(Audio& lhs, Audio& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
void telebotxx::swap(Document& lhs, Document& rhs) void swap(Document& lhs, Document& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
void telebotxx::swap(Sticker& lhs, Sticker& rhs) void swap(Sticker& lhs, Sticker& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
}

View file

@ -10,7 +10,7 @@
#include <cpr/cpr.h> #include <cpr/cpr.h>
using namespace telebotxx; namespace telebotxx {
class BotApi::Impl class BotApi::Impl
{ {
@ -181,3 +181,5 @@ std::string BotApi::getTelegramMainUrl() const
{ {
return impl_->getTelegramMainUrl(); return impl_->getTelegramMainUrl();
} }
}

View file

@ -1,7 +1,7 @@
#include <telebotxx/Chat.hpp> #include <telebotxx/Chat.hpp>
#include <stdexcept> #include <stdexcept>
using namespace telebotxx; namespace telebotxx {
Chat::Chat() Chat::Chat()
: id_(-1), : id_(-1),
@ -11,7 +11,9 @@ Chat::Chat()
} }
Chat::Chat(const Chat&) = default; Chat::Chat(const Chat&) = default;
Chat::Chat(Chat&&) = default; Chat::Chat(Chat&&) = default;
Chat::~Chat() = default; Chat::~Chat() = default;
std::int64_t Chat::getId() const std::int64_t Chat::getId() const
@ -102,12 +104,12 @@ const Chat& Chat::operator=(Chat other) noexcept
return *this; return *this;
} }
void telebotxx::swap(Chat& lhs, Chat& rhs) void swap(Chat& lhs, Chat& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
Chat::Type telebotxx::chatTypeFromString(const std::string& str) Chat::Type chatTypeFromString(const std::string& str)
{ {
if (str == "private") if (str == "private")
return Chat::Type::Private; return Chat::Type::Private;
@ -120,3 +122,5 @@ Chat::Type telebotxx::chatTypeFromString(const std::string& str)
else else
throw std::invalid_argument("Unknown chat type"); throw std::invalid_argument("Unknown chat type");
} }
}

View file

@ -3,10 +3,9 @@
#include <cstdint> #include <cstdint>
namespace telebotxx namespace telebotxx {
{ namespace impl {
namespace impl
{
template<typename T> bool is(const rapidjson::Value& obj); template<typename T> bool is(const rapidjson::Value& obj);
template<> bool is<int>(const rapidjson::Value& obj) { return obj.IsInt(); } template<> bool is<int>(const rapidjson::Value& obj) { return obj.IsInt(); }
template<> bool is<std::int64_t>(const rapidjson::Value& obj) { return obj.IsInt64(); } 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 std::int64_t null() { return 0; }
template<> const bool null() { return false; } template<> const bool null() { return false; }
template<> const std::string null() { return ""; } template<> const std::string null() { return ""; }
} }
template<typename T> template<typename T>
@ -312,4 +312,5 @@ namespace telebotxx
throw ApiError(code, description); throw ApiError(code, description);
} }
} }
} }

View file

@ -10,8 +10,8 @@
#include <rapidjson/document.h> #include <rapidjson/document.h>
namespace telebotxx namespace telebotxx {
{
const bool REQUIRED = true; const bool REQUIRED = true;
const bool OPTIONAL = false; const bool OPTIONAL = false;
@ -48,6 +48,7 @@ namespace telebotxx
/// Throws an exception if error code recieved. /// Throws an exception if error code recieved.
/// \param doc reference to JSON document /// \param doc reference to JSON document
void checkResponse(const rapidjson::Document& doc); void checkResponse(const rapidjson::Document& doc);
} }
#endif // TELEBOTXX_JSON_OBJECTS_HPP #endif // TELEBOTXX_JSON_OBJECTS_HPP

View file

@ -1,11 +1,12 @@
#include <telebotxx/Logging.hpp> #include <telebotxx/Logging.hpp>
namespace telebotxx namespace telebotxx {
{
bool debugMode = false; bool debugMode = false;
void setDebugMode(bool enabled) void setDebugMode(bool enabled)
{ {
debugMode = enabled; debugMode = enabled;
} }
} }

View file

@ -1,6 +1,6 @@
#include <telebotxx/Message.hpp> #include <telebotxx/Message.hpp>
using namespace telebotxx; namespace telebotxx {
MessageEntity::MessageEntity() MessageEntity::MessageEntity()
: type_(Type::Mention), : type_(Type::Mention),
@ -10,7 +10,9 @@ MessageEntity::MessageEntity()
} }
MessageEntity::MessageEntity(const MessageEntity&) = default; MessageEntity::MessageEntity(const MessageEntity&) = default;
MessageEntity::MessageEntity(MessageEntity&&) = default; MessageEntity::MessageEntity(MessageEntity&&) = default;
MessageEntity::~MessageEntity() = default; MessageEntity::~MessageEntity() = default;
MessageEntity::Type MessageEntity::getType() const MessageEntity::Type MessageEntity::getType() const
@ -79,7 +81,7 @@ const MessageEntity& MessageEntity::operator=(MessageEntity other)
return *this; return *this;
} }
MessageEntity::Type telebotxx::messageEntityTypeFromString(const std::string& str) MessageEntity::Type messageEntityTypeFromString(const std::string& str)
{ {
if (str == "mention") if (str == "mention")
return MessageEntity::Type::Mention; return MessageEntity::Type::Mention;
@ -113,7 +115,9 @@ Message::Message()
} }
Message::Message(const Message&) = default; Message::Message(const Message&) = default;
Message::Message(Message&&) = default; Message::Message(Message&&) = default;
Message::~Message() = default; Message::~Message() = default;
int Message::getId() const int Message::getId() const
@ -391,7 +395,9 @@ const Message& Message::operator=(Message other) noexcept
return *this; return *this;
} }
void telebotxx::swap(Message& lhs, Message& rhs) void swap(Message& lhs, Message& rhs)
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
}

View file

@ -1,6 +1,6 @@
#include <telebotxx/RequestOptions.hpp> #include <telebotxx/RequestOptions.hpp>
using namespace telebotxx; namespace telebotxx {
ChatId::ChatId(int id) ChatId::ChatId(int id)
: type_(Type::Id), id_(id) : type_(Type::Id), id_(id)
@ -235,3 +235,5 @@ const Url& Photo::getUrl() const
{ {
return url_; return url_;
} }
}

View file

@ -7,8 +7,9 @@
#include <rapidjson/writer.h> #include <rapidjson/writer.h>
#include <iostream> #include <iostream>
#include <boost/optional.hpp>
using namespace telebotxx; namespace telebotxx {
class SendMessageRequest::Impl class SendMessageRequest::Impl
{ {
@ -61,7 +62,8 @@ public:
if (parseMode_) if (parseMode_)
{ {
writer.String("parse_mode"); 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 // Add disable_web_page_preview
@ -173,3 +175,5 @@ Message SendMessageRequest::execute()
{ {
return impl_->execute(); return impl_->execute();
} }
}

View file

@ -1,5 +1,4 @@
#include <telebotxx/SendPhotoRequest.hpp> #include <telebotxx/SendPhotoRequest.hpp>
#include <telebotxx/Logging.hpp> #include <telebotxx/Logging.hpp>
#include "JsonObjects.hpp" #include "JsonObjects.hpp"
@ -8,8 +7,9 @@
#include <rapidjson/writer.h> #include <rapidjson/writer.h>
#include <iostream> #include <iostream>
#include <boost/optional.hpp>
using namespace telebotxx; namespace telebotxx {
class SendPhotoRequest::Impl class SendPhotoRequest::Impl
{ {
@ -137,3 +137,5 @@ Message SendPhotoRequest::execute()
{ {
return impl_->execute(); return impl_->execute();
} }
}

View file

@ -1,6 +1,6 @@
#include <telebotxx/Update.hpp> #include <telebotxx/Update.hpp>
using namespace telebotxx; namespace telebotxx {
Update::Update(int id, Type type) Update::Update(int id, Type type)
: id_(id), : id_(id),
@ -80,3 +80,5 @@ const EditedMessageUpdate& EditedMessageUpdate::operator=(EditedMessageUpdate ot
swap(other); swap(other);
return *this; return *this;
} }
}

View file

@ -1,7 +1,7 @@
#include <telebotxx/User.hpp> #include <telebotxx/User.hpp>
#include <sstream> #include <sstream>
using namespace telebotxx; namespace telebotxx {
User::User() User::User()
: id_(-1) : id_(-1)
@ -9,7 +9,9 @@ User::User()
} }
User::User(const User&) = default; User::User(const User&) = default;
User::User(User&&) = default; User::User(User&&) = default;
User::~User() = default; User::~User() = default;
int User::getId() const int User::getId() const
@ -73,8 +75,10 @@ const User& User::operator=(User other)
return *this; return *this;
} }
std::ostream& telebotxx::operator<<(std::ostream& os, const User& user) std::ostream& operator<<(std::ostream& os, const User& user)
{ {
os << user.toString(); os << user.toString();
return os; return os;
} }
}