Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60259 - in trunk/boost/spirit/home: qi/char support
From: joel_at_[hidden]
Date: 2010-03-06 20:27:33


Author: djowel
Date: 2010-03-06 20:27:33 EST (Sat, 06 Mar 2010)
New Revision: 60259
URL: http://svn.boost.org/trac/boost/changeset/60259

Log:
relaxing the input for char-sets (allow definition strings which have less bits than the target, e.g. char const* input where target is wchar_t).
Text files modified:
   trunk/boost/spirit/home/qi/char/char.hpp | 28 +++++++++++++++++++---------
   trunk/boost/spirit/home/support/char_class.hpp | 9 ++++++---
   2 files changed, 25 insertions(+), 12 deletions(-)

Modified: trunk/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/char.hpp (original)
+++ trunk/boost/spirit/home/qi/char/char.hpp 2010-03-06 20:27:33 EST (Sat, 06 Mar 2010)
@@ -24,6 +24,7 @@
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/remove_const.hpp>
 #include <string>
 
 #if defined(_MSC_VER)
@@ -262,32 +263,41 @@
         template <typename String>
         char_set(String const& str)
         {
- typedef typename traits::char_type_of<String>::type in_type;
+ using spirit::detail::cast_char;
+
+ typedef typename
+ remove_const<
+ typename traits::char_type_of<String>::type
+ >::type
+ in_type;
 
             BOOST_SPIRIT_ASSERT_MSG((
- (sizeof(char_type) == sizeof(in_type))
+ (sizeof(char_type) >= sizeof(in_type))
             ), cannot_convert_string, (String));
 
- char_type const* definition =
- (char_type const*)traits::get_c_string(str);
- char_type ch = *definition++;
+ in_type const* definition =
+ (in_type const*)traits::get_c_string(str);
+ in_type ch = *definition++;
             while (ch)
             {
- char_type next = *definition++;
+ in_type next = *definition++;
                 if (next == '-')
                 {
                     next = *definition++;
                     if (next == 0)
                     {
- chset.set(ch);
+ chset.set(cast_char<char_type>(ch));
                         chset.set('-');
                         break;
                     }
- chset.set(ch, next);
+ chset.set(
+ cast_char<char_type>(ch),
+ cast_char<char_type>(next)
+ );
                 }
                 else
                 {
- chset.set(ch);
+ chset.set(cast_char<char_type>(ch));
                 }
                 ch = next;
             }

Modified: trunk/boost/spirit/home/support/char_class.hpp
==============================================================================
--- trunk/boost/spirit/home/support/char_class.hpp (original)
+++ trunk/boost/spirit/home/support/char_class.hpp 2010-03-06 20:27:33 EST (Sat, 06 Mar 2010)
@@ -514,21 +514,24 @@
         static Char
         to(tag::lower, Char ch)
         {
- return static_cast<Char>(CharEncoding::tolower(detail::cast_char<char_type>(ch)));
+ return static_cast<Char>(
+ CharEncoding::tolower(detail::cast_char<char_type>(ch)));
         }
 
         template <typename Char>
         static Char
         to(tag::upper, Char ch)
         {
- return static_cast<Char>(CharEncoding::toupper(detail::cast_char<char_type>(ch)));
+ return static_cast<Char>(
+ CharEncoding::toupper(detail::cast_char<char_type>(ch)));
         }
 
         template <typename Char>
         static Char
         to(tag::ucs4, Char ch)
         {
- return static_cast<Char>(CharEncoding::toucs4(detail::cast_char<char_type>(ch)));
+ return static_cast<Char>(
+ CharEncoding::toucs4(detail::cast_char<char_type>(ch)));
         }
 
         template <typename Char>


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