Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67062 - sandbox/configurator/boost/configurator/detail
From: for.dshevchenko_at_[hidden]
Date: 2010-12-06 06:49:24


Author: dshevchenko
Date: 2010-12-06 06:49:22 EST (Mon, 06 Dec 2010)
New Revision: 67062
URL: http://svn.boost.org/trac/boost/changeset/67062

Log:
Correction error with EXP_RECORD. Spirit is no so easy, but awesome!

Text files modified:
   sandbox/configurator/boost/configurator/detail/comments_remover.hpp | 9 ++++-----
   sandbox/configurator/boost/configurator/detail/misc.hpp | 6 ++++++
   sandbox/configurator/boost/configurator/detail/validators.hpp | 37 +++++++++++--------------------------
   3 files changed, 21 insertions(+), 31 deletions(-)

Modified: sandbox/configurator/boost/configurator/detail/comments_remover.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/detail/comments_remover.hpp (original)
+++ sandbox/configurator/boost/configurator/detail/comments_remover.hpp 2010-12-06 06:49:22 EST (Mon, 06 Dec 2010)
@@ -13,7 +13,7 @@
 #include <boost/mem_fn.hpp>
 #include <boost/assign.hpp>
 
-#include <iostream>
+// #include <iostream>
 
 namespace boost {
 
@@ -58,13 +58,12 @@
                        , boost::bind( &comments_remover::remove_one_line_comment
                                       , this
                                       , _1 ) );
+ trim_all( obtained_strings );
     }
     
     void remove_one_line_comment( std::string& s ) const {
- if ( boost::contains( s, one_line_comment_sign ) ) {
- s.erase( boost::find_first( s, one_line_comment_sign ).begin()
- , s.end() );
- } else {}
+ s.erase( boost::find_first( s, one_line_comment_sign ).begin()
+ , s.end() );
     }
 private:
     void remove_multi_line_comments_from( str_storage& obtained_strings ) const {

Modified: sandbox/configurator/boost/configurator/detail/misc.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/detail/misc.hpp (original)
+++ sandbox/configurator/boost/configurator/detail/misc.hpp 2010-12-06 06:49:22 EST (Mon, 06 Dec 2010)
@@ -99,6 +99,12 @@
                    , strings.end() );
 }
 
+inline trim_all( str_storage& storage ) {
+ BOOST_FOREACH ( std::string& s, storage ) {
+ boost::trim( s );
+ }
+}
+
 } // namespace detail
 } // namespace cf
 } // namespace boost

Modified: sandbox/configurator/boost/configurator/detail/validators.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/detail/validators.hpp (original)
+++ sandbox/configurator/boost/configurator/detail/validators.hpp 2010-12-06 06:49:22 EST (Mon, 06 Dec 2010)
@@ -36,8 +36,6 @@
 namespace detail {
 
 using namespace boost::assign;
-using namespace boost::spirit;
-using namespace boost::spirit::qi;
 
 inline std::string semantic_error_prefix() { return "Semantic error: "; }
 
@@ -416,21 +414,22 @@
 /// \brief Exponential record validator.
 ///
 /// Check exponential record semantics.
-class exp_record_validator : common_validator {
+class exp_record_validator : common_validator {
 public:
     exp_record_validator( options& registered_options, const std::string& sections_separator ) :
             common_validator( registered_options, sections_separator ) {}
 public:
     void check( const std::string& exp_record, const std::string& option_name ) {
- #ifdef WITH_SEMANTIC_CHECK
- double mantissa = 0.0;
- int degree = 0;
+ #ifdef WITH_SEMANTIC_CHECK
+ using boost::spirit::qi::long_double;
+ using boost::spirit::qi::parse;
+
+ double number = 0.0;
         bool valid_exp_record = parse( exp_record.begin()
                                        , exp_record.end()
- , double_ >> 'e' | 'E' >> int_
- , mantissa, degree );
+ , long_double
+ , number );
         if ( valid_exp_record ) {
- long double number = mantissa * calculate_ten_in_degree( degree, option_name );
             store_for_option( option_name, number );
         } else {
             notify_about_invalid_exp_record( option_name, exp_record );
@@ -438,25 +437,11 @@
         #endif
     }
 #ifdef WITH_SEMANTIC_CHECK
-private:
- long double calculate_ten_in_degree( int degree, const std::string& option_name ) const {
- long double ten_in_degree = ::pow( 10, degree );
- if ( HUGE_VAL == ten_in_degree ) {
- o_stream what_happened;
- what_happened << "value of option '"
- << prepare_full_name_for_log( option_name, sections_separator )
- << "' define in correct exponential record, "
- << "but it degree '" << degree << "' is too big!";
- notify( semantic_error_prefix() + what_happened.str() );
- } else {}
- return ten_in_degree;
- }
-
+private:
     void notify_about_invalid_exp_record( const std::string& option_name
                                           , const std::string& exp_record ) const {
- notify( semantic_error_prefix()
- + "option '" + option_name
- + "' has invalid 'EXP_RECORD' value '" + exp_record + "'!" );
+ notify( semantic_error_prefix() + "option '" + option_name
+ + "' has invalid 'EXP_RECORD' value '" + exp_record + "'!" );
     }
 #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