audio_trans/cmake-build-debug/drogon_ctl/plugin_h.cc

106 lines
3.7 KiB
C++
Raw Normal View History

2025-04-07 11:31:21 +08:00
//this file is generated by program(drogon_ctl) automatically,don't modify it!
#include "plugin_h.h"
#include <drogon/utils/OStringStream.h>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <list>
#include <deque>
#include <queue>
using namespace drogon;
std::string plugin_h::genText(const DrTemplateData& plugin_h_view_data)
{
drogon::OStringStream plugin_h_tmp_stream;
std::string layoutName{""};
plugin_h_tmp_stream << "/**\n";
plugin_h_tmp_stream << " *\n";
plugin_h_tmp_stream << " * ";
{
auto & val=plugin_h_view_data["filename"];
if(val.type()==typeid(const char *)){
plugin_h_tmp_stream<<*any_cast<const char *>(&val);
}else if(val.type()==typeid(std::string)||val.type()==typeid(const std::string)){
plugin_h_tmp_stream<<*any_cast<const std::string>(&val);
}
}
plugin_h_tmp_stream << ".h\n";
plugin_h_tmp_stream << " *\n";
plugin_h_tmp_stream << " */\n";
plugin_h_tmp_stream<<"\n";
plugin_h_tmp_stream << "#pragma once\n";
plugin_h_tmp_stream<<"\n";
plugin_h_tmp_stream << "#include <drogon/plugins/Plugin.h>\n";
auto namespaceVector=plugin_h_view_data.get<std::vector<std::string>>("namespaceVector");
if(namespaceVector.empty())
plugin_h_tmp_stream<<"\n";
for(auto &namespaceName:namespaceVector){
plugin_h_tmp_stream << "namespace ";
plugin_h_tmp_stream<<namespaceName;
plugin_h_tmp_stream<<"\n";
plugin_h_tmp_stream << "{\n";
}
plugin_h_tmp_stream<<"\n";
plugin_h_tmp_stream << "class ";
{
auto & val=plugin_h_view_data["className"];
if(val.type()==typeid(const char *)){
plugin_h_tmp_stream<<*any_cast<const char *>(&val);
}else if(val.type()==typeid(std::string)||val.type()==typeid(const std::string)){
plugin_h_tmp_stream<<*any_cast<const std::string>(&val);
}
}
plugin_h_tmp_stream << " : public drogon::Plugin<";
{
auto & val=plugin_h_view_data["className"];
if(val.type()==typeid(const char *)){
plugin_h_tmp_stream<<*any_cast<const char *>(&val);
}else if(val.type()==typeid(std::string)||val.type()==typeid(const std::string)){
plugin_h_tmp_stream<<*any_cast<const std::string>(&val);
}
}
plugin_h_tmp_stream << ">\n";
plugin_h_tmp_stream << "{\n";
plugin_h_tmp_stream << " public:\n";
plugin_h_tmp_stream << " ";
{
auto & val=plugin_h_view_data["className"];
if(val.type()==typeid(const char *)){
plugin_h_tmp_stream<<*any_cast<const char *>(&val);
}else if(val.type()==typeid(std::string)||val.type()==typeid(const std::string)){
plugin_h_tmp_stream<<*any_cast<const std::string>(&val);
}
}
plugin_h_tmp_stream << "() {}\n";
plugin_h_tmp_stream << " /// This method must be called by drogon to initialize and start the plugin.\n";
plugin_h_tmp_stream << " /// It must be implemented by the user.\n";
plugin_h_tmp_stream << " void initAndStart(const Json::Value &config) override;\n";
plugin_h_tmp_stream<<"\n";
plugin_h_tmp_stream << " /// This method must be called by drogon to shutdown the plugin.\n";
plugin_h_tmp_stream << " /// It must be implemented by the user.\n";
plugin_h_tmp_stream << " void shutdown() override;\n";
plugin_h_tmp_stream << "};\n";
plugin_h_tmp_stream<<"\n";
for(size_t i=0;i<namespaceVector.size();i++){
plugin_h_tmp_stream << "}\n";
}
if(layoutName.empty())
{
std::string ret{std::move(plugin_h_tmp_stream.str())};
return ret;
}else
{
auto templ = DrTemplateBase::newTemplate(layoutName);
if(!templ) return "";
HttpViewData data = plugin_h_view_data;
auto str = std::move(plugin_h_tmp_stream.str());
if(!str.empty() && str[str.length()-1] == '\n') str.resize(str.length()-1);
data[""] = std::move(str);
return templ->genText(data);
}
}