Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7032/boost/xpressive

Modified Files:
        match_results.hpp regex_actions.hpp regex_constants.hpp 
Log Message:
support for late-bound arguments in actions

Index: match_results.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/match_results.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- match_results.hpp   22 Mar 2007 17:37:16 -0000      1.13
+++ match_results.hpp   24 Mar 2007 10:07:29 -0000      1.14
@@ -16,12 +16,15 @@
 # pragma once
 #endif
 
+#include <map>
+#include <utility>
 #include <iterator>
+#include <typeinfo>
 #include <boost/assert.hpp>
 #include <boost/integer.hpp>
+#include <boost/mpl/assert.hpp>
 #include <boost/intrusive_ptr.hpp>
 #include <boost/iterator_adaptors.hpp>
-#include <boost/mpl/assert.hpp>
 #include <boost/numeric/conversion/converter.hpp>
 #if BOOST_ITERATOR_ADAPTORS_VERSION >= 0x0200
 # include <boost/iterator/filter_iterator.hpp>
@@ -31,7 +34,6 @@
 #include <boost/xpressive/detail/core/sub_match_vector.hpp>
 #include <boost/xpressive/detail/utility/sequence_stack.hpp>
 #include <boost/xpressive/detail/core/results_cache.hpp>
-//#include <boost/xpressive/detail/core/action_state.hpp>
 #include <boost/xpressive/detail/utility/literals.hpp>
 #include <boost/xpressive/detail/utility/algorithm.hpp>
 #include <boost/xpressive/detail/utility/counted_base.hpp>
@@ -40,6 +42,25 @@
 {
 
 ///////////////////////////////////////////////////////////////////////////////
+// type_info_less
+//
+struct type_info_less
+{
+    bool operator()(std::type_info const *left, std::type_info const *right) 
const
+    {
+        return 0 != left->before(*right);
+    }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// ActionArgBinding
+//
+struct ActionArgBinding
+  : proto::assign<proto::terminal<action_arg<proto::_, proto::_> >, 
proto::terminal<proto::_> >
+{
+};
+
+///////////////////////////////////////////////////////////////////////////////
 // results_extras
 //
 template<typename BidiIter>
@@ -231,9 +252,9 @@
       , prefix_()
       , suffix_()
       , nested_results_()
-      //, action_state_()
       , extras_ptr_()
       , traits_()
+      , args_()
     {
     }
 
@@ -254,9 +275,9 @@
       , prefix_()
       , suffix_()
       , nested_results_()
-      //, action_state_(that.action_state_)
       , extras_ptr_()
       , traits_()
+      , args_(that.args_)
     {
         if(that)
         {
@@ -467,9 +488,24 @@
         std::swap(this->prefix_, that.prefix_);
         std::swap(this->suffix_, that.suffix_);
         this->nested_results_.swap(that.nested_results_);
-        //std::swap(this->action_state_, that.action_state_);
         this->extras_ptr_.swap(that.extras_ptr_);
         this->traits_.swap(that.traits_);
+        this->args_.swap(that.args_);
+    }
+
+    /// TODO document me
+    ///
+    template<typename Arg>
+    match_results<BidiIter> &bind(Arg const &arg)
+    {
+        typedef typename proto::result_of::left<Arg>::type left_type;
+        typedef typename proto::result_of::right<Arg>::type right_type;
+        typedef typename proto::result_of::arg<left_type>::type arg_left_type;
+        typedef typename proto::result_of::arg<right_type>::type 
arg_right_type;
+        BOOST_MPL_ASSERT((proto::matches<Arg, detail::ActionArgBinding>));
+        BOOST_MPL_ASSERT((is_same<typename arg_left_type::type, 
arg_right_type>));
+        this->args_[&typeid(proto::arg(proto::left(arg)))] = 
&proto::arg(proto::right(arg));
+        return *this;
     }
 
     /// INTERNAL ONLY
@@ -495,23 +531,6 @@
         return (*this)(rex.regex_id(), index);
     }
 
-    // state:
-    /// INTERNAL ONLY
-    ///
-    //template<typename State>
-    //void set_action_state(State &state)
-    //{
-    //    this->action_state_.set(state);
-    //}
-
-    /// INTERNAL ONLY
-    ///
-    //template<typename State>
-    //State &get_action_state() const
-    //{
-    //    return this->action_state_.BOOST_NESTED_TEMPLATE get<State>();
-    //}
-
 private:
 
     friend struct detail::core_access<BidiIter>;
@@ -936,22 +955,12 @@
     sub_match<BidiIter> prefix_;
     sub_match<BidiIter> suffix_;
     nested_results_type nested_results_;
-    //detail::action_state action_state_;
     intrusive_ptr<extras_type> extras_ptr_;
     intrusive_ptr<detail::traits<char_type> const> traits_;
+    detail::action_args_type args_;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
-// action_state_cast
-/// INTERNAL ONLY
-///
-//template<typename State, typename BidiIter>
-//inline State &action_state_cast(match_results<BidiIter> const &what)
-//{
-//    return what.BOOST_NESTED_TEMPLATE get_action_state<State>();
-//}
-
-///////////////////////////////////////////////////////////////////////////////
 // regex_id_filter_predicate
 //
 template<typename BidiIter>

Index: regex_actions.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_actions.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- regex_actions.hpp   23 Mar 2007 21:43:13 -0000      1.4
+++ regex_actions.hpp   24 Mar 2007 10:07:29 -0000      1.5
@@ -14,6 +14,7 @@
 # pragma once
 #endif
 
+#include <boost/mpl/identity.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/core/state.hpp>
@@ -25,6 +26,17 @@
 
     namespace detail
     {
+        template<typename T, typename U>
+        struct action_arg
+        {
+            typedef T type;
+
+            T &cast(void *pv) const
+            {
+                return *static_cast<T *>(pv);
+            }
+        };
+
         template<typename T>
         T &unconst(T const &t)
         {
@@ -213,6 +225,14 @@
         return proto::as_expr(p);
     }
 
+    template<typename T, typename U = void>
+    struct arg
+      : proto::extends<typename proto::terminal<detail::action_arg<T, U> 
>::type, arg<T, U> >
+    {
+        typedef proto::extends<typename proto::terminal<detail::action_arg<T, 
U> >::type, arg<T, U> > base_type;
+        using base_type::operator =;
+    };
+
 }}
 
 #endif // BOOST_XPRESSIVE_ACTIONS_HPP_EAN_03_22_2007

Index: regex_constants.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_constants.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- regex_constants.hpp 18 Mar 2007 07:07:00 -0000      1.7
+++ regex_constants.hpp 24 Mar 2007 10:07:29 -0000      1.8
@@ -226,6 +226,8 @@
                                 ///<
     error_badrule,              ///< An invalid use of a rule was detected.
                                 ///<
+    error_badarg,               ///< An argument to an action was unbound.
+                                ///<
     error_internal              ///< An internal error has occured.
                                 ///<
 };


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to