[Cppcms-users] Why hello_world::main() gets called automatically?
Brought to you by:
artyom-beilis
|
From: <cn...@gr...> - 2010-08-21 07:11:01
|
Hi!
The original example "Hello, World!" code follows:
------------------
class my_hello_world : public cppcms::application {
public:
my_hello_world(cppcms::service &srv) :
cppcms::application(srv)
{
}
virtual void main(std::string url);
};
void my_hello_world::main(std::string /*url*/)
{
response().out()<<
"<html>\n"
"<body>\n"
" <h1>Hello World</h1>\n"
"</body>\n"
"</html>\n";
}
int main(int argc,char ** argv)
{
try {
cppcms::service srv(argc,argv);
srv.applications_pool().mount(cppcms::applications_factory<my_hello_world>());
srv.run();
}
catch(std::exception const &e) {
std::cerr<<e.what()<<std::endl;
}
}
-------------
What I don't understand is why member function
void my_hello_world::main(std::string)
is called automatically when client requests the URL.
I changed the member function name "main" to "xmain" as below, then it stops working:
-------------
class my_hello_world : public cppcms::application {
public:
my_hello_world(cppcms::service &srv) : cppcms::application(srv)
{
}
virtual void xmain(std::string url);
};
void my_hello_world::xmain(std::string /*url*/)
...
-------------
Does this belong to cppCMS coding convention or something else?
Best Regards,
CN
|