code cleanup

This commit is contained in:
lganzzzo 2018-10-13 19:41:32 +03:00
parent 46095a0daf
commit d9d125c0ea
22 changed files with 36 additions and 48 deletions

View File

@ -50,7 +50,7 @@ public: \
public: \
static std::shared_ptr<NAME> createShared(const std::shared_ptr<oatpp::web::client::RequestExecutor>& requestExecutor, \
const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& objectMapper){ \
return std::shared_ptr<NAME>(new NAME(requestExecutor, objectMapper)); \
return std::make_shared<NAME>(requestExecutor, objectMapper); \
}
// HEADER MACRO

View File

@ -48,18 +48,6 @@ OATPP_MACRO_API_CONTROLLER_PARAM(OATPP_MACRO_API_CONTROLLER_BODY_STRING, OATPP_M
#define BODY_DTO(TYPE, NAME) \
OATPP_MACRO_API_CONTROLLER_PARAM(OATPP_MACRO_API_CONTROLLER_BODY_DTO, OATPP_MACRO_API_CONTROLLER_BODY_DTO_INFO, TYPE, NAME, ())
// INIT // ------------------------------------------------------
#define REST_CONTROLLER_INIT(NAME) \
public: \
NAME() \
{} \
public: \
\
static std::shared_ptr<NAME> createShared(){ \
return std::shared_ptr<>(new NAME(); \
return object->getSharedPtr<NAME>(); \
}
// REQUEST MACRO // ------------------------------------------------------

View File

@ -43,7 +43,7 @@ public:
virtual ~Controllable();
static std::shared_ptr<Controllable> createShared(){
return std::shared_ptr<Controllable>(new Controllable);
return std::make_shared<Controllable>();
}
};

View File

@ -59,15 +59,15 @@ namespace oatpp { namespace parser {
{}
std::shared_ptr<ParsingCaret> ParsingCaret::createShared(const char* text){
return std::shared_ptr<ParsingCaret>(new ParsingCaret(text));
return std::make_shared<ParsingCaret>(text);
}
std::shared_ptr<ParsingCaret> ParsingCaret::createShared(p_char8 parseData, v_int32 dataSize){
return std::shared_ptr<ParsingCaret>(new ParsingCaret(parseData, dataSize));
return std::make_shared<ParsingCaret>(parseData, dataSize);
}
std::shared_ptr<ParsingCaret> ParsingCaret::createShared(const oatpp::String& str){
return std::shared_ptr<ParsingCaret>(new ParsingCaret(str->getData(), str->getSize()));
return std::make_shared<ParsingCaret>(str->getData(), str->getSize());
}
ParsingCaret::~ParsingCaret(){

View File

@ -41,7 +41,7 @@ public:
static std::shared_ptr<SimpleTCPConnectionProvider>
createShared(const oatpp::String& host, v_int32 port){
return std::shared_ptr<SimpleTCPConnectionProvider>(new SimpleTCPConnectionProvider(host, port));
return std::make_shared<SimpleTCPConnectionProvider>(host, port);
}
std::shared_ptr<IOStream> getConnection() override;

View File

@ -81,7 +81,7 @@ public:
static std::shared_ptr<Server> createShared(const std::shared_ptr<ServerConnectionProvider>& connectionProvider,
const std::shared_ptr<ConnectionHandler>& connectionHandler){
return std::shared_ptr<Server>(new Server(connectionProvider, connectionHandler));
return std::make_shared<Server>(connectionProvider, connectionHandler);
}
void run() override;

View File

@ -49,7 +49,7 @@ public:
public:
static std::shared_ptr<SimpleTCPConnectionProvider> createShared(v_word16 port, bool nonBlocking = false){
return std::shared_ptr<SimpleTCPConnectionProvider>(new SimpleTCPConnectionProvider(port, nonBlocking));
return std::make_shared<SimpleTCPConnectionProvider>(port, nonBlocking);
}
~SimpleTCPConnectionProvider() {

View File

@ -66,7 +66,7 @@ public:
public:
static std::shared_ptr<Config> createShared(){
return std::shared_ptr<Config>(new Config());
return std::make_shared<Config>();
}
bool allowUnknownFields = true;

View File

@ -50,7 +50,7 @@ public:
static std::shared_ptr<ObjectMapper>
createShared(const std::shared_ptr<Serializer::Config>& serializerConfig = Serializer::Config::createShared(),
const std::shared_ptr<Deserializer::Config>& deserializerConfig = Deserializer::Config::createShared()){
return std::shared_ptr<ObjectMapper>(new ObjectMapper(serializerConfig, deserializerConfig));
return std::make_shared<ObjectMapper>(serializerConfig, deserializerConfig);
}
void write(const std::shared_ptr<oatpp::data::stream::OutputStream>& stream,

View File

@ -58,13 +58,13 @@ public:
public:
class Config : public oatpp::base::Controllable {
protected:
public:
Config()
{}
public:
static std::shared_ptr<Config> createShared(){
return std::shared_ptr<Config>(new Config());
return std::make_shared<Config>();
}
bool includeNullFields = true;

View File

@ -42,7 +42,7 @@ public:
public:
static std::shared_ptr<TestObject> createShared2(){
return std::shared_ptr<TestObject>(new TestObject);
return std::make_shared<TestObject>();
}
static std::shared_ptr<TestObject> createShared(){

View File

@ -77,7 +77,7 @@ namespace {
{}
static std::shared_ptr<Task> createShared(const std::shared_ptr<TestBase>& shared){
return std::shared_ptr<Task>(new Task(shared));
return std::make_shared<Task>(shared);
}
void run() override {

View File

@ -128,7 +128,7 @@ public:
static std::shared_ptr<ApiClient> createShared(const std::shared_ptr<RequestExecutor>& requestExecutor,
const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& objectMapper) {
return std::shared_ptr<ApiClient>(new ApiClient(requestExecutor, objectMapper));
return std::make_shared<ApiClient>(requestExecutor, objectMapper);
}
protected:

View File

@ -33,7 +33,7 @@ namespace oatpp { namespace web { namespace client {
class HttpRequestExecutor : public oatpp::base::Controllable, public RequestExecutor {
protected:
std::shared_ptr<oatpp::network::ClientConnectionProvider> m_connectionProvider;
protected:
public:
HttpRequestExecutor(const std::shared_ptr<oatpp::network::ClientConnectionProvider>& connectionProvider)
: m_connectionProvider(connectionProvider)
{}
@ -41,7 +41,7 @@ public:
static std::shared_ptr<HttpRequestExecutor>
createShared(const std::shared_ptr<oatpp::network::ClientConnectionProvider>& connectionProvider){
return std::shared_ptr<HttpRequestExecutor>(new HttpRequestExecutor(connectionProvider));
return std::make_shared<HttpRequestExecutor>(connectionProvider);
}
/**

View File

@ -119,7 +119,7 @@ public:
public:
static std::shared_ptr<AsyncHttpConnectionHandler> createShared(const std::shared_ptr<HttpRouter>& router){
return std::shared_ptr<AsyncHttpConnectionHandler>(new AsyncHttpConnectionHandler(router));
return std::make_shared<AsyncHttpConnectionHandler>(router);
}
~AsyncHttpConnectionHandler(){

View File

@ -87,7 +87,7 @@ public:
public:
static std::shared_ptr<HttpConnectionHandler> createShared(const std::shared_ptr<HttpRouter>& router){
return std::shared_ptr<HttpConnectionHandler>(new HttpConnectionHandler(router));
return std::make_shared<HttpConnectionHandler>(router);
}
void setErrorHandler(const std::shared_ptr<handler::ErrorHandler>& errorHandler){

View File

@ -53,14 +53,14 @@ protected:
return entry->getValue();
}
protected:
public:
HttpRouter()
: m_branchMap(BranchMap::createShared())
{}
public:
static std::shared_ptr<HttpRouter> createShared() {
return std::shared_ptr<HttpRouter>(new HttpRouter());
return std::make_shared<HttpRouter>();
}
void addSubscriber(const oatpp::String& method,

View File

@ -104,7 +104,7 @@ protected:
T* m_controller;
Method m_method;
MethodAsync m_methodAsync;
protected:
public:
Handler(T* controller, Method method, MethodAsync methodAsync)
: m_controller(controller)
, m_method(method)
@ -113,7 +113,7 @@ protected:
public:
static std::shared_ptr<Handler> createShared(T* controller, Method method, MethodAsync methodAsync){
return std::shared_ptr<Handler>(new Handler(controller, method, methodAsync));
return std::make_shared<Handler>(controller, method, methodAsync);
}
std::shared_ptr<OutgoingResponse> processUrl(const std::shared_ptr<protocol::http::incoming::Request>& request) override {

View File

@ -74,7 +74,7 @@ public:
{}
public:
static std::shared_ptr<Info> createShared(){
return std::shared_ptr<Info>(new Info());
return std::make_shared<Info>();
}
oatpp::String name;
@ -121,7 +121,7 @@ public:
static std::shared_ptr<Endpoint> createShared(const std::shared_ptr<RequestHandler>& handler,
const std::shared_ptr<Info>& info){
return std::shared_ptr<Endpoint>(new Endpoint(handler, info));
return std::make_shared<Endpoint>(handler, info);
}
const std::shared_ptr<RequestHandler> handler;

View File

@ -46,7 +46,7 @@ public:
public:
static std::shared_ptr<DefaultErrorHandler> createShared() {
return std::shared_ptr<DefaultErrorHandler>(new DefaultErrorHandler());
return std::make_shared<DefaultErrorHandler>();
}
std::shared_ptr<protocol::http::outgoing::Response>

View File

@ -38,7 +38,7 @@ public:
class MatchMap : public base::Controllable{
public:
typedef oatpp::collection::ListMap<oatpp::String, oatpp::String> Variables;
protected:
public:
MatchMap(const std::shared_ptr<Variables>& vars, const oatpp::String& urlTail)
: variables(vars)
, tail(urlTail)
@ -47,7 +47,7 @@ public:
static std::shared_ptr<MatchMap> createShared(const std::shared_ptr<Variables>& vars,
const oatpp::String& tail){
return std::shared_ptr<MatchMap>(new MatchMap(vars, tail));
return std::make_shared<MatchMap>(vars, tail);
}
const Variables::Entry* getVariable(const oatpp::String& key){
@ -62,7 +62,7 @@ public:
private:
class Part : public base::Controllable{
protected:
public:
Part(const char* pFunction, const oatpp::String& pText)
: function(pFunction)
, text(pText)
@ -74,7 +74,7 @@ private:
static const char* FUNCTION_ANY_END;
static std::shared_ptr<Part> createShared(const char* function, const oatpp::String& text){
return std::shared_ptr<Part>(new Part(function, text));
return std::make_shared<Part>(function, text);
}
const char* function;
@ -86,14 +86,14 @@ private:
std::shared_ptr<oatpp::collection::LinkedList<std::shared_ptr<Part>>> m_parts;
private:
v_char8 findSysChar(oatpp::parser::ParsingCaret& caret);
protected:
public:
Pattern()
: m_parts(oatpp::collection::LinkedList<std::shared_ptr<Part>>::createShared())
{}
public:
static std::shared_ptr<Pattern> createShared(){
return std::shared_ptr<Pattern>(new Pattern());
return std::make_shared<Pattern>();
}
static std::shared_ptr<Pattern> parse(p_char8 data, v_int32 size);

View File

@ -80,7 +80,7 @@ public:
public:
class Pair : public base::Controllable{
protected:
public:
Pair(const std::shared_ptr<Pattern>& pPattern, const std::shared_ptr<UrlSubscriber>& pSubscriber)
: pattern(pPattern)
, subscriber(pSubscriber)
@ -88,7 +88,7 @@ public:
public:
static std::shared_ptr<Pair> createShared(const std::shared_ptr<Pattern>& pattern, const std::shared_ptr<UrlSubscriber>& subscriber){
return std::shared_ptr<Pair>(new Pair(pattern, subscriber));
return std::make_shared<Pair>(pattern, subscriber);
}
const std::shared_ptr<Pattern> pattern;
@ -98,14 +98,14 @@ public:
private:
std::shared_ptr<oatpp::collection::LinkedList<std::shared_ptr<Pair>>> m_subscribers;
protected:
public:
Router()
: m_subscribers(oatpp::collection::LinkedList<std::shared_ptr<Pair>>::createShared())
{}
public:
static std::shared_ptr<Router> createShared(){
return std::shared_ptr<Router>(new Router());
return std::make_shared<Router>();
}
void addSubscriber(const oatpp::String& urlPattern,