Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53723 - in trunk: boost/program_options/detail libs/program_options/src
From: ghost_at_[hidden]
Date: 2009-06-07 12:10:03


Author: vladimir_prus
Date: 2009-06-07 12:10:03 EDT (Sun, 07 Jun 2009)
New Revision: 53723
URL: http://svn.boost.org/trac/boost/changeset/53723

Log:
Make program_options compile with disabled exceptions.

It appears the all throw statements are during the
parsing, so alternative error reporting strategies are
possible.
Closes #2096.

Text files modified:
   trunk/boost/program_options/detail/value_semantic.hpp | 4 ++--
   trunk/libs/program_options/src/cmdline.cpp | 18 +++++++++---------
   trunk/libs/program_options/src/variables_map.cpp | 2 ++
   3 files changed, 13 insertions(+), 11 deletions(-)

Modified: trunk/boost/program_options/detail/value_semantic.hpp
==============================================================================
--- trunk/boost/program_options/detail/value_semantic.hpp (original)
+++ trunk/boost/program_options/detail/value_semantic.hpp 2009-06-07 12:10:03 EDT (Sun, 07 Jun 2009)
@@ -55,13 +55,13 @@
         {
             static std::basic_string<charT> empty;
             if (v.size() > 1)
- throw validation_error("multiple values not allowed");
+ boost::throw_exception(validation_error("multiple values not allowed"));
             if (v.size() == 1)
                 return v.front();
             else if (allow_empty)
                 return empty;
             else
- throw validation_error("at least one value required");
+ boost::throw_exception(validation_error("at least one value required"));
         }
 
         /* Throws multiple_occurrences if 'value' is not empty. */

Modified: trunk/libs/program_options/src/cmdline.cpp
==============================================================================
--- trunk/libs/program_options/src/cmdline.cpp (original)
+++ trunk/libs/program_options/src/cmdline.cpp 2009-06-07 12:10:03 EDT (Sun, 07 Jun 2009)
@@ -152,7 +152,7 @@
             error = "style disallows all characters for short options";
 
         if (error)
- throw invalid_command_line_style(error);
+ boost::throw_exception(invalid_command_line_style(error));
 
         // Need to check that if guessing and long disguise are enabled
         // -f will mean the same as -foo
@@ -326,8 +326,8 @@
                 if (opt.position_key != -1) {
                     if (position >= m_positional->max_total_count())
                     {
- throw too_many_positional_options_error(
- "too many positional options");
+ boost::throw_exception(too_many_positional_options_error(
+ "too many positional options"));
                     }
                     opt.string_key = m_positional->name_for_position(position);
                     ++position;
@@ -380,8 +380,8 @@
         if (present_tokens >= min_tokens)
         {
             if (!opt.value.empty() && max_tokens == 0) {
- throw invalid_command_line_syntax(opt.string_key,
- invalid_command_line_syntax::extra_parameter);
+ boost::throw_exception(invalid_command_line_syntax(opt.string_key,
+ invalid_command_line_syntax::extra_parameter));
             }
             
             // If an option wants, at minimum, N tokens, we grab them
@@ -406,8 +406,8 @@
         }
         else
         {
- throw invalid_command_line_syntax(opt.string_key,
- invalid_command_line_syntax::missing_parameter);
+ boost::throw_exception(invalid_command_line_syntax(opt.string_key,
+ invalid_command_line_syntax::missing_parameter));
 
         }
     }
@@ -427,8 +427,8 @@
                 name = tok.substr(2, p-2);
                 adjacent = tok.substr(p+1);
                 if (adjacent.empty())
- throw invalid_command_line_syntax(name,
- invalid_command_line_syntax::empty_adjacent_parameter);
+ boost::throw_exception( invalid_command_line_syntax(name,
+ invalid_command_line_syntax::empty_adjacent_parameter));
             }
             else
             {

Modified: trunk/libs/program_options/src/variables_map.cpp
==============================================================================
--- trunk/libs/program_options/src/variables_map.cpp (original)
+++ trunk/libs/program_options/src/variables_map.cpp 2009-06-07 12:10:03 EDT (Sun, 07 Jun 2009)
@@ -74,11 +74,13 @@
             try {
                 d.semantic()->parse(v.value(), options.options[i].value, utf8);
             }
+#ifndef BOOST_NO_EXCEPTIONS
             catch(validation_error& e)
             {
                 e.set_option_name(name);
                 throw;
             }
+#endif
             v.m_value_semantic = d.semantic();
             
             // The option is not composing, and the value is explicitly


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