|
Boost-Commit : |
From: lists.drrngrvy_at_[hidden]
Date: 2008-05-21 12:06:48
Author: drrngrvy
Date: 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
New Revision: 45610
URL: http://svn.boost.org/trac/boost/changeset/45610
Log:
* Adding ability to compile a library by passing --build-cgi on the bjam command line (seems to work).
* Fixing examples and tests as per refactoring.
Text files modified:
sandbox/SOC/2007/cgi/trunk/libs/cgi/build/Jamfile.v2 | 47 +++++++++++++++++++++++-
sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk | 4 +
sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/reference.qbk | 75 ++++++++++++++++++++-------------------
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/Jamfile.v2 | 1
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/amortization/main.cpp | 14 +++---
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/cookie_game/main.cpp | 13 +++---
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/echo/main.cpp | 3 +
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/hello_world/main.cpp | 1
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp | 23 ++++++-----
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server1/main.cpp | 8 ++--
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server2/main.cpp | 67 +++++++++++++++++------------------
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server3/main.cpp | 10 +++--
sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server4/main.cpp | 1
sandbox/SOC/2007/cgi/trunk/libs/cgi/test/compile/response.cpp | 2
sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/cookie.cpp | 2
sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/response.cpp | 2
16 files changed, 161 insertions(+), 112 deletions(-)
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/build/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/build/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/build/Jamfile.v2 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -5,7 +5,7 @@
project boost/cgi
: build-dir
$(top)/bin.v2
- : usage-requirements
+ : requirements
<include>$(top)
<include>$(boost-root)
<library>/boost/thread/
@@ -13,9 +13,50 @@
<library>/boost/regex/
<define>_CRT_SECURE_NO_WARNINGS
<define>_SCL_SECURE_NO_WARNINGS
+ : usage-requirements
+ <include>$(top)
+ <include>$(boost-root)
+ <library>/boost/thread/
+ <library>/boost/system/
+ <library>/boost/regex/
+ <linkflags>-pthread
;
-alias boost_cgi ;
+import modules ;
+
+# make BB recognise .ipp files as .cpp files.
+import type ;
+type.register IPP : ipp : CPP ;
+
+path-constant incl : $(top)/boost/cgi/ ;
+
+SOURCES =
+ $(incl)/impl/form_parser.ipp
+ $(incl)/impl/response.ipp
+ ;
+
+
+if [ MATCH "^(--build-cgi)" : [ modules.peek : ARGV ] ] # compile library
+{
+ ECHO "Building CGI library" ;
+
+ lib boost_cgi
+ :
+ $(SOURCES)
+ :
+ <define>BOOST_CGI_BUILD_LIBRARY
+ ;
+}
+else
+{
+ alias boost_cgi ;
+}
+
+install install
+ :
+ boost_cgi
+ :
+ <location>/usr/local/lib
+ ;
-#lib boost_cgi : $(top)/boost/cgi/common/form_parser.cpp ;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/cgi.qbk 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -111,7 +111,9 @@
[/include:ug user_guide.qbk]
-[xinclude ../cgi_dox.xml]
+[/xinclude ../cgi_dox.xml]
+
+[include:reference reference.qbk]
[include:future future_development.qbk]
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/reference.qbk
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/reference.qbk (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/doc/src/reference.qbk 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -7,57 +7,58 @@
[section:ref Reference]
-[xinclude:doxygen cgi_dox.xml]
+[xinclude ../cgi_dox.xml]
-[section:quick Quick Reference]
+[h2 Quick Reference]
Reference coming...
Requests
- - Request Data
- - environment
- - operator[""]
- - operator[env][""]
- - member functions
- - script_name()
- - request_method()
- - content_length()
- - content_encoding()
- - etc...
- - GET
- - POST
- - form (transparent GET/POST)
- - cookie
- - constructors
- - load()
- - async_load()
- - close()
- - clear()
- - id()
- - client()
+
+ * Request Data
+ * environment
+ * operator[""] (operator[] on the environment map)
+ * operator[env] (request meta-data)
+ * operator[get] (GET data)
+ * operator[post] (POST data)
+ * operator[cookies] (cookie data)
+ * member functions
+ * script_name()
+ * request_method()
+ * content_length()
+ * content_encoding()
+ * etc...
+ * constructors
+ * load()
+ * async_load()
+ * close()
+ * clear()
+ * id()
+ * client()
Acceptor
- - constructors
- - accept()
- - async_accept()
- - cancel()
+
+ * constructors
+ * accept()
+ * async_accept()
+ * cancel()
Service
- - run()
- - stop()
- - reset()
- - get_io_service()
+
+ * run()
+ * stop()
+ * reset()
+ * get_io_service()
Responses
- - operator<<
- - send()
- - clear()
- - data()
- - content_length()
+ * operator<<
+ * send()
+ * clear()
+ * data()
+ * content_length()
-[endsect] [/ quick]
[endsect] [/ ref]
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/Jamfile.v2 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -6,6 +6,7 @@
project boost/cgi/example
: requirements
+ <library>/boost/cgi/
<library>/boost/system/
<library>/boost/thread/
;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/amortization/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -38,10 +38,10 @@
template<typename Request>
void fill_amortization_dictionary(google::TemplateDictionary& dict, Request& req)
{
- std::string tmp( req.POST("LoanAmt") );
+ std::string tmp( req[post]["LoanAmt"] );
dict.SetValue("LoanAmt", tmp.empty() ? "$250,000" : tmp);
- tmp = req.POST("YearlyIntRate");
+ tmp = req[post]["YearlyIntRate"];
dict.SetValue("YearlyIntRate", tmp.empty() ? "6.000" : tmp);
boost::array<std::string, 8> year_opts
@@ -52,13 +52,13 @@
dict.SetValueAndShowSection("TermYrs", year, "SELECT_TERM_YEARS");
}
- if (req.POST("Amortize").empty())
+ if (req[post]["Amortize"].empty())
dict.ShowSection("NotAmortize");
else
{
- double P = boost::lexical_cast<double>(string_from_currency(req.POST("LoanAmt")));
- double i = boost::lexical_cast<double>(req.POST("YearlyIntRate")) / 1200;
- double n = boost::lexical_cast<double>(req.POST("TermYrs")) * 12;
+ double P = boost::lexical_cast<double>(string_from_currency(req[post]["LoanAmt"]));
+ double i = boost::lexical_cast<double>(req[post]["YearlyIntRate"]) / 1200;
+ double n = boost::lexical_cast<double>(req[post]["TermYrs"]) * 12;
double monthly_payments = (P*i) / (1 - std::pow((1+i), -n));
google::TemplateDictionary* sub_dict = dict.AddSectionDictionary("RegPmtSummary");
@@ -103,7 +103,7 @@
google::Template* tmpl
= google::Template::GetTemplate("example.tpl", google::STRIP_WHITESPACE);
- std::string arg(req.GET("arg"));
+ std::string arg(req[get]["arg"]);
if (arg.empty())
arg = "4"; // Make this the default
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/cookie_game/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/cookie_game/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/cookie_game/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -1,5 +1,4 @@
#include <boost/cgi/acgi.hpp>
-#include <boost/cgi/response.hpp>
#define SCRIPT_NAME "acgi_cookie_game"
@@ -49,17 +48,17 @@
response resp;
- if (req.GET("reset") == "true")
+ if (req[get]["reset"] == "true")
{
- resp<< cookie("name")
- << location(req.script_name())
- << content_type("text/plain");
+ resp<< cookie("name").to_string()
+ << location (req.script_name()) // redirect them.
+ << content_type ("text/plain");
resp.send(req.client());
return 0;
}
// First, see if they have a cookie set
- std::string name = req[cookie_data]["name"];
+ std::string name = req[cookies]["name"];
if (!name.empty())
{
resp<< header("Content-type", "text/html")
@@ -74,7 +73,7 @@
if (!name.empty())
{
resp<< header("Content-type", "text/html")
- << cookie("name", name)
+ << cookie("name", name).to_string()
<< "Hello there, " << "<a href=''>" << name << "</a>";
resp.send(req.client());
return 0;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/echo/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -15,9 +15,10 @@
// variables QUERY_STRING and HTTP_COOKIE respectively.
//
-#include <boost/cgi/acgi.hpp>
#include <fstream>
#include <cstdio>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/acgi.hpp"
using namespace std;
using namespace boost::acgi;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/acgi/hello_world/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -13,7 +13,6 @@
//
#include <boost/cgi/acgi.hpp>
-#include <boost/cgi/return.hpp>
using namespace std;
using namespace boost::acgi;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/echo/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -16,10 +16,12 @@
//
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
+#include "boost/cgi/common/header.hpp"
using namespace std;
using namespace boost::fcgi;
@@ -82,9 +84,9 @@
<< "Request id = " << req.id() << "<p />"
<< "Process id = " << process_id() << "<p />"
<< "<form method=POST enctype='multipart/form-data'>"
- "<input type=text name=name value='" << req.POST("name") << "' />"
+ "<input type=text name=name value='" << req[post]["name"] << "' />"
"<br />"
- "<input type=text name=hello value='" << req.POST("hello") << "' />"
+ "<input type=text name=hello value='" << req[post]["hello"] << "' />"
"<br />"
"<input type=file name=user_file />"
"<input type=hidden name=cmd value=multipart_test />"
@@ -95,16 +97,17 @@
//
// Use the function defined above to show some of the request data.
//
- format_map(resp, req[env_data], "Environment Variables");
- format_map(resp, req[get_data], "GET Variables");
- format_map(resp, req[post_data], "POST Variables");
- format_map(resp, req[cookie_data], "Cookie Variables");
+ format_map(resp, req[env], "Environment Variables");
+ format_map(resp, req[get], "GET Variables");
+ format_map(resp, req[post], "POST Variables");
+ format_map(resp, req[cookies], "Cookie Variables");
//
// Response headers can be added at any time before send/flushing it:
//
- resp<< "<content-length == " << content_length(resp.content_length())
- << content_length(resp.content_length()) << ">";
+ resp<< "<content-length == "
+ << content_length(resp)
+ << content_length(resp) << ">";
//
//
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server1/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server1/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server1/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -20,8 +20,8 @@
// This is very similar to the fcgi_echo example.
//
-#include <boost/cgi/fcgi.hpp>
-#include "server.hpp"
+#include "boost/cgi/fcgi.hpp"
+#include "./server.hpp"
using namespace std;
using namespace boost::fcgi;
@@ -41,7 +41,7 @@
}
/// The handle_request function handles a single request.
-int handle_request(fcgi::request& req, boost::system::error_code& ec)
+int handle_request(request& req, boost::system::error_code& ec)
{
// Construct a `response` object (makes writing/sending responses easier).
response resp;
@@ -60,7 +60,7 @@
resp<< "<h3>Response Length</h3>" << resp.content_length()
// response::content_length() returns the length of the *body*
// of the response (ie. not including the headers).
- << content_length(resp.content_length());
+ << content_length(resp);
// This funky macro finishes up:
return_(resp, req, 0);
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server2/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server2/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server2/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -21,17 +21,16 @@
// Unlike in the server1 example, the server class in this example uses
// asynchronous functions, to increase throughput.
//
-//
-// **FIXME**
-// This is slower than the server1 example, which is stupid.
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
@@ -55,34 +54,34 @@
* corresponding to the error.
*/
int handle_request(fcgi::request& req, boost::system::error_code& ec)
- {
- // Construct a `response` object (makes writing/sending responses easier).
- response resp;
+{
+ // Construct a `response` object (makes writing/sending responses easier).
+ response resp;
- // Responses in CGI programs require at least a 'Content-type' header. The
- // library provides helpers for several common headers:
- resp<< content_type("text/html")
- // You can also stream text to a response object.
- << "Hello there, universe!<p />";
-
- // Use the function defined above to show some of the request data.
- format_map(resp, req[env_data], "Environment Variables");
- format_map(resp, req[get_data], "GET Variables");
- format_map(resp, req[cookie_data], "Cookie Variables");
-
- //log_<< "Handled request, handling another." << std::endl;
-
- // This funky macro finishes up:
- return_(resp, req, 0);
- // It is equivalent to the below, where the third argument is represented by
- // `program_status`:
- //
- // resp.send(req.client());
- // req.close(resp.status(), program_status);
- // return program_status;
- //
- // Note: in this case `program_status == 0`.
- }
+ // Responses in CGI programs require at least a 'Content-type' header. The
+ // library provides helpers for several common headers:
+ resp<< content_type("text/html")
+ // You can also stream text to a response object.
+ << "Hello there, universe!<p />";
+
+ // Use the function defined above to show some of the request data.
+ format_map(resp, req[env_data], "Environment Variables");
+ format_map(resp, req[get_data], "GET Variables");
+ format_map(resp, req[cookie_data], "Cookie Variables");
+
+ //log_<< "Handled request, handling another." << std::endl;
+
+ // This funky macro finishes up:
+ return_(resp, req, 0);
+ // It is equivalent to the below, where the third argument is represented by
+ // `program_status`:
+ //
+ // resp.send(req.client());
+ // req.close(resp.status(), program_status);
+ // return program_status;
+ //
+ // Note: in this case `program_status == 0`.
+}
/// The server is used to abstract away protocol-specific setup of requests.
@@ -192,8 +191,8 @@
}catch(boost::system::system_error& se){
cerr<< "[fcgi] System error: " << se.what() << endl;
return 1313;
-}catch(exception& e){
- cerr<< "[fcgi] Exception: " << e.what() << endl;
+}catch(std::exception* e){
+ cerr<< "[fcgi] Exception: " << e->what() << endl;
return 666;
}catch(...){
cerr<< "[fcgi] Uncaught exception!" << endl;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server3/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server3/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server3/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -21,13 +21,15 @@
//
#include <fstream>
+///////////////////////////////////////////////////////////
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/environment_iterator.hpp>
-
-#include <boost/cgi/fcgi.hpp>
+///////////////////////////////////////////////////////////
+#include "boost/cgi/fcgi.hpp"
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
/// Handle one request and return.
@@ -139,8 +141,8 @@
}catch(boost::system::system_error& se){
cerr<< "[fcgi] System error: " << se.what() << endl;
return 1313;
-}catch(exception& e){
- cerr<< "[fcgi] Exception: " << e.what() << endl;
+}catch(std::exception* e){
+ cerr<< "[fcgi] Exception: " << e->what() << endl;
return 666;
}catch(...){
cerr<< "[fcgi] Uncaught exception!" << endl;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server4/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server4/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/server4/main.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -29,6 +29,7 @@
#include <boost/cgi/fcgi.hpp>
using namespace std;
+using namespace boost;
using namespace boost::fcgi;
/// Handle one request and return.
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/test/compile/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/test/compile/response.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/test/compile/response.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -1,4 +1,4 @@
-#include <boost/cgi/response.hpp>
+#include <boost/cgi/common/response.hpp>
int main(int, char**)
{
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/cookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/cookie.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/cookie.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -9,7 +9,7 @@
#include <boost/test/unit_test.hpp>
#include <sstream>
-#include "boost/cgi/cookie.hpp"
+#include "boost/cgi/common/cookie.hpp"
BOOST_AUTO_TEST_CASE( cookie_constructor_delete )
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/response.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/test/run/response.cpp 2008-05-21 12:06:46 EDT (Wed, 21 May 2008)
@@ -13,7 +13,7 @@
#define BOOST_TEST_MODULE response_test
#include <boost/test/unit_test.hpp>
-#include "boost/cgi/response.hpp"
+#include "boost/cgi/common/response.hpp"
using namespace std;
using namespace boost;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk