Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61159 - in trunk/boost/spirit/home: karma qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-04-09 11:46:52


Author: hkaiser
Date: 2010-04-09 11:46:51 EDT (Fri, 09 Apr 2010)
New Revision: 61159
URL: http://svn.boost.org/trac/boost/changeset/61159

Log:
Spirit: added overloads for all API functions allowing to take the iterator as const refs
Text files modified:
   trunk/boost/spirit/home/karma/generate.hpp | 75 ++++++++++++++++++++++++++++++++++++---
   trunk/boost/spirit/home/karma/generate_attr.hpp | 54 +++++++++++++++++++++++++---
   trunk/boost/spirit/home/qi/parse.hpp | 74 +++++++++++++++++++++++++++++++++++++--
   trunk/boost/spirit/home/qi/parse_attr.hpp | 48 +++++++++++++++++++++++++
   4 files changed, 233 insertions(+), 18 deletions(-)

Modified: trunk/boost/spirit/home/karma/generate.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/generate.hpp (original)
+++ trunk/boost/spirit/home/karma/generate.hpp 2010-04-09 11:46:51 EDT (Fri, 09 Apr 2010)
@@ -24,11 +24,21 @@
         return detail::generate_impl<Expr>::call(sink, expr);
     }
 
+ template <typename OutputIterator, typename Expr>
+ inline bool
+ generate(
+ OutputIterator const& sink_
+ , Expr const& expr)
+ {
+ OutputIterator sink = sink_;
+ return generate(sink, expr);
+ }
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr, typename Attr>
     inline bool
     generate(
- OutputIterator& target_sink
+ OutputIterator& sink_
       , Expr const& expr
       , Attr const& attr)
     {
@@ -43,7 +53,7 @@
 
         // wrap user supplied iterator into our own output iterator
         detail::output_iterator<OutputIterator
- , mpl::int_<properties::value> > sink(target_sink);
+ , mpl::int_<properties::value> > sink(sink_);
         return compile<karma::domain>(expr).generate(sink, unused, unused, attr);
     }
 
@@ -63,6 +73,17 @@
         return compile<karma::domain>(expr).generate(sink, unused, unused, attr);
     }
 
+ template <typename OutputIterator, typename Expr, typename Attr>
+ inline bool
+ generate(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Attr const& attr)
+ {
+ OutputIterator sink = sink_;
+ return generate(sink, expr, attr);
+ }
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr, typename Delimiter>
     inline bool
@@ -77,6 +98,19 @@
             sink, expr, delimiter, pre_delimit);
     }
 
+ template <typename OutputIterator, typename Expr, typename Delimiter>
+ inline bool
+ generate_delimited(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit =
+ delimit_flag::dont_predelimit)
+ {
+ OutputIterator sink = sink_;
+ return generate_delimited(sink, expr, delimiter, pre_delimit);
+ }
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Properties, typename Expr
       , typename Delimiter, typename Attribute>
@@ -107,12 +141,11 @@
             generate(sink, unused, delimiter_, attr);
     }
 
- ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr, typename Delimiter
       , typename Attribute>
     inline bool
     generate_delimited(
- OutputIterator& target_sink
+ OutputIterator& sink_
       , Expr const& expr
       , Delimiter const& delimiter
       , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
@@ -128,13 +161,27 @@
         // wrap user supplied iterator into our own output iterator
         detail::output_iterator<OutputIterator
           , mpl::int_<properties::value | delimiter_properties::value>
- > sink(target_sink);
+ > sink(sink_);
         return karma::generate_delimited(sink, expr, delimiter, pre_delimit, attr);
     }
 
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , typename Attribute>
+ inline bool
+ generate_delimited(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
+ , Attribute const& attr)
+ {
+ OutputIterator sink = sink_;
+ return generate_delimited(sink, expr, delimiter, pre_delimit, attr);
+ }
+
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputIterator, typename Expr, typename Attribute
- , typename Delimiter>
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , typename Attribute>
     inline bool
     generate_delimited(
         OutputIterator& sink
@@ -146,6 +193,20 @@
           , delimit_flag::dont_predelimit, attr);
     }
 
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , typename Attribute>
+ inline bool
+ generate_delimited(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , Attribute const& attr)
+ {
+ OutputIterator sink = sink_;
+ return karma::generate_delimited(sink, expr, delimiter
+ , delimit_flag::dont_predelimit, attr);
+ }
+
 }}}
 
 #endif

Modified: trunk/boost/spirit/home/karma/generate_attr.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/generate_attr.hpp (original)
+++ trunk/boost/spirit/home/karma/generate_attr.hpp 2010-04-09 11:46:51 EDT (Fri, 09 Apr 2010)
@@ -62,7 +62,7 @@
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
     inline bool
     generate(
- OutputIterator& target_sink
+ OutputIterator& sink_
       , Expr const& expr
       , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
     {
@@ -72,7 +72,19 @@
 
         // wrap user supplied iterator into our own output iterator
         detail::output_iterator<OutputIterator
- , mpl::int_<properties::value> > sink(target_sink);
+ , mpl::int_<properties::value> > sink(sink_);
+ return karma::generate(sink, expr, BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
+ template <typename OutputIterator, typename Expr
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ generate(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
+ {
+ OutputIterator sink = sink_;
         return karma::generate(sink, expr, BOOST_PP_ENUM_PARAMS(N, attr));
     }
 
@@ -116,7 +128,7 @@
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
     inline bool
     generate_delimited(
- OutputIterator& target_sink
+ OutputIterator& sink_
       , Expr const& expr
       , Delimiter const& delimiter
       , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
@@ -132,16 +144,32 @@
         // wrap user supplied iterator into our own output iterator
         detail::output_iterator<OutputIterator
           , mpl::int_<properties::value | delimiter_properties::value>
- > sink(target_sink);
+ > sink(sink_);
+ return karma::generate_delimited(sink, expr, delimiter, pre_delimit
+ , BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ generate_delimited(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
+ {
+ OutputIterator sink = sink_;
         return karma::generate_delimited(sink, expr, delimiter, pre_delimit
           , BOOST_PP_ENUM_PARAMS(N, attr));
     }
 
+ ///////////////////////////////////////////////////////////////////////////
     template <typename OutputIterator, typename Expr, typename Delimiter
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
     inline bool
     generate_delimited(
- OutputIterator& target_sink
+ OutputIterator& sink_
       , Expr const& expr
       , Delimiter const& delimiter
       , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
@@ -156,11 +184,25 @@
         // wrap user supplied iterator into our own output iterator
         detail::output_iterator<OutputIterator
           , mpl::int_<properties::value | delimiter_properties::value>
- > sink(target_sink);
+ > sink(sink_);
         return karma::generate_delimited(sink, expr, delimiter
           , delimit_flag::dont_predelimit, BOOST_PP_ENUM_PARAMS(N, attr));
     }
 
+ template <typename OutputIterator, typename Expr, typename Delimiter
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ generate_delimited(
+ OutputIterator const& sink_
+ , Expr const& expr
+ , Delimiter const& delimiter
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
+ {
+ OutputIterator sink = sink_;
+ return karma::generate_delimited(sink, expr, delimiter,
+ , delimit_flag::dont_predelimit, BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
 }}}
 
 #undef BOOST_SPIRIT_KARMA_ATTRIBUTE_REFERENCE

Modified: trunk/boost/spirit/home/qi/parse.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/parse.hpp (original)
+++ trunk/boost/spirit/home/qi/parse.hpp 2010-04-09 11:46:51 EDT (Fri, 09 Apr 2010)
@@ -25,7 +25,7 @@
       , Iterator last
       , Expr const& expr)
     {
- // Make sure the iterator is at least a forward_iterator. If you got an
+ // Make sure the iterator is at least a forward_iterator. If you got a
         // compilation error here, then you are using an input_iterator while
         // calling this function, you need to supply at least a
         // forward_iterator instead.
@@ -34,6 +34,18 @@
         return detail::parse_impl<Expr>::call(first, last, expr);
     }
 
+ template <typename Iterator, typename Expr>
+ inline bool
+ parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr)
+ {
+ Iterator first = first_;
+ return parse(first, last, expr);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator, typename Expr, typename Attr>
     inline bool
     parse(
@@ -42,7 +54,7 @@
       , Expr const& expr
       , Attr& attr)
     {
- // Make sure the iterator is at least a forward_iterator. If you got an
+ // Make sure the iterator is at least a forward_iterator. If you got a
         // compilation error here, then you are using an input_iterator while
         // calling this function, you need to supply at least a
         // forward_iterator instead.
@@ -56,6 +68,18 @@
         return compile<qi::domain>(expr).parse(first, last, unused, unused, attr);
     }
 
+ template <typename Iterator, typename Expr, typename Attr>
+ inline bool
+ parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Attr& attr)
+ {
+ Iterator first = first_;
+ return parse(first, last, expr, attr);
+ }
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator, typename Expr, typename Skipper>
     inline bool
@@ -66,7 +90,7 @@
       , Skipper const& skipper
       , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
     {
- // Make sure the iterator is at least a forward_iterator. If you got an
+ // Make sure the iterator is at least a forward_iterator. If you got a
         // compilation error here, then you are using an input_iterator while
         // calling this function, you need to supply at least a
         // forward_iterator instead.
@@ -76,6 +100,20 @@
             first, last, expr, skipper, post_skip);
     }
 
+ template <typename Iterator, typename Expr, typename Skipper>
+ inline bool
+ phrase_parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Skipper const& skipper
+ , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
+ {
+ Iterator first = first_;
+ return phrase_parse(first, last, expr, skipper, post_skip);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator, typename Expr, typename Skipper, typename Attr>
     inline bool
     phrase_parse(
@@ -86,7 +124,7 @@
       , BOOST_SCOPED_ENUM(skip_flag) post_skip
       , Attr& attr)
     {
- // Make sure the iterator is at least a forward_iterator. If you got an
+ // Make sure the iterator is at least a forward_iterator. If you got a
         // compilation error here, then you are using an input_iterator while
         // calling this function, you need to supply at least a
         // forward_iterator instead.
@@ -116,6 +154,21 @@
     template <typename Iterator, typename Expr, typename Skipper, typename Attr>
     inline bool
     phrase_parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Skipper const& skipper
+ , BOOST_SCOPED_ENUM(skip_flag) post_skip
+ , Attr& attr)
+ {
+ Iterator first = first_;
+ return phrase_parse(first, last, expr, skipper, post_skip, attr);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Iterator, typename Expr, typename Skipper, typename Attr>
+ inline bool
+ phrase_parse(
         Iterator& first
       , Iterator last
       , Expr const& expr
@@ -125,6 +178,19 @@
         return phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
     }
 
+ template <typename Iterator, typename Expr, typename Skipper, typename Attr>
+ inline bool
+ phrase_parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Skipper const& skipper
+ , Attr& attr)
+ {
+ Iterator first = first_;
+ return phrase_parse(first, last, expr, skipper, skip_flag::postskip, attr);
+ }
+
 }}}
 
 #endif

Modified: trunk/boost/spirit/home/qi/parse_attr.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/parse_attr.hpp (original)
+++ trunk/boost/spirit/home/qi/parse_attr.hpp 2010-04-09 11:46:51 EDT (Fri, 09 Apr 2010)
@@ -37,6 +37,7 @@
 
 namespace boost { namespace spirit { namespace qi
 {
+ ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator, typename Expr
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
     inline bool
@@ -65,6 +66,19 @@
         return compile<qi::domain>(expr).parse(first, last, unused, unused, attr);
     }
 
+ template <typename Iterator, typename Expr
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
+ {
+ Iterator first = first_;
+ return qi::parse(first, last, expr, BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
     ///////////////////////////////////////////////////////////////////////////
     template <typename Iterator, typename Expr, typename Skipper
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
@@ -113,13 +127,45 @@
       , BOOST_PP_ENUM_PARAMS(N, typename A)>
     inline bool
     phrase_parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Skipper const& skipper
+ , BOOST_SCOPED_ENUM(skip_flag) post_skip
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
+ {
+ Iterator first = first_;
+ return qi::phrase_parse(first, last, expr, skipper, post_skip
+ , BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Iterator, typename Expr, typename Skipper
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ phrase_parse(
         Iterator& first
       , Iterator last
       , Expr const& expr
       , Skipper const& skipper
       , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
     {
- return phrase_parse(first, last, expr, skipper, skip_flag::postskip
+ return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip
+ , BOOST_PP_ENUM_PARAMS(N, attr));
+ }
+
+ template <typename Iterator, typename Expr, typename Skipper
+ , BOOST_PP_ENUM_PARAMS(N, typename A)>
+ inline bool
+ phrase_parse(
+ Iterator const& first_
+ , Iterator last
+ , Expr const& expr
+ , Skipper const& skipper
+ , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr))
+ {
+ Iterator first = first_;
+ return qi::phrase_parse(first, last, expr, skipper, skip_flag::postskip
           , BOOST_PP_ENUM_PARAMS(N, attr));
     }
 


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