interfaceをチョットいじった

This commit is contained in:
keita
2021-02-21 22:51:15 +09:00
parent 788eda9d4a
commit 255536209c
10 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
#include <cocoatweet/api/favorite/create.h> #include <cocoatweet/api/favorite/create.h>
#include <iostream>
namespace CocoaTweet::API::Favorites { namespace CocoaTweet::API::Favorites {
Create::Create() { Create::Create() {
contentType_ = "application/x-www-form-urlencoded"; contentType_ = "application/x-www-form-urlencoded";
@@ -11,7 +11,7 @@ void Create::id(const std::string& _id) {
} }
void Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { void Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth, HttpPost::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; }); [](const std::string& _srv) { std::cout << _srv << std::endl; });
} }
} // namespace CocoaTweet::API::Favorites } // namespace CocoaTweet::API::Favorites
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef COCOATWEET_API_FAVORITE_CREATE_H_ #ifndef COCOATWEET_API_FAVORITE_CREATE_H_
#define COCOATWEET_API_FAVORITE_CREATE_H_ #define COCOATWEET_API_FAVORITE_CREATE_H_
#include <cocoatweet/api/interface/postInterface.h> #include <cocoatweet/api/interface/httpPost.h>
namespace CocoaTweet::API::Favorites { namespace CocoaTweet::API::Favorites {
class Create : public CocoaTweet::API::Interface::postInterface { class Create : public CocoaTweet::API::Interface::HttpPost {
public: public:
Create(); Create();
void id(const std::string& _id); void id(const std::string& _id);
+2 -2
View File
@@ -1,5 +1,5 @@
#include <cocoatweet/api/favorite/destroy.h> #include <cocoatweet/api/favorite/destroy.h>
#include <iostream>
namespace CocoaTweet::API::Favorites { namespace CocoaTweet::API::Favorites {
Destroy::Destroy() { Destroy::Destroy() {
contentType_ = "application/x-www-form-urlencoded"; contentType_ = "application/x-www-form-urlencoded";
@@ -11,7 +11,7 @@ void Destroy::id(const std::string& _id) {
} }
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth, HttpPost::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; }); [](const std::string& _srv) { std::cout << _srv << std::endl; });
} }
} // namespace CocoaTweet::API::Favorites } // namespace CocoaTweet::API::Favorites
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef COCOATWEET_API_FAVORITE_DESTROY_H_ #ifndef COCOATWEET_API_FAVORITE_DESTROY_H_
#define COCOATWEET_API_FAVORITE_DESTROY_H_ #define COCOATWEET_API_FAVORITE_DESTROY_H_
#include <cocoatweet/api/interface/postInterface.h> #include <cocoatweet/api/interface/httpPost.h>
namespace CocoaTweet::API::Favorites { namespace CocoaTweet::API::Favorites {
class Destroy : public CocoaTweet::API::Interface::postInterface { class Destroy : public CocoaTweet::API::Interface::HttpPost {
public: public:
Destroy(); Destroy();
void id(const std::string& _id); void id(const std::string& _id);
@@ -1,4 +1,4 @@
#include <cocoatweet/api/interface/postInterface.h> #include <cocoatweet/api/interface/httpPost.h>
#include "cocoatweet/util/util.h" #include "cocoatweet/util/util.h"
#include <iterator> #include <iterator>
#include <memory> #include <memory>
@@ -10,14 +10,14 @@ extern "C" {
} }
namespace CocoaTweet::API::Interface { namespace CocoaTweet::API::Interface {
size_t postInterface::curlCallback_(char* _ptr, size_t _size, size_t _nmemb, size_t HttpPost::curlCallback_(char* _ptr, size_t _size, size_t _nmemb,
std::string* _stream) { std::string* _stream) {
int realsize = _size * _nmemb; int realsize = _size * _nmemb;
_stream->append(_ptr, realsize); _stream->append(_ptr, realsize);
return realsize; return realsize;
} }
void postInterface::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth, void HttpPost::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth,
std::function<void(std::string)> _callback) { std::function<void(std::string)> _callback) {
// エンドポイントへのパラメータにOAuthパラメータを付加して署名作成 // エンドポイントへのパラメータにOAuthパラメータを付加して署名作成
auto oauth = _oauth.lock(); auto oauth = _oauth.lock();
@@ -3,11 +3,11 @@
#include <functional> #include <functional>
#include "cocoatweet/oauth/oauth.h" #include "cocoatweet/oauth/oauth.h"
#include <iostream>
namespace CocoaTweet::API::Interface { namespace CocoaTweet::API::Interface {
class postInterface { class HttpPost {
public: public:
protected: protected:
std::weak_ptr<CocoaTweet::OAuth::OAuth1> oauth_; std::weak_ptr<CocoaTweet::OAuth::OAuth1> oauth_;
std::map<std::string, std::string> bodyParam_; std::map<std::string, std::string> bodyParam_;
+2 -2
View File
@@ -1,5 +1,5 @@
#include "cocoatweet/api/status/destroy.h" #include "cocoatweet/api/status/destroy.h"
#include <iostream>
namespace CocoaTweet::API::Statuses { namespace CocoaTweet::API::Statuses {
Destroy::Destroy() {} Destroy::Destroy() {}
void Destroy::id(const std::string _id) { void Destroy::id(const std::string _id) {
@@ -8,7 +8,7 @@ void Destroy::id(const std::string _id) {
} }
void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { void Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth, HttpPost::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; }); [](const std::string& _srv) { std::cout << _srv << std::endl; });
} }
+2 -2
View File
@@ -3,11 +3,11 @@
#include <memory> #include <memory>
#include "cocoatweet/api/interface/postInterface.h" #include "cocoatweet/api/interface/httpPost.h"
//#include "cocoatweet/oauth/oauth.h" //#include "cocoatweet/oauth/oauth.h"
namespace CocoaTweet::API::Statuses { namespace CocoaTweet::API::Statuses {
class Destroy : public CocoaTweet::API::Interface::postInterface { class Destroy : public CocoaTweet::API::Interface::HttpPost {
public: public:
Destroy(); Destroy();
void id(const std::string _id); void id(const std::string _id);
+2 -1
View File
@@ -1,4 +1,5 @@
#include "cocoatweet/api/status/update.h" #include "cocoatweet/api/status/update.h"
#include <iostream>
namespace CocoaTweet::API::Statuses { namespace CocoaTweet::API::Statuses {
Update::Update() { Update::Update() {
@@ -11,7 +12,7 @@ void Update::status(const std::string _status) {
} }
void Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) { void Update::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
postInterface::process(_oauth, HttpPost::process(_oauth,
[](const std::string& _srv) { std::cout << _srv << std::endl; }); [](const std::string& _srv) { std::cout << _srv << std::endl; });
} }
+2 -3
View File
@@ -2,12 +2,11 @@
#define COCOATWEET_API_STATUSES_UPDATE_H_ #define COCOATWEET_API_STATUSES_UPDATE_H_
#include <memory> #include <memory>
#include "cocoatweet/api/interface/httpPost.h"
#include "cocoatweet/api/interface/postInterface.h"
//#include "cocoatweet/oauth/oauth.h" //#include "cocoatweet/oauth/oauth.h"
namespace CocoaTweet::API::Statuses { namespace CocoaTweet::API::Statuses {
class Update : public CocoaTweet::API::Interface::postInterface { class Update : public CocoaTweet::API::Interface::HttpPost {
public: public:
Update(); Update();
void status(const std::string _status); void status(const std::string _status);