Sorry folks. Been busy the last day or two so haven't been able to reply.
I think I explained the problem rather poorly in my original post. Let
me try and explain better.
If the request was coming directly into the framework and the framework
could provide the regex and the member function that should be called
this would be a non-issue and it would be easy to solve as described
above. But that is not the case.
The request actually comes into the framework via an SCGI protocol
handling class but the regex and the class containing the member
function which renders the HTML for the response is provided by the
user. I have no control over this (other than specifying conventions in
documentation of course).
So the problem is this:
HTTP Request -> HTTP Server -> SCGI Request - C++ Web Framework -> User
provided C++ code to match request to a regex and then call a member
function -> User provided C++ member function -> C++ Web Framework ->
SCGI Response -> HTTP Server -> HTTP Response
The only code I have control over is the C++ web framework. Somehow I
need to allow a user to extend the framework with a set of code that
will allow requests to be routed to a class which contains a member
function that renders HTML as a response (for those who know MVC this is
the view class).
I've been basing my design off the Django web framework which is written
in Python since I already know that but I'm having a hard time
converting things which make heavy use of Python's dynamism into the
more static C++ world.
For reference this is how Django deals with URLs:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
and this is what I was roughly hoping to emulate. The URL regex and the
views are provided by the user and the framework provides the code to
link the two together.
So it is not as simple as a if / else if / else branch since the
framework doesn't know ahead of time what is being provided by the user.
Hopefully that has explained things a little bit better.