Declaring a Command in a Parse Map

OverviewHow Do I

The rest of this article is a continuing example of a parse map. The code examples demonstrate the parsing of a URL string, specifying default and required parameters, and using optional parameters. The example uses these elements:

Element Name
Server MOOSE
Server DLL SURVEY.DLL
CHttpServer object CServerDerived
Command RegisterUser
User name Richard M. Jones

The following parse map declares a single command, RegisterUser. This command accepts only one parameter: a pointer to a string:

BEGIN_PARSE_MAP( CServerDerived, CHttpServer )
ON_PARSE_COMMAND( RegisterUser, CServerDerived, ITS_PSTR )
END_PARSE_MAP( CServerDerived )

The corresponding command handler, RegisterUser, is a member of the CServerDerived class, and must be declared as follows:

CServerDerived::RegisterUser( CHttpServerContext* pCtxt, LPCTSTR pstrParameter )
{
   // do work here!
}

The first parameter of the handling member function must be a pointer to a CHttpServerContext object.

What do you want to know more about?