Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-03-21 13:09:13


Author: drrngrvy
Date: 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
New Revision: 43757
URL: http://svn.boost.org/trac/boost/changeset/43757

Log:
* Added cgi/echo example
* Modified/fixed/cleaned up amortization example
Added:
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2
      - copied, changed from r43578, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/main.cpp
      - copied, changed from r43578, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp
Properties modified:
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/ (props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 | 6 ++
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/Jamfile.v2 | 24 +++++++++-
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp | 88 ++++++++++++++++++++++++++++++++++++++-
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 | 15 +++++
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 | 17 ++++++-
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/main.cpp | 10 ++-
   6 files changed, 143 insertions(+), 17 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/Jamfile.v2 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -4,6 +4,12 @@
 # (See accompanying file LICENSE_1_0.txt or copy
 # at http://www.boost.org/LICENSE_1_0.txt)
 
+project boost.cgi.examples
+ : requirements
+ <library>/boost/system/
+ <library>/boost/thread/
+ ;
+
 # Install all of the acgi examples
 install acgi
  : # sources

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/Jamfile.v2 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -4,26 +4,42 @@
 # (See accompanying file LICENSE_1_0.txt or copy
 # at http://www.boost.org/LICENSE_1_0.txt)
 
+# A symbolic name for this project.
+project boost.cgi.examples.acgi.amortization ;
+
+import os ;
+
+if [ os.name ] = NT
+{
+ lib ctemplate : : <file>c:/cc/src/ctemplate/ctemplate-0.9/Release/libctemplate.lib ;
+}
+else
+{
+ lib ctemplate ;
+}
+
+
 exe acgi_amort
   :
     main.cpp
- /boost/thread/
     /boost/regex/
   :
+ <library>ctemplate
   :
- <linkflags>-lctemplate
+ #<linkflags>-lctemplate
   ;
 
 # Our install rule (builds binaries and copies them to <location>)
 install install
- : acgi_amort
+ :
+ acgi_amort
    acgi_amort.tpl
  :
  :
    <location>$(cgi-bin)
  ;
 
-install install_extra
+install install-extra
  :
    acgi_amort.css
    acgi_amort.js

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/amortization/main.cpp 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -17,9 +17,11 @@
 // It is a very basic amortization calculator.
 //
 #include <iostream>
+#include <iomanip>
 #include <boost/cgi/acgi.hpp>
 #include <boost/algorithm/string/regex.hpp>
 #include <google/template.h>
+#include <boost/high_resolution_timer.hpp>
 
 using namespace boost::acgi;
 
@@ -100,15 +102,89 @@
   google::Template* tmpl
     = google::Template::GetTemplate("example.tpl", google::STRIP_WHITESPACE);
 
- std::string output;
- tmpl->Expand(&output, &dict);
+ boost::high_resolution_timer t;
+
+ std::string arg(req.GET("arg"));
+
+ if (arg == "1")
+ {
+ std::string output;
+ tmpl->Expand(&output, &dict);
+ std::cout<< output;
+ }else
+ if (arg == "2")
+ {
+ std::string output;
+ tmpl->Expand(&output, &dict);
+ resp<< output;
+ }else
+ if (arg == "3")
+ {
+ std::string s;
+ std::vector<boost::asio::const_buffer> out;
+
+ tmpl->Expand(&s, &out, &dict);
+ write(req.client(), out);
+ }else
+ if (arg == "4")
+ {
+ std::string output;
+ tmpl->Expand(&output, &dict);
+ write(req.client(), buffer(output));
+ }else
+ if (arg == "5")
+ {
+ std::string output;
+ tmpl->Expand(&output, &dict);
+ std::cout.write(output.c_str(), output.size());
+ }else
+ {
+ resp<< "Error!";
+ }
+ //output.clear();
+ //<< "<b>" << t.elapsed() << "</b><p />"
+ //<< output << "<p /><p />"
+ //<< "<b>" << t.elapsed() << "</b><p />";
+ //}
+
+ //std::cout<<
+ // "<pre>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nSTARTING OTHER THINGY\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n</pre>"
+ // ;
+/*
+ std::string s;
+ std::vector<boost::asio::const_buffer> out;
+for(int i=0; i < 50000; ++i) {
+ // boost::high_resolution_timer t;
+
+ tmpl->Expand(&s, &out, &dict);
+ out.clear();
+ s.clear();
+ //std::cout<< "<b>" << t.elapsed() << "</b><p />";
+
+ //<< "<p /><p />"
+ //<< "<b>" << t.elapsed() << "</b><p />";
+ }
+
+
+ std::cerr<< "a took " << std::setiosflags(std::ios::fixed) << std::setprecision(5) << a/100000 << " secs<p />"
+ << "b took " << b/100000 << " secs<p />";
+
   
- resp<< content_type("text/html")
- << output;
+ std::cerr
+ << "Content-type: text/html\r\n\r\n"
+ << output << "<p /><p />";
+
+ resp<< content_type("text/html");
+ resp.flush(req.client());
+ write(req.client(), buffer(output));
+ */
 }
 
 int main()
 {
+ try{
+ std::cout
+ << "Content-type: text/html\r\n\r\n";
   service s;
   request req(s);
   req.load(true);
@@ -117,5 +193,9 @@
   write_amortization_template(req, resp);
   
   return_(resp, req, 0);
+ }catch(...){
+ std::cout<< "Content-type: text/html\r\n\r\n"
+ << "ERROR!! BOOM!";
+ }
 }
 

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -4,14 +4,25 @@
 # (See accompanying file LICENSE_1_0.txt or copy
 # at http://www.boost.org/LICENSE_1_0.txt)
 
-exe acgi_echo : main.cpp /boost/thread/ ;
+exe acgi_echo
+ : main.cpp
+ /boost/thread/
+ /boost/regex/
+ ;
+
+local LOCATION = $(cgi-bin) ;
+if ! $(LOCATION)
+{
+ LOCATION = . ;
+}
+
 
 # Our install rule (builds binaries and copies them to <location>)
 install install
  : acgi_echo
  :
  :
- <location>$(cgi-bin)
+ <location>$(LOCATION)
  ;
 
 # Only install example if you use `bjam install' or equivalent

Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 (from r43578, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/Jamfile.v2 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -4,14 +4,25 @@
 # (See accompanying file LICENSE_1_0.txt or copy
 # at http://www.boost.org/LICENSE_1_0.txt)
 
-exe acgi_echo : main.cpp /boost/thread/ ;
+exe cgi_echo
+ : main.cpp
+ /boost/thread/
+ /boost/regex/
+ ;
+
+local LOCATION = $(cgi-bin) ;
+if ! $(LOCATION)
+{
+ LOCATION = . ;
+}
+
 
 # Our install rule (builds binaries and copies them to <location>)
 install install
- : acgi_echo
+ : cgi_echo
  :
  :
- <location>$(cgi-bin)
+ <location>$(LOCATION)
  ;
 
 # Only install example if you use `bjam install' or equivalent

Copied: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/main.cpp (from r43578, /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp)
==============================================================================
--- /sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/acgi/echo/main.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/example/cgi/echo/main.cpp 2008-03-21 13:09:13 EDT (Fri, 21 Mar 2008)
@@ -13,10 +13,11 @@
 // variables QUERY_STRING and HTTP_COOKIE respectively.
 //
 
-#include <boost/cgi/acgi.hpp>
+//[file
+#include <boost/cgi/cgi.hpp>
 
 using namespace std;
-using namespace boost::acgi;
+using namespace boost::cgi;
 
 // This function writes the title and map contents to the ostream in an
 // HTML-encoded format (to make them easier on the eye).
@@ -33,8 +34,7 @@
 
 int main()
 {
- service s;
- request req(s);
+ request req;
 
   req.load(true); // The 'true' means parse STDIN data too.
 
@@ -54,3 +54,5 @@
 
   return 0;
 }
+//]
+


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