Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59994 - in sandbox/SOC/2007/cgi/trunk: boost/cgi/fcgi boost/cgi/impl boost/cgi/utility libs/cgi/build libs/cgi/example/cgi/stencil libs/cgi/example/fcgi libs/cgi/example/fcgi/amortization libs/cgi/example/fcgi/stencil
From: lists.drrngrvy_at_[hidden]
Date: 2010-02-28 12:00:07


Author: drrngrvy
Date: 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
New Revision: 59994
URL: http://svn.boost.org/trac/boost/changeset/59994

Log:
Bug fixes, compiled with linux. Also fixing FastCGI jamfiles.
Text files modified:
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp | 3 +
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp | 4 +-
   sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp | 41 ++++++++++++++++++++++-----------------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp | 27 +++++++++++++++----------
   sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/redirect.hpp | 5 ++-
   sandbox/SOC/2007/cgi/trunk/libs/cgi/build/Jamfile.v2 | 2 +
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/Jamfile.v2 | 19 +++++++++++++++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/Jamfile.v2 | 8 ++++++
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/amortization/main.cpp | 11 ++++-----
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/Jamfile.v2 | 14 +++++++-----
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/main.cpp | 11 +++++++--
   11 files changed, 94 insertions(+), 51 deletions(-)

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/acceptor_service_impl.hpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -296,7 +296,8 @@
      int accept(implementation_type& impl, accept_handler_type handler
              , endpoint_type* endpoint, boost::system::error_code& ec)
      {
- typedef std::pair<std::set<request_type::pointer>::iterator, bool> pair_t;
+ typedef typename std::set<request_ptr>::iterator iter_t;
+ typedef std::pair<iter_t, bool> pair_t;
        
        request_ptr new_request;
        pair_t insert_result;

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/client.hpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -228,12 +228,12 @@
   )
   {
     prepare_buffer(buf);
-
+ boost::system::error_code ec;
     std::size_t bytes_transferred
       = boost::asio::write(*connection_, outbuf_
                           , boost::asio::transfer_all(), ec);
-
     handle_write(bytes_transferred, ec);
+ handler(bytes_transferred, ec);
   }
 
  } // namespace common

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/fcgi/request_service.hpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -146,29 +146,46 @@
     template<typename Handler>
     void do_load(
         implementation_type& impl, common::parse_options opts,
- Handler handler, boost::system::error_code const& ec
+ Handler handler, boost::system::error_code& ec
       );
 
     template<typename Handler>
     void handle_read_header(
         implementation_type& impl,
+ ::BOOST_CGI_NAMESPACE::common::parse_options opts,
         Handler handler,
- boost::system::error_code const& ec,
+ boost::system::error_code& ec,
         const std::size_t bytes_transferred
       );
 
     template<typename Handler>
     void handle_begin_request_header(
         implementation_type& impl,
+ common::parse_options opts,
         Handler handler,
- boost::system::error_code const& ec
+ boost::system::error_code& ec
       );
 
+ /// Asynchronously read a single header, but do nothing with it.
     template<typename Handler>
     void async_read_header(
- implementation_type& impl
- , Handler handler
- , boost::system::error_code& ec);
+ implementation_type& impl,
+ common::parse_options opts,
+ Handler handler)
+ {
+ // clear the header first (might be unneccesary).
+ impl.header_buf_ = implementation_type::header_buffer_type();
+
+ async_read(*impl.client_.connection(), buffer(impl.header_buf_)
+ , boost::asio::transfer_all(), handler);
+ }
+
+ template<typename Handler>
+ void async_read_header(
+ implementation_type& impl,
+ common::parse_options opts,
+ Handler handler,
+ boost::system::error_code& ec);
 
   protected:
     /// Read and parse the cgi POST meta variables (greedily)
@@ -201,18 +218,6 @@
     boost::system::error_code
       read_header(implementation_type& impl, boost::system::error_code& ec);
 
- /// Asynchronously read a single header, but do nothing with it.
- template<typename Handler>
- void async_read_header(implementation_type& impl, Handler handler)
- {
- // clear the header first (might be unneccesary).
- impl.header_buf_ = implementation_type::header_buffer_type();
-
- async_read(*impl.client_.connection(), buffer(impl.header_buf_)
- , boost::asio::transfer_all(), handler);
- }
-
-
     /*** Various handlers go below here; they might find a
      * better place to live ***/
 

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/impl/fcgi_request_service.ipp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -45,10 +45,10 @@
      struct async_load_helper
      {
        async_load_helper(T& t, typename T::implementation_type& impl
- , bool parse_stdin, Handler h)
+ , common::parse_options opts, Handler h)
          : type(t)
          , impl_(impl)
- , parse_stdin_(parse_stdin)
+ , parse_opts_(opts)
          , handler_(h)
        {
        }
@@ -56,13 +56,13 @@
        void operator()()
        {
          boost::system::error_code ec;
- type.load(impl_, parse_stdin_, ec);
+ type.load(impl_, parse_opts_, ec);
          handler_(ec);
        }
 
        T& type;
        typename T::implementation_type& impl_;
- bool parse_stdin_;
+ common::parse_options parse_opts_;
        Handler handler_;
      };
      
@@ -239,7 +239,7 @@
     BOOST_CGI_INLINE
     void fcgi_request_service::do_load(
         implementation_type& impl, common::parse_options opts,
- Handler handler, boost::system::error_code const& ec
+ Handler handler, boost::system::error_code& ec
       )
     {
       impl.client_.construct(impl, ec);
@@ -253,8 +253,9 @@
     BOOST_CGI_INLINE
     void fcgi_request_service::handle_read_header(
         implementation_type& impl,
+ common::parse_options opts,
         Handler handler,
- boost::system::error_code const& ec,
+ boost::system::error_code& ec,
         const std::size_t bytes_transferred
       )
     {
@@ -300,8 +301,9 @@
     BOOST_CGI_INLINE
     void fcgi_request_service::handle_begin_request_header(
         implementation_type& impl,
+ common::parse_options opts,
         Handler handler,
- boost::system::error_code const& ec
+ boost::system::error_code& ec
       )
     {
       if (//impl.request_status_ < common::env_read &&
@@ -351,14 +353,16 @@
     void fcgi_request_service::async_load(
         implementation_type& impl, common::parse_options opts, Handler handler)
     {
+ /*
       strand_.post(
           boost::bind(&self_type::do_load<Handler>,
               this, boost::ref(impl), opts, handler
             )
         );
+ */
         
- this->io_service().post(
- detail::async_load_helper<self_type, Handler>(this, opts & common::parse_post_only, handler)
+ strand_.post(
+ detail::async_load_helper<self_type, Handler>(this, opts, handler)
       );
     }
 
@@ -483,6 +487,7 @@
     BOOST_CGI_INLINE void
     fcgi_request_service::async_read_header(
         implementation_type& impl
+ , common::parse_options opts
       , Handler handler
       , boost::system::error_code& ec)
     {
@@ -494,12 +499,12 @@
         , boost::asio::transfer_all()
         , strand_.wrap(
               boost::bind(&self_type::handle_read_header,
- this, boost::ref(impl), handler,
+ this, boost::ref(impl), opts, handler,
                   boost::asio::placeholders::error,
                   boost::asio::placeholders::bytes_transferred
                 )
             )
- )
+ );
     }
 
     /*** Various handlers go below here; they might find a

Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/redirect.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/redirect.hpp (original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/redirect.hpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -27,8 +27,9 @@
    redirect(RequestT& req, typename RequestT::string_type const& dest
            , bool secure, boost::system::error_code& ec)
    {
- typename RequestT::string_type url(dest);
- if (url.find("://") == typename RequestT::string_type::npos) {
+ typedef typename RequestT::string_type string_type;
+ string_type url(dest);
+ if (url.find("://") == string_type::npos) {
        url = secure ? "https" : "http";
        url += "://" + req.server_name();
        if (dest[0] == '/')

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 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -59,6 +59,7 @@
       <library>/boost//thread/
       <library>/boost//system/
       <library>/boost//regex/
+ <library>/boost//filesystem/
       <library>/boost//date_time/
       <define>_CRT_SECURE_NO_WARNINGS
       <define>_SCL_SECURE_NO_WARNINGS
@@ -68,6 +69,7 @@
       <include>$(boost-root)
       <library>/boost//thread/
       <library>/boost//system/
+ <library>/boost//filesystem/
       <library>/boost//regex/
       <library>/boost//date_time/
       <define>_CRT_SECURE_NO_WARNINGS

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/stencil/Jamfile.v2 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -1,4 +1,4 @@
-# Copyright (c) 2007 Darren Garvey
+# Copyright (c) 2009 Darren Garvey
 #
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy
@@ -6,10 +6,27 @@
 
 project boost/cgi/example/cgi/stencil ;
 
+# Note: to compile this example you need to download and install
+# cTemplate from Google. You can download it from here:
+#
+# http://code.google.com/p/google-ctemplate/
+#
+# The stencil class is a lightweight wrapper over ctemplate, which
+# started out as just an experiment but some may find it useful.
+#
+# Also in your user-config.jam (this is just a text file you should
+# create in your "HOME" directory - Boost.Build uses this for configuration),
+# you should add a line that looks like (not the space before the
+# trailing ';'):
+#
+# lib ctemplate : <file>path/to/ctemplate ;
+#
+
 exe cgi_stencil
   :
      main.cpp /boost/regex/ /boost/cgi/
   :
+ <library>ctemplate
   ;
 
 

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/Jamfile.v2 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -1,4 +1,4 @@
-# Copyright (c) 2007, 2008 Darren Garvey
+# Copyright (c) 2007-2009 Darren Garvey
 #
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy
@@ -9,6 +9,9 @@
 # By default, just build the examples
 build-project hello_world ;
 build-project echo ;
+build-project amortization ;
+build-project file_browser ;
+build-project stencil ;
 build-project server1 ;
 build-project server2 ;
 build-project server3 ;
@@ -19,6 +22,9 @@
   :
     hello_world
     echo
+ amortization
+ file_browser
+ stencil
     server1
     server2
     server3

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/amortization/main.cpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -21,7 +21,6 @@
 #include <iostream>
 #include <iomanip>
 #include <boost/cgi/fcgi.hpp>
-#include <boost/cgi/utility.hpp>
 #include <boost/algorithm/string/regex.hpp>
 #include <ctemplate/template.h>
 
@@ -42,7 +41,7 @@
 {
   dict.SetValue("LoanAmt", req.post.count("LoanAmt")
       ? "$250,000" : req.post["LoanAmt"]);
- dict.SetIntValue("YearlyIntRate", req.post.as("YearlyIntRate", 6.000));
+ dict.SetIntValue("YearlyIntRate", req.post.pick("YearlyIntRate", 6.000));
 
   boost::array<std::string, 8> year_opts
     = {{ "5", "7", "10", "20", "30", "40", "50" }};
@@ -58,9 +57,9 @@
   {
     double P = boost::lexical_cast<double>(
       string_from_currency(req.post["LoanAmt"]));
- double i = req.post.as<double>("YearlyIntRate", 1) / 1200;
- double n = req.post.as<double>("TermYrs", 1) * 12;
- double monthly_payments = (P*i) / (1 - std::pow((1+i), -n));+
+ double i = req.post.pick("YearlyIntRate", 1.0) / 1200;
+ double n = req.post.pick("TermYrs", 1.0) * 12;
+ double monthly_payments = (P*i) / (1 - std::pow((1+i), -n));
     
     ctemplate::TemplateDictionary* sub_dict
       = dict.AddSectionDictionary("RegPmtSummary");
@@ -112,7 +111,7 @@
   std::string h("Content-type: text/html\r\n\r\n");
   write(req.client(), buffer(h));
 
- int arg = req.get.as("arg", 2); // 2 is the default.
+ int arg = req.get.pick("arg", 2); // 2 is the default.
 
   // Different, but equivalent ways of writing the output.
   std::string output;

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/Jamfile.v2 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -1,23 +1,25 @@
-# Copyright (c) 2007 Darren Garvey
+# Copyright (c) 2009 Darren Garvey
 #
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy
 # at http://www.boost.org/LICENSE_1_0.txt)
 
-project boost/cgi/example/cgi/stencil ;
+project boost/cgi/example/fcgi/stencil ;
 
-exe cgi_stencil
+exe fcgi_stencil
   :
      main.cpp /boost/regex/ /boost/cgi/
- :
   ;
 
 
 # Our install rule (builds binaries and copies them to <location>)
 install install
- : cgi_stencil
- : <location>$(cgi-bin)
+ :
+ fcgi_stencil
+ :
+ <location>$(fcgi-bin)
  ;
 
 # Only install example if you use `bjam install' or equivalent
 explicit install ;
+

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/stencil/main.cpp 2010-02-28 12:00:05 EST (Sun, 28 Feb 2010)
@@ -42,9 +42,14 @@
   resp.set("short_bits", 8 * sizeof(short)); // Populates {{short_bits}}.
   if (req.get.count("short"))
   {
- // Almost any type is supported by as<>
+ // Almost any type is supported by pick<>
     // (ie. any type supported by Boost.Lexical_cast.).
- short some_short = req.get.as<short>("short", -1);
+ // This is equivalent to request::as<>, but returns the second parameter
+ // iff there is no item in the map and / or the value could not be
+ // cast to the specified type. In this case, we shall explicitly cast
+ // to a `short`. In general, however, the default type that the value is
+ // cast to is inferred from the type of the second parameter.
+ short some_short = req.get.pick<short>("short", -1);
     resp.set("some_short", some_short);
   }
   
@@ -60,7 +65,7 @@
   
   //// Test 4.
   
- int num = req.get.as("count", 0);
+ int num = req.get.pick("count", 0);
   if (num < 0) num = 0;
   resp.set("show_less", num ? num - 1 : 0);
   resp.set("show_more", num + 1);


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