Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57846 - sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common
From: lists.drrngrvy_at_[hidden]
Date: 2009-11-22 13:19:34


Author: drrngrvy
Date: 2009-11-22 13:19:33 EST (Sun, 22 Nov 2009)
New Revision: 57846
URL: http://svn.boost.org/trac/boost/changeset/57846

Log:
Additions to path_info, inspired by boost::filesystem::path. Many functions are not included in path_info as they aren't relevant to the domain.
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp | 7 +++++++
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp | 33 ++++++++++++++++++++++++++++-----
   2 files changed, 35 insertions(+), 5 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/commit.hpp 2009-11-22 13:19:33 EST (Sun, 22 Nov 2009)
@@ -35,5 +35,12 @@
  } // namespace common
 BOOST_CGI_NAMESPACE_END
 
+namespace boost {
+
+ namespace cgi { using ::BOOST_CGI_NAMESPACE::common::commit; }
+ namespace fcgi { using ::BOOST_CGI_NAMESPACE::common::commit; }
+
+} // namespace boost
+
 #endif // BOOST_CGI_COMMIT_HPP_INCLUDED_
 

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/common/path_info.hpp 2009-11-22 13:19:33 EST (Sun, 22 Nov 2009)
@@ -15,31 +15,54 @@
    struct path_info
    {
      typedef std::string value_type;
+ typedef value_type string_type;
+ typedef string_type::size_type size_type;
      typedef std::vector<value_type> vector_type;
      typedef vector_type::iterator iterator;
      typedef vector_type::const_iterator const_iterator;
 
+private:
+ void parse()
+ {
+ if (value[0] != '/') value.insert(value.begin(), '/');
+ boost::algorithm::split(
+ parts, value, boost::algorithm::is_any_of("/"));
+ }
+
+ string_type substr(string_type const& str, char ch, bool include_char = true) const
+ {
+ try {
+ return value.substr(value.find_last_of(ch));
+ } catch(...) {
+ return "";
+ }
+ }
+
+public:
+
      template<typename S, typename P, typename A>
      path_info(basic_request<S,P,A> & request)
        : value(request.env["path_info"])
      {
- boost::algorithm::split(
- parts, value, boost::algorithm::is_any_of("/"));
+ parse();
      }
 
      path_info(value_type const& str)
        : value(str)
      {
- boost::algorithm::split(
- parts, value, boost::algorithm::is_any_of("/"));
+ parse();
      }
      
      value_type& operator[](int i) { return parts[i]; }
      
- value_type& str() { return value; }
+ value_type& string() { return value; }
      
      operator value_type& () { return value; }
      
+ string_type stem() const { return substr(value, '/', false); }
+
+ string_type extension() const { return substr(stem(), '.'); }
+
      iterator begin() { return parts.begin(); }
      iterator end() { return parts.end(); }
      const_iterator begin() const { return parts.begin(); }


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