Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50936 - in sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi: build/msvc/9.0/Boost.CGI build/msvc/9.0/Boost.CGI/Amortization build/msvc/9.0/Boost.CGI/acgi_cookie_game build/msvc/9.0/Boost.CGI/acgi_echo build/msvc/9.0/Boost.CGI/acgi_hello_world build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server build/msvc/9.0/Boost.CGI/cgi_debug_server build/msvc/9.0/Boost.CGI/cgi_echo build/msvc/9.0/Boost.CGI/cgi_hello_world build/msvc/9.0/Boost.CGI/fcgi_hello_world build/msvc/9.0/Boost.CGI/xcgi_server1 example/acgi/amortization example/acgi/echo example/fcgi/amortization
From: lists.drrngrvy_at_[hidden]
Date: 2009-01-31 18:43:52


Author: drrngrvy
Date: 2009-01-31 18:43:51 EST (Sat, 31 Jan 2009)
New Revision: 50936
URL: http://svn.boost.org/trac/boost/changeset/50936

Log:
* Fixing svn props.
* Minor changes to acgi_amortization.
Properties modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Amortization/Amortization.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Amortization/Amortization.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_cookie_game/acgi_cookie_game.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_cookie_game/acgi_cookie_game.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_echo/acgi_echo.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_echo/acgi_echo.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_hello_world/acgi_hello_world.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/acgi_hello_world/acgi_hello_world.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj (contents, props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_debug_server/cgi_debug_server.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_debug_server/cgi_debug_server.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_echo/cgi_echo.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_echo/cgi_echo.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_hello_world/cgi_hello_world.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_hello_world/cgi_hello_world.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/fcgi_hello_world/fcgi_hello_world.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/fcgi_hello_world/fcgi_hello_world.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/xcgi_server1/xcgi_server1.vcproj (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/xcgi_server1/xcgi_server1.vcproj.360-SYSTEMS.darreng.user (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/amortization/amortization.css (props changed)
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/fcgi/amortization/amortization.js (props changed)
Binary files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.ncb
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.html | 10 ++++-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.js | 6 +-
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp | 61 ++++++++++++++++++++++++++++-----------
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp | 7 +++-
   4 files changed, 58 insertions(+), 26 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.ncb
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.html
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.html (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.html 2009-01-31 18:43:51 EST (Sat, 31 Jan 2009)
@@ -49,9 +49,13 @@
       <td class="td1">Length of Loan</td>
       <td class="td2">
         <select name="TermYrs">
- {{#SELECT_TERM_YEARS}}
- <option value="{{TermYrs}}">{{TermYrs}} Years</option>
- {{/SELECT_TERM_YEARS}}
+ <option value="5" {{TermYrs_5}}">5 Years</option>
+ <option value="7" {{TermYrs_7}}">7 Years</option>
+ <option value="10" {{TermYrs_10}}">10 Years</option>
+ <option value="20" {{TermYrs_20}}">20 Years</option>
+ <option value="30" {{TermYrs_30}}">30 Years</option>
+ <option value="40" {{TermYrs_40}}">40 Years</option>
+ <option value="50" {{TermYrs_50}}">50 Years</option>
         </select>
       </td>
       <td class="td1">Start with Payment</td>

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.js
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.js (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/acgi_amort.js 2009-01-31 18:43:51 EST (Sat, 31 Jan 2009)
@@ -119,7 +119,7 @@
 
 
 function replaceChar(entry) {
- out = "$";
+ out = "£";
         add = "";
         temp = "" + entry;
         while (temp.indexOf(out)>-1) {
@@ -159,13 +159,13 @@
                         num=replaceChars(num);
                 if ( checkForm(num));
 {
- num = num.toString().replace(/$|,/g,'');
+ num = num.toString().replace(/[$£,]/g,'');
                         if(isNaN(num)) num = "0";
                         num = Math.floor(num).toString();
                 for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
                         num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
                          
- return ('$' + num );
+ return ('£' + num );
 }
 }
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/amortization/main.cpp 2009-01-31 18:43:51 EST (Sat, 31 Jan 2009)
@@ -27,6 +27,9 @@
 
 using namespace boost::acgi;
 
+#define DEFAULT_LOAN_AMT "£250,000"
+#define DEFAULT_INTEREST_RATE "6.000"
+
 /// Convert a string like '$250,000' into one like '250000'.
 std::string string_from_currency(std::string amt)
 {
@@ -44,36 +47,57 @@
   dict.SetValue("PrePmtFreq_" + val, " selected=\"selected\"");
 }
 
+template<typename Request, typename Dictionary>
+double get_term_years(Request& req, Dictionary& dict)
+{
+ std::string val(has_key(req[form], "TermYrs")
+ ? req[form]["TermYrs"]
+ : "");
+ dict.SetValue("TermYrs_" + val, " selected=\"selected\"");
+ return boost::lexical_cast<double>(val);
+}
+
+template<typename Request, typename Dictionary>
+double get_interest_rate(Request& req, Dictionary& dict)
+{
+ std::string val(has_key(req[form], "YearlyIntRate")
+ ? req[form]["YearlyIntRate"]
+ : DEFAULT_INTEREST_RATE);
+ dict.SetValue("YearlyIntRate", val);
+ return boost::lexical_cast<double>(val);
+
+}
+
+template<typename Request, typename Dictionary>
+double get_loan_amount(Request& req, Dictionary& dict)
+{
+ std::string val(has_key(req[form], "LoanAmt")
+ ? req[form]["LoanAmt"]
+ : "£250,000");
+ dict.SetValue("LoanAmt", val);
+ return boost::lexical_cast<double>(string_from_currency(val));
+}
+
 /// This function fills the dictionary and sub-dictionaries with relevant values.
 template<typename Request>
 void fill_amortization_dictionary(google::TemplateDictionary& dict, Request& req)
 {
   dict.SetValue("SCRIPT_NAME", req.script_name());
- dict.SetValue("LoanAmt", has_key(req[form],"LoadAmt")
- ? req[form]["LoanAmt"]
- : "£250,000");
-
- dict.SetValue("YearlyIntRate", has_key(req[form],"YearlyIntRate")
- ? req[form]["YearlyIntRate"]
- : "6.000");
 
- boost::array<std::string, 8> year_opts
- = {{ "5", "7", "10", "20", "30", "40", "50" }};
-
- BOOST_FOREACH(std::string& year, year_opts)
- {
- dict.SetValueAndShowSection("TermYrs", year, "SELECT_TERM_YEARS");
- }
-
   get_prepayment_frequency(req, dict);
 
   if ( ! has_key(req[form], "Amortize") )
+ {
     dict.ShowSection("NotAmortize");
+ // Set some default values
+ dict.SetValue("LoanAmt", DEFAULT_LOAN_AMT);
+ dict.SetValue("YearlyIntRate", "6.000");
+ }
   else
   {
- double P = boost::lexical_cast<double>(string_from_currency(req[form]["LoanAmt"]));
- double i = boost::lexical_cast<double>(req[form]["YearlyIntRate"]) / 1200;
- double n = boost::lexical_cast<double>(req[form]["TermYrs"]) * 12;
+ double P = get_loan_amount(req, dict);
+ double i = get_interest_rate(req, dict) / 1200;
+ double n = get_term_years(req, dict) * 12;
     double monthly_payments = (P*i) / (1 - std::pow((1+i), -n));
     
     google::TemplateDictionary* sub_dict = dict.AddSectionDictionary("RegPmtSummary");
@@ -189,6 +213,7 @@
     response resp;
 
     write_amortization_template(req, resp);
+ resp<< req[form]["YearlyIntRate"];
   
     return_(resp, req, 0);
   }catch(boost::system::system_error* err){

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/acgi/echo/main.cpp 2009-01-31 18:43:51 EST (Sat, 31 Jan 2009)
@@ -20,6 +20,7 @@
 #include <vector>
 ///////////////////////////////////////////////////////////
 #include "boost/cgi/acgi.hpp"
+#include "boost/cgi/utility/has_key.hpp"
 
 using namespace std;
 using namespace boost::acgi;
@@ -119,10 +120,12 @@
                "Process ID = " << process_id() << "<br />"
                "<form method=POST enctype='multipart/form-data'>"
                  "<input type=text name=name value='"
- << req[post]["name"] << "' />"
+ << (has_key(req[post],"name") ? req[post]["name"] : "")
+ << "' />"
                  "<br />"
                  "<input type=text name=hello value='"
- << req[post]["hello"] << "' />"
+ << (has_key(req[post],"hello") ? req[post]["hello"] : "")
+ << "' />"
                  "<br />"
                  "<input type=file name=user_file />"
                  "<input type=hidden name=cmd value=multipart_test />"


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