The goals of the library are to provide a cross-platform API for writing CGI (+FastCGI) programs that can be super-fast, scalable, concise and maintainable. The major features of the library:
- Cross-platform - tested with MSVC 9.0 (XP & 7) and gcc 4.3 on Ubuntu linux.
- A consistent interface for the CGI and FastCGI protocols.
- Asynchronous I/O using Boost.Asio.
- Supports lazy-loading of requests.
- Uses existing conventions where practicable, especially with STL and Boost.
- Provides flexible access to all request data: environment, GET, POST, cookies, file uploads.
- An interface supporting exceptions or error codes for reporting errors.
- An implementation with minimal copying of data (ideally, data is allocated once and only once).
- Add-on that supports Google cTemplate (optional).
- Configurable support for strongly-typed sessions (optional).
- A traits-based library design to allow you to plug in your own internal implementations.
What's needed really are good, portable, modern C++ libraries for database programming, HTML templating, etc. If you use or wrote any particularly good ones, please email me at email@example.com. The examples herein are quite contrived, mainly since they don't use a database. As soon as a de-facto database library comes around, the examples can be fleshed out.
There are examples that *use* HTML templates. The library used for doing that is Google's ctemplate. That library is very focused on templating (not even necessarily HTML - it could be XML, JSON or even MSXML and it wouldn't make a difference) and it by far the best of its ilk that I know of.
This library has been developed to make CGI programming as easy in C++ as possible, with the explicit intention of exposing as much as reasonably possible to the programmer, in case they have a use for it. I think the examples shown in the linked docs above should be relatively straight-forward, even to those relatively new to C++, or programmers who have used Python before.
There are several Boost C++ libraries used in the core of this one:
- Boost.Asio - for I/O and asynchronous dispatching.
- Boost.Thread - for multithreaded FastCGI stuff.
- Boost.Regex - powerful regular expression library.
- Boost.System - for reporting errors.
- Boost.MPL - for template metaprogramming needs.
- Boost.Fusion - for holding the request data.
- Boost.Serialization - for the optional session support.
- Many other Boost libraries.
Apart from the examples - a couple of which require Google ctemplate and another couple that require Boost.Chrono (it's currently in the Boost SVN sandbox and used for timing requests) - there are no library dependencies apart from Boost. The code aims to be completely standard C++, wherever possible.
It's been tested on a 64bit Ubuntu linux machine and MSVC9.0 on Windows. There are some MSVC projects in the libs/cgi/build/msvc directory, made using MSVC 2008 (sorry, I don't have any other copy).