diff --git a/drogon_ctl/create_view.cc b/drogon_ctl/create_view.cc index 227e75ae..b7100eee 100755 --- a/drogon_ctl/create_view.cc +++ b/drogon_ctl/create_view.cc @@ -25,8 +25,8 @@ static const std::string cxx_end = "%>"; static const std::string cxx_lang = "<%c++"; static const std::string cxx_view_data = "@@"; static const std::string cxx_output = "$$"; -static const std::string cxx_val_start = "{{"; -static const std::string cxx_val_end = "}}"; +static const std::string cxx_val_start = "[["; +static const std::string cxx_val_end = "]]"; static const std::string sub_view_start = "<%view"; static const std::string sub_view_end = "%>"; diff --git a/drogon_ctl/templates/cmake.csp b/drogon_ctl/templates/cmake.csp index 2fd1f99a..fb1645bd 100644 --- a/drogon_ctl/templates/cmake.csp +++ b/drogon_ctl/templates/cmake.csp @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.2) -Project({{ProjectName}}) +Project([[ProjectName]]) link_directories(/usr/local/lib) link_libraries(drogon trantor pthread dl) @@ -103,4 +103,4 @@ foreach(cspFile ${SCP_LIST}) endforeach() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_executable({{ProjectName}} ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC}) +add_executable([[ProjectName]] ${SRC_DIR} ${CTL_SRC} ${FILTER_SRC} ${VIEWSRC} ${PLUGIN_SRC} ${MODEL_SRC}) diff --git a/drogon_ctl/templates/filter_cc.csp b/drogon_ctl/templates/filter_cc.csp index d32eae60..1be6ecac 100644 --- a/drogon_ctl/templates/filter_cc.csp +++ b/drogon_ctl/templates/filter_cc.csp @@ -1,10 +1,10 @@ /** * - * {{filename}}.cc + * [[filename]].cc * */ -#include "{{filename}}.h" +#include "[[filename]].h" using namespace drogon; <%c++auto namespaceStr=@@.get("namespaceString"); @@ -12,7 +12,7 @@ if(!namespaceStr.empty()) $$<<"using namespace "< -void {{className}}::doFilter(const HttpRequestPtr &req, +void [[className]]::doFilter(const HttpRequestPtr &req, const FilterCallback &fcb, const FilterChainCallback &fccb) { diff --git a/drogon_ctl/templates/filter_h.csp b/drogon_ctl/templates/filter_h.csp index 08ae4c94..d7678f2c 100644 --- a/drogon_ctl/templates/filter_h.csp +++ b/drogon_ctl/templates/filter_h.csp @@ -1,6 +1,6 @@ /** * - * {{filename}}.h + * [[filename]].h * */ @@ -18,10 +18,10 @@ namespace {%namespaceName%} { <%c++} $$<<"\n";%> -class {{className}} : public HttpFilter<{{className}}> +class [[className]] : public HttpFilter<[[className]]> { public: - {{className}}() {} + [[className]]() {} virtual void doFilter(const HttpRequestPtr &req, const FilterCallback &fcb, const FilterChainCallback &fccb) override; diff --git a/drogon_ctl/templates/model_cc.csp b/drogon_ctl/templates/model_cc.csp index a17a2309..ba700ec5 100644 --- a/drogon_ctl/templates/model_cc.csp +++ b/drogon_ctl/templates/model_cc.csp @@ -3,12 +3,12 @@ using namespace drogon_ctl; %> /** * - * {{className}}.cc + * [[className]].cc * DO NOT EDIT. This file is generated by drogon_ctl * */ -#include "{{className}}.h" +#include "[[className]].h" #include #include #include @@ -17,17 +17,17 @@ using namespace drogon_ctl; auto className=@@.get("className"); %> -using namespace drogon_model::{{dbName}}; +using namespace drogon_model::[[dbName]]; <%c++for(auto col:cols){ %> -const std::string {{className}}::Cols::{%col._colName%} = "{%col._colName%}"; +const std::string [[className]]::Cols::{%col._colName%} = "{%col._colName%}"; <%c++ }%> <%c++if(@@.get("hasPrimaryKey")<=1){%> -const std::string {{className}}::primaryKeyName = "{{primaryKeyName}}"; +const std::string [[className]]::primaryKeyName = "[[primaryKeyName]]"; <%c++}else{%> -const std::vector {{className}}::primaryKeyName = {<%c++ +const std::vector [[className]]::primaryKeyName = {<%c++ auto pkName=@@.get>("primaryKeyName"); for(size_t i=0;i}; <%c++}%> <%c++ if(@@.get("hasPrimaryKey",0)>0){%> -const bool {{className}}::hasPrimaryKey = true; +const bool [[className]]::hasPrimaryKey = true; <%c++ }else{%> -const bool {{className}}::hasPrimaryKey = false; +const bool [[className]]::hasPrimaryKey = false; <%c++}%> -const std::string {{className}}::tableName = "{{tableName}}"; +const std::string [[className]]::tableName = "[[tableName]]"; -const std::vector {{className}}::_metaData={ +const std::vector [[className]]::_metaData={ <%c++for(size_t i=0;i }; -const std::string &{{className}}::getColumnName(size_t index) noexcept(false) +const std::string &[[className]]::getColumnName(size_t index) noexcept(false) { assert(index < _metaData.size()); return _metaData[index]._colName; } -{{className}}::{{className}}(const Row &r) noexcept +[[className]]::[[className]](const Row &r) noexcept { <%c++ for(auto col:cols) @@ -110,7 +110,7 @@ const std::string &{{className}}::getColumnName(size_t index) noexcept(false) $$<<" if(str.length()>=2&&\n"; $$<<" str[0]=='\\\\'&&str[1]=='x')\n"; $$<<" {\n"; - $$<<" _"<>(drogon::hexToBinaryVector(str.data()+2,str.length()-2));\n"; + $$<<" _"<>(drogon::utils::hexToBinaryVector(str.data()+2,str.length()-2));\n"; $$<<" }\n"; $$<<" }\n"; continue; @@ -233,7 +233,7 @@ const std::string &{{className}}::getColumnName(size_t index) noexcept(false) } %> -const std::vector &{{className}}::insertColumns() noexcept +const std::vector &[[className]]::insertColumns() noexcept { static const std::vector _inCols={ <%c++for(size_t i=0;i &{{className}}::insertColumns() noexcept return _inCols; } -void {{className}}::outputArgs(drogon::orm::internal::SqlBinder &binder) const +void [[className]]::outputArgs(drogon::orm::internal::SqlBinder &binder) const { <%c++for(auto col:cols){ if(!col._isAutoVal&&!col._colType.empty()) @@ -271,7 +271,7 @@ void {{className}}::outputArgs(drogon::orm::internal::SqlBinder &binder) const %> } -const std::vector {{className}}::updateColumns() const +const std::vector [[className]]::updateColumns() const { std::vector ret; for(size_t i=0;i {{className}}::updateColumns() const return ret; } -void {{className}}::updateArgs(drogon::orm::internal::SqlBinder &binder) const +void [[className]]::updateArgs(drogon::orm::internal::SqlBinder &binder) const { <%c++ for(size_t i=0;i } -Json::Value {{className}}::toJson() const +Json::Value [[className]]::toJson() const { Json::Value ret; <%c++for(auto col:cols){%> @@ -319,7 +319,7 @@ Json::Value {{className}}::toJson() const <%c++}else if(col._colDatabaseType.find("timestamp")!=std::string::npos||col._colDatabaseType.find("datetime")!=std::string::npos){%> ret["{%col._colName%}"]=get{%col._colTypeName%}()->toDbStringLocal(); <%c++}else if(col._colDatabaseType=="bytea"||col._colDatabaseType.find("blob")!=std::string::npos){%> - ret["{%col._colName%}"]=drogon::base64Encode((const unsigned char *)get{%col._colTypeName%}()->data(),get{%col._colTypeName%}()->size()); + ret["{%col._colName%}"]=drogon::utils::base64Encode((const unsigned char *)get{%col._colTypeName%}()->data(),get{%col._colTypeName%}()->size()); <%c++}else if(col._colType=="int64_t"){%> ret["{%col._colName%}"]=(Json::Int64)getValueOf{%col._colTypeName%}(); <%c++}else if(col._colType=="uint64_t"){%> diff --git a/drogon_ctl/templates/model_h.csp b/drogon_ctl/templates/model_h.csp index a985ea10..433089cc 100644 --- a/drogon_ctl/templates/model_h.csp +++ b/drogon_ctl/templates/model_h.csp @@ -3,7 +3,7 @@ using namespace drogon_ctl; %> /** * - * {{className}}.h + * [[className]].h * DO NOT EDIT. This file is generated by drogon_ctl * */ @@ -26,10 +26,10 @@ using namespace drogon::orm; namespace drogon_model { -namespace {{dbName}} +namespace [[dbName]] { -class {{className}} +class [[className]] { public: struct Cols @@ -49,7 +49,7 @@ auto cols=@@.get>("columns"); <%c++if(@@.get("hasPrimaryKey")<=1){%> const static std::string primaryKeyName; <%c++if(!@@.get("primaryKeyType").empty()){%> - typedef {{primaryKeyType}} PrimaryKeyType; + typedef [[primaryKeyType]] PrimaryKeyType; const PrimaryKeyType & getPrimaryKey() const; <%c++}else{%> typedef void PrimaryKeyType; @@ -77,8 +77,8 @@ auto cols=@@.get>("columns"); PrimaryKeyType getPrimaryKey() const; <%c++}%> - {{className}}(const Row &r) noexcept; - {{className}}() = default; + [[className]](const Row &r) noexcept; + [[className]]() = default; <%c++ for(auto col:cols) @@ -119,7 +119,7 @@ auto cols=@@.get>("columns"); Json::Value toJson() const; private: - friend Mapper<{{className}}>; + friend Mapper<[[className]]>; static const std::vector &insertColumns() noexcept; void outputArgs(drogon::orm::internal::SqlBinder &binder) const; const std::vector updateColumns() const; @@ -147,5 +147,5 @@ auto cols=@@.get>("columns"); bool _dirtyFlag[{%cols.size()%}]={ false }; }; -} // namespace {{dbName}} +} // namespace [[dbName]] } // namespace drogon_model diff --git a/drogon_ctl/templates/plugin_cc.csp b/drogon_ctl/templates/plugin_cc.csp index f7c9ab1f..718ad626 100644 --- a/drogon_ctl/templates/plugin_cc.csp +++ b/drogon_ctl/templates/plugin_cc.csp @@ -1,10 +1,10 @@ /** * - * {{filename}}.cc + * [[filename]].cc * */ -#include "{{filename}}.h" +#include "[[filename]].h" using namespace drogon; <%c++auto namespaceStr=@@.get("namespaceString"); @@ -12,12 +12,12 @@ if(!namespaceStr.empty()) $$<<"using namespace "< -void {{className}}::initAndStart(const Json::Value &config) +void [[className]]::initAndStart(const Json::Value &config) { /// Initialize and start the plugin } -void {{className}}::shutdown() +void [[className]]::shutdown() { /// Shutdown the plugin } diff --git a/drogon_ctl/templates/plugin_h.csp b/drogon_ctl/templates/plugin_h.csp index 33813cd0..7a835e89 100644 --- a/drogon_ctl/templates/plugin_h.csp +++ b/drogon_ctl/templates/plugin_h.csp @@ -1,6 +1,6 @@ /** * - * {{filename}}.h + * [[filename]].h * */ @@ -18,10 +18,10 @@ namespace {%namespaceName%} { <%c++} $$<<"\n";%> -class {{className}} : public Plugin<{{className}}> +class [[className]] : public Plugin<[[className]]> { public: - {{className}}() {} + [[className]]() {} /// This method must be called by drogon to initialize and start the plugin. /// It must be implemented by the user. virtual void initAndStart(const Json::Value &config) override; diff --git a/examples/simple_example/ListParaView.csp b/examples/simple_example/ListParaView.csp index 68ef5864..879f783e 100755 --- a/examples/simple_example/ListParaView.csp +++ b/examples/simple_example/ListParaView.csp @@ -5,7 +5,7 @@ %> - {{ title }} + [[ title ]] <%view header %>