|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55494 - in trunk/boost/spirit: home/karma/action home/karma/auxiliary home/karma/binary home/karma/char home/karma/detail home/karma/directive home/karma/numeric home/karma/numeric/detail home/karma/operator home/karma/string home/support include repository/home/karma/directive repository/home/qi/directive
From: hartmut.kaiser_at_[hidden]
Date: 2009-08-09 19:03:52
Author: hkaiser
Date: 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
New Revision: 55494
URL: http://svn.boost.org/trac/boost/changeset/55494
Log:
Spirit: changed semantics of karma::char_(), karma::string(), karma::int_() et.al., karma::double_() et.al.
Fixed attribute handling all over the place.
Added:
trunk/boost/spirit/home/karma/detail/string_compare.hpp (contents, props changed)
trunk/boost/spirit/include/karma_int.hpp (contents, props changed)
trunk/boost/spirit/include/karma_real.hpp (contents, props changed)
trunk/boost/spirit/include/karma_uint.hpp (contents, props changed)
Text files modified:
trunk/boost/spirit/home/karma/action/action.hpp | 2
trunk/boost/spirit/home/karma/auxiliary/lazy.hpp | 8 +-
trunk/boost/spirit/home/karma/binary/binary.hpp | 7 -
trunk/boost/spirit/home/karma/char/char.hpp | 43 ++++++++-----
trunk/boost/spirit/home/karma/directive/buffer.hpp | 7 -
trunk/boost/spirit/home/karma/directive/center_alignment.hpp | 16 ++--
trunk/boost/spirit/home/karma/directive/delimit.hpp | 9 -
trunk/boost/spirit/home/karma/directive/left_alignment.hpp | 16 ++--
trunk/boost/spirit/home/karma/directive/maxwidth.hpp | 9 -
trunk/boost/spirit/home/karma/directive/omit.hpp | 7 -
trunk/boost/spirit/home/karma/directive/repeat.hpp | 19 ++---
trunk/boost/spirit/home/karma/directive/right_alignment.hpp | 16 ++--
trunk/boost/spirit/home/karma/directive/verbatim.hpp | 9 -
trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 99 ++++++++++++++++++++++---------
trunk/boost/spirit/home/karma/numeric/int.hpp | 126 ++++++++++++++++++++++++++++++++-------
trunk/boost/spirit/home/karma/numeric/real.hpp | 83 +++++++++++++++++++++++---
trunk/boost/spirit/home/karma/numeric/uint.hpp | 108 ++++++++++++++++++++++++++++-----
trunk/boost/spirit/home/karma/operator/alternative.hpp | 4
trunk/boost/spirit/home/karma/operator/and_predicate.hpp | 5
trunk/boost/spirit/home/karma/operator/kleene.hpp | 19 ++---
trunk/boost/spirit/home/karma/operator/list.hpp | 18 ++---
trunk/boost/spirit/home/karma/operator/not_predicate.hpp | 5
trunk/boost/spirit/home/karma/operator/optional.hpp | 19 ++---
trunk/boost/spirit/home/karma/operator/plus.hpp | 19 ++---
trunk/boost/spirit/home/karma/operator/sequence.hpp | 4
trunk/boost/spirit/home/karma/string/lit.hpp | 84 +++++++++++++++++---------
trunk/boost/spirit/home/support/meta_compiler.hpp | 6 -
trunk/boost/spirit/repository/home/karma/directive/confix.hpp | 9 -
trunk/boost/spirit/repository/home/qi/directive/confix.hpp | 9 -
trunk/boost/spirit/repository/home/qi/directive/distinct.hpp | 2
30 files changed, 518 insertions(+), 269 deletions(-)
Modified: trunk/boost/spirit/home/karma/action/action.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/action/action.hpp (original)
+++ trunk/boost/spirit/home/karma/action/action.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -38,7 +38,7 @@
template <typename Context, typename Unused>
struct attribute
- : traits::attribute_of<Subject, Context, Unused>
+ : traits::attribute_of<Subject, Context>
{};
action(Subject const& subject, Action f)
Modified: trunk/boost/spirit/home/karma/auxiliary/lazy.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auxiliary/lazy.hpp (original)
+++ trunk/boost/spirit/home/karma/auxiliary/lazy.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -49,7 +49,7 @@
{
typedef mpl::int_<generator_properties::all_properties> properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
{
typedef typename
@@ -72,7 +72,7 @@
generator_type;
typedef typename
- traits::attribute_of<generator_type, Context, Unused>::type
+ traits::attribute_of<generator_type, Context, Iterator>::type
type;
};
@@ -114,7 +114,7 @@
typedef Subject subject_type;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
{
typedef typename
@@ -145,7 +145,7 @@
generator_type;
typedef typename
- traits::attribute_of<generator_type, Context>::type
+ traits::attribute_of<generator_type, Context, Iterator>::type
type;
};
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-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -231,11 +231,8 @@
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, data_type>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, data_type>
+ {};
template <typename T>
literal_binary_generator(T const& t)
Modified: trunk/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/char/char.hpp (original)
+++ trunk/boost/spirit/home/karma/char/char.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -81,9 +81,9 @@
///////////////////////////////////////////////////////////////////////////
//
// any_char
- // generates a single character from the associated parameter
+ // generates a single character from the associated attribute
//
- // Note: this generator has to have an associated parameter
+ // Note: this generator has to have an associated attribute
//
///////////////////////////////////////////////////////////////////////////
template <typename CharEncoding, typename Tag>
@@ -121,7 +121,7 @@
// providing any attribute, as the generator doesn't 'know' what
// character to output. The following assertion fires if this
// situation is detected in your code.
- BOOST_SPIRIT_ASSERT_MSG(false, char__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, char_not_usable_without_attribute, ());
return false;
}
@@ -152,17 +152,32 @@
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, char_type>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, char_type>
+ {};
+ // A char_('x') which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <
typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context&, Delimiter const& d
- , Attribute const&) const
+ , Attribute const& attr) const
+ {
+ // fail if attribute isn't matched my immediate literal
+ typedef spirit::char_class::convert<char_encoding> convert_type;
+ if (convert_type::to(Tag(), attr) != ch)
+ return false;
+
+ return karma::detail::generate_to(sink, ch) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A char_('x') without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
return karma::detail::generate_to(sink, ch) &&
karma::delimit_out(sink, d); // always do post-delimiting
@@ -191,14 +206,11 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef literal_char<
typename spirit::detail::get_encoding<
Modifiers, Encoding, lower || upper>::type
, typename get_casetag<Modifiers, lower || upper>::type
- , no_attr>
+ , true>
result_type;
template <typename Char>
@@ -270,14 +282,11 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef literal_char<
typename spirit::detail::get_encoding<
Modifiers, CharEncoding, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , no_attr
+ , false
> result_type;
template <typename Terminal>
Added: trunk/boost/spirit/home/karma/detail/string_compare.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/karma/detail/string_compare.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -0,0 +1,76 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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_KARMA_STRING_COMPARE_AUG_08_2009_0756PM)
+#define BOOST_SPIRIT_KARMA_STRING_COMPARE_AUG_08_2009_0756PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <string>
+#include <boost/spirit/home/support/char_class.hpp>
+#include <boost/spirit/home/karma/detail/generate_to.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost { namespace spirit { namespace karma { namespace detail
+{
+ template <typename Char>
+ bool string_compare(Char const* attr, Char const* lit)
+ {
+ Char ch_attr = *attr;
+ Char ch_lit = *lit;
+
+ while (!!ch_lit && !!ch_attr)
+ {
+ if (ch_attr != ch_lit)
+ return false;
+
+ ch_attr = *++attr;
+ ch_lit = *++lit;
+ }
+
+ return true;
+ }
+
+ template <typename Char>
+ bool string_compare(Char const* attr, Char const* lit, unused_type, unused_type)
+ {
+ return string_compare(attr, lit);
+ }
+
+ template <typename Char>
+ bool string_compare(unused_type, Char const*, unused_type, unused_type)
+ {
+ return true;
+ }
+
+ template <typename Char, typename CharEncoding, typename Tag>
+ bool string_compare(Char const* attr, Char const* lit, CharEncoding ce, Tag tag)
+ {
+ Char ch_attr = spirit::char_class::convert<CharEncoding>::to(Tag(), *attr);
+ Char ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *lit);
+
+ while (!!ch_lit && !!ch_attr)
+ {
+ if (ch_attr != ch_lit)
+ return false;
+
+ ch_attr = spirit::char_class::convert<CharEncoding>::to(Tag(), *++attr);
+ ch_lit = spirit::char_class::convert<CharEncoding>::to(Tag(), *++lit);
+ }
+
+ return true;
+ }
+
+ template <typename Char, typename CharEncoding, typename Tag>
+ bool string_compare(unused_type, Char const*, CharEncoding, Tag)
+ {
+ return true;
+ }
+
+}}}}
+
+#endif
Modified: trunk/boost/spirit/home/karma/directive/buffer.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/buffer.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/buffer.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -51,11 +51,8 @@
template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
Modified: trunk/boost/spirit/home/karma/directive/center_alignment.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/center_alignment.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/center_alignment.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -134,13 +134,10 @@
generator_properties::countingbuffer | subject_type::properties::value
> properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
simple_center_alignment(Subject const& subject, Width width = Width())
: subject(subject), width(width) {}
@@ -253,7 +250,12 @@
struct make_directive<
terminal_ex<tag::center, fusion::vector1<Padding> >
, Subject, Modifiers
- , typename enable_if<spirit::traits::matches<karma::domain, Padding> >::type>
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
{
typedef typename
result_of::compile<karma::domain, Padding, Modifiers>::type
Modified: trunk/boost/spirit/home/karma/directive/delimit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/delimit.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/delimit.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -60,13 +60,10 @@
typedef typename subject_type::properties properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
redelimit_generator(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/directive/left_alignment.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/left_alignment.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/left_alignment.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -117,13 +117,10 @@
generator_properties::counting | subject_type::properties::value
> properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
simple_left_alignment(Subject const& subject, Width width = Width())
: subject(subject), width(width) {}
@@ -236,7 +233,12 @@
struct make_directive<
terminal_ex<tag::left_align, fusion::vector1<Padding> >
, Subject, Modifiers
- , typename enable_if<spirit::traits::matches<karma::domain, Padding> >::type>
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
{
typedef typename
result_of::compile<karma::domain, Padding, Modifiers>::type
Modified: trunk/boost/spirit/home/karma/directive/maxwidth.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/maxwidth.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/maxwidth.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -138,13 +138,10 @@
generator_properties::countingbuffer | subject_type::properties::value
> properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
maxwidth_width(Subject const& subject, Width const& w = Width()
, Rest const& r = Rest())
Modified: trunk/boost/spirit/home/karma/directive/omit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/omit.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/omit.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -47,11 +47,8 @@
template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
Modified: trunk/boost/spirit/home/karma/directive/repeat.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/repeat.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/repeat.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -130,18 +130,15 @@
generator_properties::countingbuffer | subject_type::properties::value
> properties;
- template <typename Context, typename Unused>
+ // Build a std::vector from the subject's attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
struct attribute
- {
- // Build a std::vector from the subject's attribute. Note
- // that build_std_vector may return unused_type if the
- // subject's attribute is an unused_type.
- typedef typename
- traits::build_std_vector<
- typename traits::attribute_of<Subject, Context>::type
- >::type
- type;
- };
+ : traits::build_std_vector<
+ typename traits::attribute_of<Subject, Context, Iterator>::type
+ >
+ {};
repeat_generator(Subject const& subject, LoopIter const& iter)
: subject(subject), iter(iter) {}
Modified: trunk/boost/spirit/home/karma/directive/right_alignment.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/right_alignment.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/right_alignment.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -127,13 +127,10 @@
generator_properties::countingbuffer | subject_type::properties::value
> properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
simple_right_alignment(Subject const& subject, Width width = Width())
: subject(subject), width(width) {}
@@ -246,7 +243,12 @@
struct make_directive<
terminal_ex<tag::right_align, fusion::vector1<Padding> >
, Subject, Modifiers
- , typename enable_if<spirit::traits::matches<karma::domain, Padding> >::type>
+ , typename enable_if<
+ mpl::and_<
+ spirit::traits::matches<karma::domain, Padding>,
+ mpl::not_<mpl::bool_<integer_traits<Padding>::is_integral> >
+ >
+ >::type>
{
typedef typename
result_of::compile<karma::domain, Padding, Modifiers>::type
Modified: trunk/boost/spirit/home/karma/directive/verbatim.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/verbatim.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/verbatim.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -46,13 +46,10 @@
typedef Subject subject_type;
typedef typename subject_type::properties properties;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
verbatim_generator(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -49,49 +49,90 @@
// underflow
//
///////////////////////////////////////////////////////////////////////
- inline unsigned short absolute_value (short n)
- {
- return (n >= 0) ? n : (unsigned short)(-n);
- }
-
- inline unsigned int absolute_value (int n)
+ template <typename T>
+ struct absolute_value_helper
{
- return (n >= 0) ? n : (unsigned int)(-n);
- }
+ typedef T result_type;
+ static T call (T n)
+ {
+ // allow for ADL to find the correct overloads for fabs
+ using namespace std;
+ return fabs(n);
+ }
+ };
- inline unsigned long absolute_value (long n)
- {
- return (n >= 0) ? n : (unsigned long)(-n);
- }
+#define BOOST_SPIRIT_ABSOLUTE_VALUE(type, unsignedtype) \
+ template <> \
+ struct absolute_value_helper<type> \
+ { \
+ typedef unsignedtype result_type; \
+ static result_type call(type n) \
+ { \
+ return (n >= 0) ? n : (unsignedtype)(-n); \
+ } \
+ } \
+ /**/
+#define BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(type) \
+ template <> \
+ struct absolute_value_helper<type> \
+ { \
+ typedef type result_type; \
+ static result_type call(type n) \
+ { \
+ return n; \
+ } \
+ } \
+ /**/
+ BOOST_SPIRIT_ABSOLUTE_VALUE(short, unsigned short);
+ BOOST_SPIRIT_ABSOLUTE_VALUE(int, unsigned int);
+ BOOST_SPIRIT_ABSOLUTE_VALUE(long, unsigned long);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned short);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned int);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(unsigned long);
#ifdef BOOST_HAS_LONG_LONG
- inline boost::ulong_long_type absolute_value (boost::long_long_type n)
- {
- return (n >= 0) ? n : (boost::ulong_long_type)(-n);
- }
+ BOOST_SPIRIT_ABSOLUTE_VALUE(boost::long_long_type, boost::ulong_long_type);
+ BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(boost::ulong_long_type);
#endif
- inline float absolute_value (float n)
+#undef BOOST_SPIRIT_ABSOLUTE_VALUE
+#undef BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED
+
+ template <>
+ struct absolute_value_helper<float>
{
- return (spirit::detail::signbit)(n) ? -n : n;
- }
+ typedef long double result_type;
+ static result_type call(float n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
- inline double absolute_value (double n)
+ template <>
+ struct absolute_value_helper<double>
{
- return (spirit::detail::signbit)(n) ? -n : n;
- }
+ typedef long double result_type;
+ static result_type call(double n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
- inline long double absolute_value (long double n)
+ template <>
+ struct absolute_value_helper<long double>
{
- return (spirit::detail::signbit)(n) ? -n : n;
- }
+ typedef long double result_type;
+ static result_type call(long double n)
+ {
+ return (spirit::detail::signbit)(n) ? -n : n;
+ }
+ };
template <typename T>
- inline T absolute_value (T n)
+ typename absolute_value_helper<T>::result_type
+ absolute_value(T n)
{
- // allow for ADL to find the correct overloads for fabs
- using namespace std;
- return fabs(n);
+ return absolute_value_helper<T>::call(n);
}
///////////////////////////////////////////////////////////////////////
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-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -69,6 +69,25 @@
#endif
///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, short> // enables lit(short(0))
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, int> // enables lit(0)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, long> // enables lit(0L)
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct use_terminal<karma::domain, boost::long_long_type> // enables lit(0LL)
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename A0>
struct use_terminal<karma::domain // enables short_(...)
, terminal_ex<tag::short_, fusion::vector1<A0> >
@@ -146,6 +165,8 @@
using spirit::long_long_type;
#endif
+ using spirit::lit; // lit(1) is equivalent to 1
+
///////////////////////////////////////////////////////////////////////////
// This specialization is used for int generators not having a direct
// initializer: int_, long_ etc. These generators must be used in
@@ -179,12 +200,11 @@
generate(OutputIterator& sink, Context&, Delimiter const& d
, Attribute const& attr)
{
- return
- sign_inserter<force_sign>::call(sink
- , detail::is_zero(attr), detail::is_negative(attr)) &&
- int_inserter<Radix, CharEncoding, Tag>::call(sink
- , detail::absolute_value(attr)) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return sign_inserter<force_sign>::call(sink
+ , detail::is_zero(attr), detail::is_negative(attr)) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(attr)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
// this int has no Attribute attached, it needs to have been
@@ -193,7 +213,7 @@
static bool
generate(OutputIterator&, Context&, Delimiter const&, unused_type)
{
- BOOST_SPIRIT_ASSERT_MSG(false, int__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, int_not_usable_without_attribute, ());
return false;
}
@@ -217,11 +237,8 @@
{
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, T>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
literal_int_generator(typename add_const<T>::type n)
: n_(n) {}
@@ -234,17 +251,35 @@
BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
signed_unsigned_mismatch, ());
+ // A int_(1) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context&, Delimiter const& d
- , Attribute const&) const
+ , Attribute const& attr) const
+ {
+ if (n_ != attr)
+ return false;
+
+ return sign_inserter<force_sign>::call(sink
+ , detail::is_zero(n_), detail::is_negative(n_)) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(n_)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A int_(1) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
- return
- sign_inserter<force_sign>::call(sink
- , detail::is_zero(n_), detail::is_negative(n_)) &&
- int_inserter<Radix, CharEncoding, Tag>::call(sink
- , detail::absolute_value(n_)) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return sign_inserter<force_sign>::call(sink
+ , detail::is_zero(n_), detail::is_negative(n_)) &&
+ int_inserter<Radix, CharEncoding, Tag>::call(sink
+ , detail::absolute_value(n_)) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
template <typename Context>
@@ -316,17 +351,12 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef literal_int_generator<
T
, typename spirit::detail::get_encoding<
Modifiers, unused_type, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , Radix
- , force_sign
- , no_attr
+ , Radix, force_sign, false
> result_type;
template <typename Terminal>
@@ -336,6 +366,7 @@
}
};
+ ///////////////////////////////////////////////////////////////////////////
template <typename Modifiers, typename A0>
struct make_primitive<
terminal_ex<tag::short_, fusion::vector1<A0> >, Modifiers>
@@ -365,6 +396,51 @@
, Modifiers>
: make_int_direct<T, Modifiers, Radix, force_sign> {};
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_int_literal
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_int_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, false, true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
+
+ template <typename Modifiers>
+ struct make_primitive<short, Modifiers>
+ : detail::basic_int_literal<int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<int, Modifiers>
+ : detail::basic_int_literal<int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<long, Modifiers>
+ : detail::basic_int_literal<long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<boost::long_long_type, Modifiers>
+ : detail::basic_int_literal<boost::long_long_type, Modifiers> {};
+#endif
+
}}}
#endif
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-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -74,6 +74,19 @@
: mpl::true_ {};
///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<karma::domain, float> // enables lit(1.of)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, double> // enables lit(1.0)
+ : mpl::true_ {};
+
+ template <>
+ struct use_terminal<karma::domain, long double> // enables lit(1.0l)
+ : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename A0>
struct use_terminal<karma::domain // enables float_(...)
, terminal_ex<tag::float_, fusion::vector1<A0> >
@@ -195,20 +208,34 @@
{
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, T>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
literal_real_generator(typename add_const<T>::type n
, Policies const& policies = Policies())
: n_(n), p_(policies) {}
+ // A double_(1.0) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context&, Delimiter const& d
- , Attribute const&) const
+ , Attribute const& attr) const
+ {
+ if (n_ != attr)
+ return false;
+
+ typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
+ return inserter_type::call(sink, n_, p_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A double_(1.0) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
typedef real_inserter<T, Policies, CharEncoding, Tag> inserter_type;
return inserter_type::call(sink, n_, p_) &&
@@ -295,15 +322,12 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef literal_real_generator<
T, Policies
, typename spirit::detail::get_encoding<
Modifiers, unused_type, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , no_attr
+ , false
> result_type;
template <typename Terminal>
@@ -336,6 +360,45 @@
, Modifiers>
: make_real_direct<T, Modifiers, Policy> {};
+ ///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_real_literal
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_real_generator<
+ T, real_policies<T>
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
+
+ template <typename Modifiers>
+ struct make_primitive<float, Modifiers>
+ : detail::basic_real_literal<float, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<double, Modifiers>
+ : detail::basic_real_literal<double, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<long double, Modifiers>
+ : detail::basic_real_literal<long double, Modifiers> {};
+
}}}
#endif // defined(BOOST_SPIRIT_KARMA_REAL_FEB_26_2007_0512PM)
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-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -80,6 +80,25 @@
#endif
///////////////////////////////////////////////////////////////////////////
+ template <> // enables lit(unsigned short(0))
+ struct use_terminal<karma::domain, unsigned short>
+ : mpl::true_ {};
+
+ template <> // enables lit(0U)
+ struct use_terminal<karma::domain, unsigned int>
+ : mpl::true_ {};
+
+ template <> // enables lit(0UL)
+ struct use_terminal<karma::domain, unsigned long>
+ : mpl::true_ {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <> // enables lit(0ULL)
+ struct use_terminal<karma::domain, boost::ulong_long_type>
+ : mpl::true_ {};
+#endif
+
+ ///////////////////////////////////////////////////////////////////////////
template <typename A0>
struct use_terminal<karma::domain // enables ushort_(...)
, terminal_ex<tag::ushort_, fusion::vector1<A0> >
@@ -190,6 +209,8 @@
using spirit::hex;
using spirit::hex_type;
+ using spirit::lit; // lit(1U) is equivalent to 1U
+
///////////////////////////////////////////////////////////////////////////
// This specialization is used for unsigned int generators not having a
// direct initializer: uint_, ulong_ etc. These generators must be used in
@@ -220,9 +241,8 @@
generate(OutputIterator& sink, Context&, Delimiter const& d
, Attribute const& attr)
{
- return
- int_inserter<Radix, CharEncoding, Tag>::call(sink, attr) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, attr) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
// this int has no Attribute attached, it needs to have been
@@ -231,7 +251,7 @@
static bool
generate(OutputIterator&, Context&, Delimiter const&, unused_type)
{
- BOOST_SPIRIT_ASSERT_MSG(false, uint__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, uint_not_usable_without_attribute, ());
return false;
}
@@ -255,11 +275,8 @@
{
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, T>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, T>
+ {};
literal_uint_generator(typename add_const<T>::type n)
: n_(n) {}
@@ -272,14 +289,29 @@
BOOST_SPIRIT_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
signed_unsigned_mismatch, ());
+ // A uint(1U) which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context&, Delimiter const& d
- , Attribute const&) const
+ , Attribute const& attr) const
+ {
+ if (n_ != attr)
+ return false;
+
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A uint(1U) without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
- return
- int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
template <typename Context>
@@ -360,16 +392,12 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef literal_uint_generator<
T
, typename spirit::detail::get_encoding<
Modifiers, unused_type, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , Radix
- , no_attr
+ , Radix, false
> result_type;
template <typename Terminal>
@@ -422,6 +450,50 @@
, Modifiers>
: make_uint_direct<T, Modifiers, Radix> {};
+ namespace detail
+ {
+ template <typename T, typename Modifiers>
+ struct basic_uint_literal
+ {
+ static bool const lower =
+ has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
+ static bool const upper =
+ has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
+
+ typedef literal_uint_generator<
+ T
+ , typename spirit::detail::get_encoding<
+ Modifiers, unused_type, lower || upper>::type
+ , typename detail::get_casetag<Modifiers, lower || upper>::type
+ , 10, true
+ > result_type;
+
+ template <typename T_>
+ result_type operator()(T_ i, unused_type) const
+ {
+ return result_type(i);
+ }
+ };
+ }
+
+ template <typename Modifiers>
+ struct make_primitive<unsigned short, Modifiers>
+ : detail::basic_uint_literal<unsigned short, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<unsigned int, Modifiers>
+ : detail::basic_uint_literal<unsigned int, Modifiers> {};
+
+ template <typename Modifiers>
+ struct make_primitive<unsigned long, Modifiers>
+ : detail::basic_uint_literal<unsigned long, Modifiers> {};
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <typename Modifiers>
+ struct make_primitive<boost::ulong_long_type, Modifiers>
+ : detail::basic_uint_literal<boost::ulong_long_type, Modifiers> {};
+#endif
+
}}}
#endif
Modified: trunk/boost/spirit/home/karma/operator/alternative.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/alternative.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/alternative.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -74,12 +74,12 @@
typedef typename traits::alternative_properties<Elements>::type
properties;
- template <typename Context, typename Unused = unused_type>
+ template <typename Context, typename Iterator = unused_type>
struct attribute
{
// Put all the element attributes in a tuple
typedef typename traits::build_attribute_sequence<
- Elements, Context, mpl::identity
+ Elements, Context, mpl::identity, Iterator
>::type all_attributes;
// Ok, now make a variant over the attribute sequence. Note that
Modified: trunk/boost/spirit/home/karma/operator/and_predicate.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/and_predicate.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/and_predicate.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -42,9 +42,8 @@
template <typename Context, typename Iterator>
struct attribute
- {
- typedef unused_type type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
and_predicate(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/operator/kleene.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/kleene.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/kleene.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -41,18 +41,15 @@
typedef Subject subject_type;
typedef typename subject_type::properties properties;
- template <typename Context, typename Unused>
+ // Build a std::vector from the subject's attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
struct attribute
- {
- // Build a std::vector from the subject's attribute. Note
- // that build_std_vector may return unused_type if the
- // subject's attribute is an unused_type.
- typedef typename
- traits::build_std_vector<
- typename traits::attribute_of<Subject, Context>::type
- >::type
- type;
- };
+ : traits::build_std_vector<
+ typename traits::attribute_of<Subject, Context, Iterator>::type
+ >
+ {};
kleene(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/operator/list.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/list.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/list.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -42,19 +42,15 @@
left_type::properties::value | right_type::properties::value
> properties;
+ // Build a std::vector from the LHS's attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
template <typename Context, typename Iterator>
struct attribute
- {
- // Build a std::vector from the LHS's attribute. Note
- // that build_std_vector may return unused_type if the
- // subject's attribute is an unused_type.
- typedef typename
- traits::build_std_vector<
- typename traits::
- attribute_of<Left, Context, Iterator>::type
- >::type
- type;
- };
+ : traits::build_std_vector<
+ typename traits::attribute_of<Left, Context, Iterator>::type
+ >
+ {};
list(Left const& left, Right const& right)
: left(left), right(right) {}
Modified: trunk/boost/spirit/home/karma/operator/not_predicate.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/not_predicate.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/not_predicate.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -43,9 +43,8 @@
template <typename Context, typename Iterator>
struct attribute
- {
- typedef unused_type type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
not_predicate(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/operator/optional.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/optional.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/optional.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -85,18 +85,15 @@
typedef Subject subject_type;
typedef typename subject_type::properties properties;
- template <typename Context, typename Unused = unused_type>
+ // Build a boost::optional from the subject's attribute. Note
+ // that boost::optional may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator = unused_type>
struct attribute
- {
- // Build a boost::optional from the subject's attribute. Note
- // that boost::optional may return unused_type if the
- // subject's attribute is an unused_type.
- typedef typename
- traits::build_optional<
- typename traits::attribute_of<Subject, Context>::type
- >::type
- type;
- };
+ : traits::build_optional<
+ typename traits::attribute_of<Subject, Context, Iterator>::type
+ >
+ {};
optional(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/operator/plus.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/plus.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/plus.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -41,18 +41,15 @@
typedef Subject subject_type;
typedef typename subject_type::properties properties;
- template <typename Context, typename Unused>
+ // Build a std::vector from the subjects attribute. Note
+ // that build_std_vector may return unused_type if the
+ // subject's attribute is an unused_type.
+ template <typename Context, typename Iterator>
struct attribute
- {
- // Build a std::vector from the subject's attribute. Note
- // that build_std_vector may return unused_type if the
- // subject's attribute is an unused_type.
- typedef typename
- traits::build_std_vector<
- typename traits::attribute_of<Subject, Context>::type
- >::type
- type;
- };
+ : traits::build_std_vector<
+ typename traits::attribute_of<subject_type, Context, Iterator>::type
+ >
+ {};
plus(Subject const& subject)
: subject(subject) {}
Modified: trunk/boost/spirit/home/karma/operator/sequence.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/sequence.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/sequence.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -90,12 +90,12 @@
typedef Elements elements_type;
struct sequence_base_id;
- template <typename Context, typename Unused = unused_type>
+ template <typename Context, typename Iterator = unused_type>
struct attribute
{
// Put all the element attributes in a tuple
typedef typename traits::build_attribute_sequence<
- Elements, Context, mpl::identity>::type
+ Elements, Context, mpl::identity, Iterator>::type
all_attributes;
// Now, build a fusion vector over the attributes. Note
Modified: trunk/boost/spirit/home/karma/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/string/lit.hpp (original)
+++ trunk/boost/spirit/home/karma/string/lit.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -21,6 +21,7 @@
#include <boost/spirit/home/karma/auxiliary/lazy.hpp>
#include <boost/spirit/home/karma/detail/get_casetag.hpp>
#include <boost/spirit/home/karma/detail/string_generate.hpp>
+#include <boost/spirit/home/karma/detail/string_compare.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/cons.hpp>
@@ -131,26 +132,41 @@
template <typename Context, typename Unused>
struct attribute
- {
- typedef typename mpl::if_c<
- no_attribute, unused_type, string_type>::type
- type;
- };
+ : mpl::if_c<no_attribute, unused_type, string_type>
+ {};
literal_string(typename add_reference<String>::type str)
: str_(str)
{}
+ // A string("...") which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <
- typename OutputIterator, typename Context,
- typename Delimiter, typename Attribute
- >
- bool generate(OutputIterator& sink, Context& /*ctx*/
- , Delimiter const& d, Attribute const&) const
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // fail if attribute isn't matched my immediate literal
+ using spirit::traits::get_c_string;
+ if (!detail::string_compare(get_c_string(attr), get_c_string(str_)
+ , char_encoding(), Tag()))
+ {
+ return false;
+ }
+ return detail::string_generate(sink, str_, char_encoding(), Tag()) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A string("...") without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
- return
- detail::string_generate(sink, str_, char_encoding(), Tag()) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return detail::string_generate(sink, str_, char_encoding(), Tag()) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
template <typename Context>
@@ -182,16 +198,32 @@
literal_string(typename add_reference<String>::type str)
: str_(str) {}
+ // A string("...") which additionally has an associated attribute emits
+ // its immediate literal only if it matches the attribute, otherwise
+ // it fails.
template <
- typename OutputIterator, typename Context,
- typename Delimiter, typename Attribute
- >
- bool generate(OutputIterator& sink, Context& /*ctx*/
- , Delimiter const& d, Attribute const& attr) const
+ typename OutputIterator, typename Context, typename Delimiter
+ , typename Attribute>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , Attribute const& attr) const
+ {
+ // fail if attribute isn't matched my immediate literal
+ using spirit::traits::get_c_string;
+ if (!detail::string_compare(get_c_string(attr), get_c_string(str_)))
+ return false;
+
+ return detail::string_generate(sink, str_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
+ }
+
+ // A string("...") without any associated attribute just emits its
+ // immediate literal
+ template <typename OutputIterator, typename Context, typename Delimiter>
+ bool generate(OutputIterator& sink, Context&, Delimiter const& d
+ , unused_type) const
{
- return
- detail::string_generate(sink, str_) &&
- karma::delimit_out(sink, d); // always do post-delimiting
+ return detail::string_generate(sink, str_) &&
+ karma::delimit_out(sink, d); // always do post-delimiting
}
template <typename Context>
@@ -241,16 +273,13 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef typename add_const<T>::type const_string;
typedef literal_string<
const_string
, typename spirit::detail::get_encoding<
Modifiers, unused_type, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , no_attr
+ , true
> result_type;
result_type operator()(
@@ -272,16 +301,13 @@
static bool const upper =
has_modifier<Modifiers, tag::char_code<tag::upper, CharEncoding> >::value;
- static bool const no_attr =
- !has_modifier<Modifiers, tag::lazy_eval>::value;
-
typedef typename add_const<A0>::type const_string;
typedef literal_string<
const_string
, typename spirit::detail::get_encoding<
Modifiers, unused_type, lower || upper>::type
, typename detail::get_casetag<Modifiers, lower || upper>::type
- , no_attr
+ , false
> result_type;
template <typename Terminal>
Modified: trunk/boost/spirit/home/support/meta_compiler.hpp
==============================================================================
--- trunk/boost/spirit/home/support/meta_compiler.hpp (original)
+++ trunk/boost/spirit/home/support/meta_compiler.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -195,8 +195,7 @@
compile(Expr const& expr)
{
typedef typename proto::is_expr<Expr>::type is_expr;
- return detail::compiler<Domain>::/*template*/
- compile(expr, unused, is_expr());
+ return detail::compiler<Domain>::compile(expr, unused, is_expr());
}
template <typename Domain, typename Expr, typename Modifiers>
@@ -204,8 +203,7 @@
compile(Expr const& expr, Modifiers modifiers)
{
typedef typename proto::is_expr<Expr>::type is_expr;
- return detail::compiler<Domain>::/*template*/
- compile(expr, modifiers, is_expr());
+ return detail::compiler<Domain>::compile(expr, modifiers, is_expr());
}
///////////////////////////////////////////////////////////////////////////
Added: trunk/boost/spirit/include/karma_int.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/include/karma_int.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Joel de Guzman
+ Copyright (c) 2001-2009 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_INCLUDE_KARMA_INT
+#define BOOST_SPIRIT_INCLUDE_KARMA_INT
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/numeric/int.hpp>
+
+#endif
Added: trunk/boost/spirit/include/karma_real.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/include/karma_real.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Joel de Guzman
+ Copyright (c) 2001-2009 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_INCLUDE_KARMA_REAL
+#define BOOST_SPIRIT_INCLUDE_KARMA_REAL
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/numeric/real.hpp>
+
+#endif
Added: trunk/boost/spirit/include/karma_uint.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/include/karma_uint.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Joel de Guzman
+ Copyright (c) 2001-2009 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_INCLUDE_KARMA_UINT
+#define BOOST_SPIRIT_INCLUDE_KARMA_UINT
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/numeric/uint.hpp>
+
+#endif
Modified: trunk/boost/spirit/repository/home/karma/directive/confix.hpp
==============================================================================
--- trunk/boost/spirit/repository/home/karma/directive/confix.hpp (original)
+++ trunk/boost/spirit/repository/home/karma/directive/confix.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -55,13 +55,10 @@
{
typedef Subject subject_type;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
confix_generator(Subject const& subject, Prefix const& prefix
, Suffix const& suffix)
Modified: trunk/boost/spirit/repository/home/qi/directive/confix.hpp
==============================================================================
--- trunk/boost/spirit/repository/home/qi/directive/confix.hpp (original)
+++ trunk/boost/spirit/repository/home/qi/directive/confix.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -56,13 +56,10 @@
{
typedef Subject subject_type;
- template <typename Context, typename Unused>
+ template <typename Context, typename Iterator>
struct attribute
- {
- typedef typename
- traits::attribute_of<subject_type, Context>::type
- type;
- };
+ : traits::attribute_of<subject_type, Context, Iterator>
+ {};
confix_parser(Subject const& subject, Prefix const& prefix
, Suffix const& suffix)
Modified: trunk/boost/spirit/repository/home/qi/directive/distinct.hpp
==============================================================================
--- trunk/boost/spirit/repository/home/qi/directive/distinct.hpp (original)
+++ trunk/boost/spirit/repository/home/qi/directive/distinct.hpp 2009-08-09 19:03:43 EDT (Sun, 09 Aug 2009)
@@ -65,7 +65,7 @@
{
template <typename Context, typename Iterator>
struct attribute
- : traits::attribute_of<Subject>
+ : traits::attribute_of<Subject, Context, Iterator>
{};
distinct_parser(Subject const& subject, Tail const& tail)
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