Boost logo

Boost-Commit :

From: joel_at_[hidden]
Date: 2008-04-27 21:07:53


Author: djowel
Date: 2008-04-27 21:07:52 EDT (Sun, 27 Apr 2008)
New Revision: 44831
URL: http://svn.boost.org/trac/boost/changeset/44831

Log:
tweaks
Added:
   trunk/boost/spirit/home/qi/char/detail/get_char.hpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/qi/char/char.hpp | 47 ++++++---------------------------------
   1 files changed, 8 insertions(+), 39 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 2008-04-27 21:07:52 EDT (Sun, 27 Apr 2008)
@@ -8,6 +8,7 @@
 #define BOOST_SPIRIT_CHAR_APR_16_2006_1051AM
 
 #include <boost/spirit/home/qi/char/char_parser.hpp>
+#include <boost/spirit/home/qi/char/detail/get_char.hpp>
 #include <boost/spirit/home/qi/domain.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/fusion/include/value_at.hpp>
@@ -53,22 +54,10 @@
             typedef unused_type type; // literal parsers have no attribute
         };
 
- template <typename CharParam>
- static CharParam get_char(CharParam ch)
- {
- return ch;
- }
-
- template <typename CharParam>
- static CharParam get_char(CharParam const* str)
- {
- return *str;
- }
-
         template <typename Component, typename CharParam, typename Context>
         static bool test(Component const& component, CharParam ch, Context&)
         {
- return get_char(fusion::at_c<0>(component.elements)) == ch;
+ return detail::get_char(fusion::at_c<0>(component.elements)) == ch;
         }
 
         template <typename Component>
@@ -76,7 +65,7 @@
         {
             return std::string("'")
                 + spirit::detail::to_narrow_char(
- get_char(fusion::at_c<0>(component.elements)))
+ detail::get_char(fusion::at_c<0>(component.elements)))
                 + '\'';
         }
     };
@@ -203,21 +192,11 @@
             typedef unused_type type; // literal parsers have no attribute
         };
 
- static Char get_char(Char ch)
- {
- return ch;
- }
-
- static Char get_char(Char const* str)
- {
- return *str;
- }
-
         template <typename Component, typename CharParam, typename Context>
         static bool test(Component const& component, CharParam ch, Context&)
         {
- return get_char(fusion::at_c<0>(component.elements)) == ch
- || get_char(fusion::at_c<1>(component.elements)) == ch
+ return detail::get_char(fusion::at_c<0>(component.elements)) == ch
+ || detail::get_char(fusion::at_c<1>(component.elements)) == ch
             ;
         }
 
@@ -227,11 +206,11 @@
             std::string result;
             result += std::string("'")
                 + spirit::detail::to_narrow_char(
- get_char(fusion::at_c<0>(component.elements))) + '\'';
+ detail::get_char(fusion::at_c<0>(component.elements))) + '\'';
             result += " or ";
             result += std::string("'") +
                 spirit::detail::to_narrow_char(
- get_char(fusion::at_c<1>(component.elements))) + '\'';
+ detail::get_char(fusion::at_c<1>(component.elements))) + '\'';
             return result;
         }
     };
@@ -334,22 +313,12 @@
             component<qi::domain, qi::no_case_literal_char<Char>, vector_type>
         type;
 
- static Char get_char(Char ch)
- {
- return ch;
- }
-
- static Char get_char(Char const* str)
- {
- return *str;
- }
-
         static type
         call(Elements const& elements)
         {
             typedef typename Modifier::char_set char_set;
 
- Char ch = get_char(fusion::at_c<0>(elements));
+ Char ch = qi::detail::get_char(fusion::at_c<0>(elements));
             vector_type v(
                 char_set::tolower(ch)
               , char_set::toupper(ch)

Added: trunk/boost/spirit/home/qi/char/detail/get_char.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/char/detail/get_char.hpp 2008-04-27 21:07:52 EDT (Sun, 27 Apr 2008)
@@ -0,0 +1,36 @@
+/*=============================================================================
+ Copyright (c) 2001-2007 Joel de Guzman
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#if !defined(BOOST_SPIRIT_GET_CHAR_APR_20_2008_0618_PM)
+#define BOOST_SPIRIT_GET_CHAR_APR_20_2008_0618_PM
+
+#include <string>
+
+namespace boost { namespace spirit { namespace qi { namespace detail
+{
+ // utility to get the (first) character from a primitive char,
+ // a null terminated string and a std::basic_string
+
+ template <typename Char>
+ static Char get_char(Char ch)
+ {
+ return ch;
+ }
+
+ template <typename Char>
+ static Char get_char(Char const* str)
+ {
+ return *str;
+ }
+
+ template <typename Char>
+ static Char get_char(std::basic_string<Char> const& str)
+ {
+ return str[0];
+ }
+}}}}
+
+#endif


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