Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21828/boost/xpressive
Modified Files:
regex_primitives.hpp
Log Message:
allow (s1,-s1,s2) syntax as Subs parameter to regex_token_iterator ctor
Index: regex_primitives.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_primitives.hpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- regex_primitives.hpp 27 May 2007 08:06:46 -0000 1.36
+++ regex_primitives.hpp 1 Jun 2007 19:09:28 -0000 1.37
@@ -11,6 +11,7 @@
#include <climits>
#include <boost/mpl/if.hpp>
+#include <boost/mpl/and.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
@@ -49,6 +50,64 @@
using proto::extends<basic_mark_tag, mark_tag>::operator =;
};
+ template<typename Grammar>
+ struct push_back_sub
+ : Grammar
+ {
+ template<typename Expr, typename, typename>
+ struct apply { typedef Expr type; };
+
+ template<typename Expr, typename State, typename Visitor>
+ static Expr const &call(Expr const &expr, State const &, Visitor &subs)
+ {
+ subs.push_back(proto::arg(expr).mark_number_);
+ return expr;
+ }
+ };
+
+ template<typename Grammar>
+ struct push_back_int
+ : Grammar
+ {
+ template<typename Expr, typename, typename>
+ struct apply { typedef Expr type; };
+
+ template<typename Expr, typename State, typename Visitor>
+ static Expr const &call(Expr const &expr, State const &, Visitor &subs)
+ {
+ subs.push_back(-1);
+ return expr;
+ }
+ };
+
+ // s1 or -s1
+ struct SubMatch
+ : proto::or_<
+ push_back_sub< proto::terminal<mark_placeholder> >
+ , push_back_int< proto::negate<proto::terminal<mark_placeholder> > >
+ >
+ {};
+
+ struct SubMatchList
+ : proto::or_<
+ proto::comma<SubMatch, SubMatch>
+ , proto::comma<SubMatchList, SubMatch>
+ >
+ {};
+
+ template<typename Subs>
+ typename enable_if<
+ mpl::and_<proto::is_expr<Subs>, proto::matches<Subs, SubMatchList> >
+ , std::vector<int>
+ >::type
+ to_vector(Subs const &subs)
+ {
+ std::vector<int> subs_;
+ SubMatchList::call(subs, 0, subs_);
+ return subs_;
+ }
+
+
/*
///////////////////////////////////////////////////////////////////////////////
/// INTERNAL ONLY
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs