FastDo是一个强大的C++跨平台开发库,能助您快速的开发服务端程序,Web应用及网页。
ecp翻译的时候需要一个源码模板才能生成源文件。源码模板你可以自定义,关键的替换用占位符分别是:{{defcode}},{{code}},{{impcode}},分别表示定义代码,内嵌代码,实现代码。
下面是默认的do文件源代码模板内容:
#ifdef _MSC_VER
#define DLL_API __declspec(dllexport)
#elif __GNUC__
#define DLL_API
#endif
#include "fcgiplus.hpp"
#include "eiendb.hpp"
#include <iostream>
using namespace std;
using namespace winux;
using namespace eiendb;
using namespace FCGI;
#define GET_PARAM(type) ((type)__param)
{{defcode}}
DLL_API int WebMain( Response * __rsp, void * __param )
{
Response & RSP = *__rsp;
Request & REQ = __rsp->req;
#if defined(__GNUC__) && !defined(WIN32) // on linux
SetLocale::set("zh_CN.UTF-8");
#endif
SetLocale __loc__;
try
{
{{code}}
}
catch ( std::exception const & e )
{
cout << e.what() << endl;
}
catch (...)
{
cout << "Unknown error" << endl;
}
return 0;
}
{{impcode}}
修改do文件源代码模板,你可以增加你自己的代码,函数,类到里面,或者是第三方库等等。每一个Web页面生成都能使用它们。还可以修改Response和Request变量名称,方便在Web页面中使用。这里默认是RSP,REQ。
FastDo现在还能生成普通的可执行文件。为此,ecp需要一个新的源代码模板以产生可执行文件源码。
下面是默认的可执行文件模板内容:
#include "fcgiplus.hpp"
#include "eiendb.hpp"
#include <iostream>
using namespace std;
using namespace winux;
using namespace eiendb;
{{defcode}}
int main( int argc, char * argv[] )
{
#if defined(__GNUC__) && !defined(WIN32) // on linux
SetLocale::set("zh_CN.UTF-8");
#endif
SetLocale __loc__;
try
{
{{code}}
}
catch ( std::exception const & e )
{
cout << e.what() << endl;
}
catch (...)
{
cout << "Unknown error" << endl;
}
return 0;
}
{{impcode}}
同样可以增加你自己的代码,函数,类到里面,或者是第三方库等等。