Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55904 - in trunk/boost/spirit/home/karma: binary numeric stream
From: hartmut.kaiser_at_[hidden]
Date: 2009-08-31 07:29:30


Author: hkaiser
Date: 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
New Revision: 55904
URL: http://svn.boost.org/trac/boost/changeset/55904

Log:
Spirit: default parameters for custom generator specs, semantic changes to binary generators
Text files modified:
   trunk/boost/spirit/home/karma/binary/binary.hpp | 38 +++++++++++++++++---------------------
   trunk/boost/spirit/home/karma/numeric/int.hpp | 2 +-
   trunk/boost/spirit/home/karma/numeric/real.hpp | 2 +-
   trunk/boost/spirit/home/karma/numeric/uint.hpp | 2 +-
   trunk/boost/spirit/home/karma/stream/stream.hpp | 2 +-
   5 files changed, 21 insertions(+), 25 deletions(-)

Modified: trunk/boost/spirit/home/karma/binary/binary.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/binary/binary.hpp (original)
+++ trunk/boost/spirit/home/karma/binary/binary.hpp 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
@@ -170,13 +170,10 @@
     struct any_binary_generator
       : primitive_generator<any_binary_generator<endian, bits> >
     {
- template <typename Context, typename Unused>
- struct attribute
- {
- typedef boost::integer::endian<
- endian, typename karma::detail::integer<bits>::type, bits
- > type;
- };
+ template <typename Context, typename Unused = unused_type>
+ struct attribute
+ : karma::detail::integer<bits>
+ {};
 
         template <
             typename OutputIterator, typename Context, typename Delimiter
@@ -187,7 +184,9 @@
             // Even if the endian types are not pod's (at least not in the
             // definition of C++03) it seems to be safe to assume they are.
             // This allows us to treat them as a sequence of consecutive bytes.
- typename attribute<Context, unused_type>::type p;
+ boost::integer::endian<
+ endian, typename karma::detail::integer<bits>::type, bits
+ > p;
             p = attr;
             unsigned char const* bytes =
                 reinterpret_cast<unsigned char const*>(&p);
@@ -220,19 +219,15 @@
     };
 
     ///////////////////////////////////////////////////////////////////////////
- template <BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits
- , bool no_attribute>
+ template <BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits>
     struct literal_binary_generator
- : primitive_generator<literal_binary_generator<endian, bits, no_attribute> >
+ : primitive_generator<literal_binary_generator<endian, bits> >
     {
- typedef boost::integer::endian<
- endian, typename karma::detail::integer<bits>::type, bits
- > data_type;
-
         template <typename Context, typename Unused>
         struct attribute
- : mpl::if_c<no_attribute, unused_type, data_type>
- {};
+ {
+ typedef unused_type type;
+ };
 
         template <typename T>
         literal_binary_generator(T const& t)
@@ -267,6 +262,10 @@
             return karma::detail::what<endian>::is();
         }
 
+ typedef boost::integer::endian<
+ endian, typename karma::detail::integer<bits>::type, bits
+ > data_type;
+
         data_type data_;
     };
 
@@ -291,10 +290,7 @@
           , BOOST_SCOPED_ENUM(boost::integer::endianness) endian, int bits>
         struct basic_binary_literal
         {
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
- typedef literal_binary_generator<endian, bits, no_attr> result_type;
+ typedef literal_binary_generator<endian, bits> result_type;
 
             template <typename Terminal>
             result_type operator()(Terminal const& term, unused_type) const

Modified: trunk/boost/spirit/home/karma/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/int.hpp 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
@@ -41,7 +41,7 @@
         ///////////////////////////////////////////////////////////////////////
         // This one is the class that the user can instantiate directly in
         // order to create a customized int generator
- template <typename T, unsigned Radix = 10, bool force_sign = false>
+ template <typename T = int, unsigned Radix = 10, bool force_sign = false>
         struct int_generator
           : spirit::terminal<tag::int_tag<T, Radix, force_sign> >
         {};

Modified: trunk/boost/spirit/home/karma/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/real.hpp 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
@@ -48,7 +48,7 @@
         ///////////////////////////////////////////////////////////////////////
         // This one is the class that the user can instantiate directly in
         // order to create a customized real generator
- template <typename T, typename Policies = real_policies<T> >
+ template <typename T = double, typename Policies = real_policies<T> >
         struct real_generator
           : spirit::terminal<tag::real_tag<T, Policies> >
         {

Modified: trunk/boost/spirit/home/karma/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/uint.hpp 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
@@ -40,7 +40,7 @@
         ///////////////////////////////////////////////////////////////////////
         // This one is the class that the user can instantiate directly in
         // order to create a customized int generator
- template <typename T, unsigned Radix = 10>
+ template <typename T = unsigned int, unsigned Radix = 10>
         struct uint_generator
           : spirit::terminal<tag::uint_tag<T, Radix> >
         {};

Modified: trunk/boost/spirit/home/karma/stream/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/stream.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/stream.hpp 2009-08-31 07:29:29 EDT (Mon, 31 Aug 2009)
@@ -34,7 +34,7 @@
 {
     namespace tag
     {
- template <typename Char>
+ template <typename Char = char>
         struct stream_tag {};
     }
 


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