Update of /cvsroot/boost/boost/boost/xpressive/detail/static/transforms
In directory 
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29885/detail/static/transforms

Modified Files:
        as_set.hpp 
Log Message:
SetFillContext does proper widening of narrow chars

Index: as_set.hpp
===================================================================
RCS file: 
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/as_set.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- as_set.hpp  16 Apr 2007 08:10:15 -0000      1.5
+++ as_set.hpp  24 Apr 2007 07:05:20 -0000      1.6
@@ -21,6 +21,7 @@
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/detail/utility/chset/chset.hpp>
+#include <boost/xpressive/detail/utility/traits_utils.hpp>
 
 namespace boost { namespace xpressive { namespace detail
 {
@@ -60,24 +61,28 @@
         >
     {};
 
-    template<typename Char>
+    template<typename Traits>
     struct SetFillContext
-      : proto::callable_context<SetFillContext<Char> >
+      : proto::callable_context<SetFillContext<Traits> >
     {
-        explicit SetFillContext(Char *buf)
-          : buffer(buf)
+        typedef typename Traits::char_type char_type;
+        explicit SetFillContext(char_type *buffer, Traits const &traits)
+          : buffer_(buffer)
+          , traits_(traits)
         {}
 
         typedef xpressive::detail::set_initializer result_type;
 
         template<typename Tag, typename Left, typename Right>
-        result_type operator()(Tag, Left const &left, Right const &ch)
+        result_type operator()(Tag, Left const &left, Right const &right)
         {
-            *this->buffer++ = proto::arg(ch);
+            char_type ch = char_cast<char_type>(proto::arg(right), 
this->traits_);
+            *this->buffer_++ = this->traits_.translate(ch);
             return proto::eval(left, *this);
         }
 
-        Char *buffer;
+        char_type *buffer_;
+        Traits const &traits_;
     };
 
     template<typename Grammar>
@@ -99,15 +104,9 @@
         static typename apply<Expr, State, Visitor>::type
         call(Expr const &expr, State const &state, Visitor &visitor)
         {
-            typedef typename Visitor::char_type char_type;
-            typename apply<Expr, State, Visitor>::type set(visitor.traits());
-            SetFillContext<char_type> ctx(set.set_);
+            typename apply<Expr, State, Visitor>::type set;
+            SetFillContext<typename Visitor::traits_type> ctx(set.set_, 
visitor.traits());
             proto::eval(expr, ctx);
-            int const size = Grammar::template apply<Expr, State, 
Visitor>::type::value;
-            for(int i = 0; i < size; ++i)
-            {
-                set.set_[i] = visitor.traits().translate(set.set_[i]);
-            }
             return set;
         }
     };


-------------------------------------------------------------------------
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

Reply via email to