Re: [Cppcms-users] Why hello_world::main() gets called automatically?
Brought to you by:
artyom-beilis
From: David E. <dav...@gm...> - 2010-08-21 07:18:14
|
It's a part of the interface. The base cmsapplication you are inheriting from specifies that method. Other parts of cms call that method, except since you override it, your method gets called... On Aug 21, 2010 3:11 AM, <cn...@gr...> wrote: 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 ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |