Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67204 - sandbox/configurator/boost/configurator
From: for.dshevchenko_at_[hidden]
Date: 2010-12-13 02:01:48


Author: dshevchenko
Date: 2010-12-13 02:01:44 EST (Mon, 13 Dec 2010)
New Revision: 67204
URL: http://svn.boost.org/trac/boost/changeset/67204

Log:
Add

Added:
   sandbox/configurator/boost/configurator/configurator_settings.hpp (contents, props changed)
Text files modified:
   sandbox/configurator/boost/configurator/configurator.hpp | 4 +-
   sandbox/configurator/boost/configurator/option.hpp | 47 +++++++++++++++++++++++++--------------
   2 files changed, 32 insertions(+), 19 deletions(-)

Modified: sandbox/configurator/boost/configurator/configurator.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/configurator.hpp (original)
+++ sandbox/configurator/boost/configurator/configurator.hpp 2010-12-13 02:01:44 EST (Mon, 13 Dec 2010)
@@ -9,8 +9,8 @@
 #ifndef BOOST_CONFIGURATOR_HPP
 #define BOOST_CONFIGURATOR_HPP
 
-#include <boost/configurator/configurator_settings.hpp>
 #include <boost/configurator/macro.hpp>
+#include <boost/configurator/detail/configurator_settings.hpp>
 #include <boost/configurator/detail/validators.hpp>
 #include <boost/configurator/detail/type_name.hpp>
 #include <boost/configurator/detail/pure_option.hpp>
@@ -58,7 +58,7 @@
 private:
     detail::configurator_settings settings_of_configurator;
 public:
- configurator_settings& settings() {
+ detail::configurator_settings& settings() {
         return settings_of_configurator;
     }
 public:

Added: sandbox/configurator/boost/configurator/configurator_settings.hpp
==============================================================================
--- (empty file)
+++ sandbox/configurator/boost/configurator/configurator_settings.hpp 2010-12-13 02:01:44 EST (Mon, 13 Dec 2010)
@@ -0,0 +1,70 @@
+// detail/configurator_settings.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (C) 2010 Denis Shevchenko (for @ dshevchenko.biz)
+//
+// Distributed under the Boost Software License, version 1.0
+// (see http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_CONFIGURATOR_SETTINGS_HPP
+#define BOOST_CONFIGURATOR_SETTINGS_HPP
+
+#include <boost/configurator/detail/types.hpp>
+#include <boost/configurator/detail/misc.hpp>
+
+#include <string>
+
+namespace boost {
+
+/// \namespace cf
+/// \brief Main namespace of library.
+namespace cf {
+
+/// \namespace cf::detail
+/// \brief Details of realization.
+namespace detail {
+
+///
+struct configurator_settings {
+ configurator_settings() :
+ option_name_value_separator( '=' )
+ , option_name_value_separator_str( "=" )
+ , one_line_comment_sign( "//" )
+ , case_sensitivity( false ) {}
+public:
+ char option_name_value_separator;
+ std::string one_line_comment_sign;
+ bool case_sensitivity;
+ std::string option_name_value_separator_str;
+ //
+public:
+ configurator_settings& set_case_sensitivity_for_names() {
+ case_sensitivity = true;
+ return *this;
+ }
+
+ configurator_settings& set_name_value_separator( char separator ) {
+ option_name_value_separator = separator;
+ check_separator_validity();
+ return *this;
+ }
+private:
+ void check_separator_validity() const {
+ const int ascii_code = option_name_value_separator;
+ if ( ascii_code < 0x20 ) {
+ detail::o_stream what_happened;
+ what_happened << "Symbol (ASCII-code is " << ascii_code
+ << ") is not suitable for name-value separator!"
+ ;
+ notify( what_happened.str() );
+ } else {}
+ }
+public:
+ //
+};
+
+} // namespace detail
+} // namespace cf
+} // namespace boost
+
+#endif // BOOST_CONFIGURATOR_SETTINGS_HPP

Modified: sandbox/configurator/boost/configurator/option.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/option.hpp (original)
+++ sandbox/configurator/boost/configurator/option.hpp 2010-12-13 02:01:44 EST (Mon, 13 Dec 2010)
@@ -18,6 +18,29 @@
 /// \brief Main namespace of library.
 namespace cf {
 
+struct common_semantic {
+ explicit common_semantic( const detail::value_semantic& _semantic ) :
+ semantic( _semantic ) {}
+public:
+ const detail::value_semantic semantic;
+};
+
+#define BOOST_CONFIGURATOR_SEMANTIC( type ) \
+ struct type : public boost::cf::common_semantic { \
+ type() : boost::cf::common_semantic( boost::cf::detail::type ) {} \
+ };
+
+BOOST_CONFIGURATOR_SEMANTIC( no_semantic )
+BOOST_CONFIGURATOR_SEMANTIC( path )
+BOOST_CONFIGURATOR_SEMANTIC( optional_path )
+BOOST_CONFIGURATOR_SEMANTIC( ipv4 )
+BOOST_CONFIGURATOR_SEMANTIC( ipv6 )
+BOOST_CONFIGURATOR_SEMANTIC( ip )
+BOOST_CONFIGURATOR_SEMANTIC( email )
+BOOST_CONFIGURATOR_SEMANTIC( size )
+BOOST_CONFIGURATOR_SEMANTIC( time_period )
+BOOST_CONFIGURATOR_SEMANTIC( exp_record )
+
 ///
 struct option {
     option() {}
@@ -26,7 +49,7 @@
             , type_name( _type_name.begin(), _type_name.end() )
             , location( _type_name.begin(), _type_name.end() )
             , value()
- , semantic( no_semantic )
+ , semantic( detail::no_semantic )
             , necessary( false )
             , multi_values_allowed( false ) {}
     virtual ~option() {}
@@ -37,7 +60,7 @@
     std::string location;
     std::string section;
     std::string value;
- value_semantic semantic;
+ detail::value_semantic semantic;
     bool necessary;
     bool multi_values_allowed;
     std::string default_value;
@@ -104,29 +127,19 @@
         } else {}
     }
 public:
- option& check_semantic( const value_semantic& _semantic ) {
- check_semantic_correctness( _semantic );
- semantic = _semantic;
+ template< typename Semantic >
+ option& check_semantic() {
+ Semantic sem;
+ semantic = sem.semantic;
         return *this;
     }
-private:
- void check_semantic_correctness( const value_semantic& semantic ) const {
- if ( semantic < no_semantic || semantic > exp_record ) {
- detail::o_stream what_happened;
- what_happened << "Invalid semantic value '" << semantic
- << "' for option '" << type_name
- << "', use supported semantic only (see documentation)!"
- ;
- notify( what_happened.str() );
- } else {}
- }
 public:
     option& allow_multi_values() {
         multi_values_allowed = true;
         return *this;
     }
 public:
- bool semantic_defined() const { return no_semantic != semantic; }
+ bool semantic_defined() const { return detail::no_semantic != semantic; }
     bool already_has_default_value() const { return !default_value.empty(); }
     bool is_necessary() const { return necessary; }
     bool empty() const { return value.empty(); }


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