|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67271 - in sandbox/configurator: boost/configurator boost/configurator/detail libs/configurator/doc
From: for.dshevchenko_at_[hidden]
Date: 2010-12-16 02:24:07
Author: dshevchenko
Date: 2010-12-16 02:24:03 EST (Thu, 16 Dec 2010)
New Revision: 67271
URL: http://svn.boost.org/trac/boost/changeset/67271
Log:
Multi-line comments also may be custom!
Text files modified:
sandbox/configurator/boost/configurator/configurator.hpp | 4 +++-
sandbox/configurator/boost/configurator/configurator_settings.hpp | 22 ++++++++++++++++++++--
sandbox/configurator/boost/configurator/detail/comments_remover.hpp | 14 ++++++++------
sandbox/configurator/libs/configurator/doc/config_file_customizing.html | 34 +++++++++++++++++++++++++++++++++-
4 files changed, 64 insertions(+), 10 deletions(-)
Modified: sandbox/configurator/boost/configurator/configurator.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/configurator.hpp (original)
+++ sandbox/configurator/boost/configurator/configurator.hpp 2010-12-16 02:24:03 EST (Thu, 16 Dec 2010)
@@ -45,7 +45,9 @@
configurator() :
sections_separator( "::" )
, settings_of_configurator()
- , remove_comments_from( settings_of_configurator.one_line_comment_sign )
+ , remove_comments_from( settings_of_configurator.one_line_comment_sign
+ , settings_of_configurator.multi_line_comment_begin_sign
+ , settings_of_configurator.multi_line_comment_end_sign )
, options_obtainer( settings_of_configurator.option_name_value_separator
, sections_separator
, registered_options
Modified: sandbox/configurator/boost/configurator/configurator_settings.hpp
==============================================================================
--- sandbox/configurator/boost/configurator/configurator_settings.hpp (original)
+++ sandbox/configurator/boost/configurator/configurator_settings.hpp 2010-12-16 02:24:03 EST (Thu, 16 Dec 2010)
@@ -25,18 +25,36 @@
struct configurator_settings {
configurator_settings() :
option_name_value_separator( '=' )
- , one_line_comment_sign( "//" )
+ , one_line_comment_sign( "//" )
+ , multi_line_comment_begin_sign( "/*" )
+ , multi_line_comment_end_sign( "*/" )
, case_sensitivity( false ) {}
public:
char option_name_value_separator;
std::string one_line_comment_sign;
+ std::string multi_line_comment_begin_sign;
+ std::string multi_line_comment_end_sign;
bool case_sensitivity;
- //
public:
configurator_settings& set_one_line_comment_sign( const std::string& sign ) {
one_line_comment_sign = sign;
return *this;
}
+
+ configurator_settings& set_multi_line_comment_signs( const std::string& begin
+ , const std::string& end ) {
+ check_multi_line_comment_signs_validity( begin, end );
+ multi_line_comment_begin_sign = begin;
+ multi_line_comment_end_sign = end;
+ return *this;
+ }
+
+ void check_multi_line_comment_signs_validity( const std::string& begin
+ , const std::string& end ) const {
+ if ( begin == end ) {
+ detail::notify( "Incorrect multi-line comments signs, it cannot be equal!" );
+ } else {}
+ }
configurator_settings& set_case_sensitivity_for_names() {
case_sensitivity = true;
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-16 02:24:03 EST (Thu, 16 Dec 2010)
@@ -40,14 +40,16 @@
class comments_remover {
typedef boost::spirit::qi::rule< string_const_it > simple_rule;
public:
- explicit comments_remover( const std::string& _one_line_comment_sign ) :
+ comments_remover( const std::string& _one_line_comment_sign
+ , const std::string& _multi_line_comment_begin_sign
+ , const std::string& _multi_line_comment_end_sign) :
one_line_comment_sign( _one_line_comment_sign )
- , multi_line_comment_begin_sign( "/*" )
- , multi_line_comment_end_sign( "*/" ) {}
+ , multi_line_comment_begin_sign( _multi_line_comment_begin_sign )
+ , multi_line_comment_end_sign( _multi_line_comment_end_sign ) {}
private:
- const std::string& one_line_comment_sign;
- const std::string multi_line_comment_begin_sign;
- const std::string multi_line_comment_end_sign;
+ const std::string& one_line_comment_sign;
+ const std::string& multi_line_comment_begin_sign;
+ const std::string& multi_line_comment_end_sign;
public:
void operator()( str_storage& obtained_strings ) const {
std::string obtained = concatenate( obtained_strings );
Modified: sandbox/configurator/libs/configurator/doc/config_file_customizing.html
==============================================================================
--- sandbox/configurator/libs/configurator/doc/config_file_customizing.html (original)
+++ sandbox/configurator/libs/configurator/doc/config_file_customizing.html 2010-12-16 02:24:03 EST (Thu, 16 Dec 2010)
@@ -80,6 +80,8 @@
<br/>
<h3><a name="comments"></a>Comments</h3>
+ <h4>One-line</h4>
+
You can set custom one-line comment sign. It may be useful for some cases, for example:
<pre class="config">
Host = http://some.address.com/
@@ -94,7 +96,7 @@
int main( int argc, char* argv[] ) {
try {
boost::cf::configurator conf;
- conf.settings().set_one_line_comment_sign( '#' );
+ conf.settings().set_one_line_comment_sign( "#" );
// ...
} catch ( const std::exception& exc ) {
std::cerr << exc.what() << std::endl;
@@ -110,6 +112,36 @@
# |
# now it's just two slashes...
</pre>
+Of course, one-line comments may not necessarily begin with a single character. You may be accustomed to Emacs comments? No problems:
+<pre class="cpp">
+ // ...
+ boost::cf::configurator conf;
+ conf.settings().set_one_line_comment_sign( ";;" );
+ // ...
+</pre>
+So:
+<pre class="config">
+;; Emacs-like config...
+Host = http://some.address.com/
+</pre>
+
+ <h4>Multi-line</h4>
+
+ Also you can set custom multi-line comment signs. What if you want to use HTML-like comments? Let's do it:
+<pre class="cpp">
+ // ...
+ boost::cf::configurator conf;
+ conf.settings().set_multi_line_comment_signs( "<!--", "-->" );
+ // ...
+</pre>
+Now we can write:
+<pre class="config">
+Host = http://some.address.com/
+<!--
+This is HTML-like multi-line comment...
+-->
+</pre>
+
<br/>
<h3><a name="section_names_edging"></a>Section names edging</h3>
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