2018-05-31 17:00:31 +08:00
|
|
|
/**
|
|
|
|
*
|
2018-10-30 18:43:11 +08:00
|
|
|
* create_controller.h
|
|
|
|
* An Tao
|
2018-05-31 17:00:31 +08:00
|
|
|
*
|
|
|
|
* Copyright 2018, An Tao. All rights reserved.
|
2018-12-07 15:50:18 +08:00
|
|
|
* https://github.com/an-tao/drogon
|
2018-05-31 17:00:31 +08:00
|
|
|
* Use of this source code is governed by a MIT license
|
|
|
|
* that can be found in the License file.
|
|
|
|
*
|
2018-11-16 13:26:14 +08:00
|
|
|
* Drogon
|
2018-05-31 17:00:31 +08:00
|
|
|
*
|
|
|
|
*/
|
2018-05-29 13:49:26 +08:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <drogon/DrObject.h>
|
2019-09-30 21:34:30 +08:00
|
|
|
#include <drogon/DrTemplateBase.h>
|
2018-05-29 13:49:26 +08:00
|
|
|
#include "CommandHandler.h"
|
|
|
|
using namespace drogon;
|
|
|
|
namespace drogon_ctl
|
|
|
|
{
|
2019-05-18 20:39:57 +08:00
|
|
|
class create_controller : public DrObject<create_controller>,
|
|
|
|
public CommandHandler
|
2018-10-14 15:56:54 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void handleCommand(std::vector<std::string> ¶meters) override;
|
2019-05-18 20:39:57 +08:00
|
|
|
virtual std::string script() override
|
|
|
|
{
|
|
|
|
return "create controller files";
|
|
|
|
}
|
2018-08-22 14:27:45 +08:00
|
|
|
|
2018-10-14 15:56:54 +08:00
|
|
|
protected:
|
|
|
|
enum ControllerType
|
|
|
|
{
|
|
|
|
Simple = 0,
|
2018-11-15 14:31:10 +08:00
|
|
|
Http,
|
2019-09-30 21:34:30 +08:00
|
|
|
WebSocket,
|
|
|
|
Restful
|
2018-10-14 15:56:54 +08:00
|
|
|
};
|
2018-08-22 14:27:45 +08:00
|
|
|
|
2019-05-18 20:39:57 +08:00
|
|
|
void createController(std::vector<std::string> &httpClasses,
|
|
|
|
ControllerType type);
|
2018-12-15 21:21:39 +08:00
|
|
|
void createController(const std::string &className, ControllerType type);
|
2019-09-30 21:34:30 +08:00
|
|
|
void createARestfulController(const std::string &className,
|
|
|
|
const std::string &resource);
|
2018-12-15 21:21:39 +08:00
|
|
|
|
2019-05-18 20:39:57 +08:00
|
|
|
void newSimpleControllerHeaderFile(std::ofstream &file,
|
|
|
|
const std::string &className);
|
|
|
|
void newSimpleControllerSourceFile(std::ofstream &file,
|
|
|
|
const std::string &className,
|
|
|
|
const std::string &filename);
|
2018-12-15 21:21:39 +08:00
|
|
|
|
2019-05-18 20:39:57 +08:00
|
|
|
void newWebsockControllerHeaderFile(std::ofstream &file,
|
|
|
|
const std::string &className);
|
|
|
|
void newWebsockControllerSourceFile(std::ofstream &file,
|
|
|
|
const std::string &className,
|
|
|
|
const std::string &filename);
|
2018-06-06 18:29:05 +08:00
|
|
|
|
2019-05-18 20:39:57 +08:00
|
|
|
void newHttpControllerHeaderFile(std::ofstream &file,
|
|
|
|
const std::string &className);
|
|
|
|
void newHttpControllerSourceFile(std::ofstream &file,
|
|
|
|
const std::string &className,
|
|
|
|
const std::string &filename);
|
2018-10-14 15:56:54 +08:00
|
|
|
};
|
2019-05-18 20:39:57 +08:00
|
|
|
} // namespace drogon_ctl
|