$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [boost/spirit]  numeric policy
From: Brian Schrom (brian.schrom_at_[hidden])
Date: 2013-07-31 12:37:55
I've had the case where I needed to retain formatting information for a
number (general, fixed, scientific) and was nicely accomplished by
extending the policy, but needed to have a begin_parse() and end_parse()
for the policy to be complete.  It seems that it makes some sense or is
this accomplished another way?  Maybe something to consider for policies
in general?
Index: qi/numeric/real_policies.hpp
===================================================================
--- qi/numeric/real_policies.hpp        (revision 85166)
+++ qi/numeric/real_policies.hpp        (working copy)
@@ -28,6 +28,18 @@
         static bool const allow_trailing_dot = true;
         static bool const expect_dot = false;
 
+        template <typename Attribute>
+        static void
+        begin_parse(Attribute& attr_)
+        {
+        }
+
+        template <typename Attribute>
+        static void
+        end_parse(Attribute& attr_,bool /* result */)
+        {
+        }
+
         template <typename Iterator>
         static bool
         parse_sign(Iterator& /*first*/, Iterator const& /*last*/)
Index: qi/numeric/detail/real_impl.hpp
===================================================================
--- qi/numeric/detail/real_impl.hpp     (revision 85166)
+++ qi/numeric/detail/real_impl.hpp     (working copy)
@@ -133,6 +133,7 @@
         parse(Iterator& first, Iterator const& last, Attribute& attr,
             RealPolicies const& p)
         {
+            p.begin_parse(attr);
             if (first == last)
                 return false;
             Iterator save = first;
@@ -257,6 +258,7 @@
             // If we got a negative sign, negate the number
             traits::assign_to(traits::negate(neg, n), attr);
 
+            p.end_parse(attr, true);    // maybe this should return a
bool and be the return value?
             // Success!!!
             return true;
         }