11/*
2- * Catch v1.4 .0
3- * Generated: 2016-03-15 07:23:12.623111
2+ * Catch v1.5 .0
3+ * Generated: 2016-04-25 18:56:14.308559
44 * ----------------------------------------------------------
55 * This file has been merged from multiple headers. Please don't edit it directly
66 * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -3618,7 +3618,7 @@ namespace Catch {
36183618#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
36193619// #included from: ../external/clara.h
36203620
3621- // Version 0.0.1.1
3621+ // Version 0.0.2.3
36223622
36233623// Only use header guard if we are not using an outer namespace
36243624#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
@@ -3934,6 +3934,10 @@ namespace Tbc {
39343934#include < stdexcept>
39353935#include < memory>
39363936
3937+ #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
3938+ #define CLARA_PLATFORM_WINDOWS
3939+ #endif
3940+
39373941// Use optional outer namespace
39383942#ifdef STITCH_CLARA_OPEN_NAMESPACE
39393943STITCH_CLARA_OPEN_NAMESPACE
@@ -3957,9 +3961,6 @@ namespace Clara {
39573961 const unsigned int consoleWidth = 80 ;
39583962#endif
39593963
3960- // Use this to try and stop compiler from warning about unreachable code
3961- inline bool isTrue ( bool value ) { return value; }
3962-
39633964 using namespace Tbc ;
39643965
39653966 inline bool startsWith ( std::string const & str, std::string const & prefix ) {
@@ -3995,14 +3996,6 @@ namespace Clara {
39953996 else
39963997 throw std::runtime_error ( " Expected a boolean value but did not recognise:\n '" + _source + " '" );
39973998 }
3998- inline void convertInto ( bool _source, bool & _dest ) {
3999- _dest = _source;
4000- }
4001- template <typename T>
4002- inline void convertInto ( bool , T& ) {
4003- if ( isTrue ( true ) )
4004- throw std::runtime_error ( " Invalid conversion" );
4005- }
40063999
40074000 template <typename ConfigT>
40084001 struct IArgFunction {
@@ -4012,7 +4005,6 @@ namespace Clara {
40124005 IArgFunction ( IArgFunction const & ) = default;
40134006#endif
40144007 virtual void set ( ConfigT& config, std::string const & value ) const = 0;
4015- virtual void setFlag ( ConfigT& config ) const = 0;
40164008 virtual bool takesArg () const = 0;
40174009 virtual IArgFunction* clone () const = 0;
40184010 };
@@ -4034,9 +4026,6 @@ namespace Clara {
40344026 void set ( ConfigT& config, std::string const & value ) const {
40354027 functionObj->set ( config, value );
40364028 }
4037- void setFlag ( ConfigT& config ) const {
4038- functionObj->setFlag ( config );
4039- }
40404029 bool takesArg () const { return functionObj->takesArg (); }
40414030
40424031 bool isSet () const {
@@ -4049,7 +4038,6 @@ namespace Clara {
40494038 template <typename C>
40504039 struct NullBinder : IArgFunction<C>{
40514040 virtual void set ( C&, std::string const & ) const {}
4052- virtual void setFlag ( C& ) const {}
40534041 virtual bool takesArg () const { return true ; }
40544042 virtual IArgFunction<C>* clone () const { return new NullBinder ( *this ); }
40554043 };
@@ -4060,9 +4048,6 @@ namespace Clara {
40604048 virtual void set ( C& p, std::string const & stringValue ) const {
40614049 convertInto ( stringValue, p.*member );
40624050 }
4063- virtual void setFlag ( C& p ) const {
4064- convertInto ( true , p.*member );
4065- }
40664051 virtual bool takesArg () const { return !IsBool<M>::value; }
40674052 virtual IArgFunction<C>* clone () const { return new BoundDataMember ( *this ); }
40684053 M C::* member;
@@ -4075,11 +4060,6 @@ namespace Clara {
40754060 convertInto ( stringValue, value );
40764061 (p.*member)( value );
40774062 }
4078- virtual void setFlag ( C& p ) const {
4079- typename RemoveConstRef<M>::type value;
4080- convertInto ( true , value );
4081- (p.*member)( value );
4082- }
40834063 virtual bool takesArg () const { return !IsBool<M>::value; }
40844064 virtual IArgFunction<C>* clone () const { return new BoundUnaryMethod ( *this ); }
40854065 void (C::*member)( M );
@@ -4093,9 +4073,6 @@ namespace Clara {
40934073 if ( value )
40944074 (p.*member)();
40954075 }
4096- virtual void setFlag ( C& p ) const {
4097- (p.*member)();
4098- }
40994076 virtual bool takesArg () const { return false ; }
41004077 virtual IArgFunction<C>* clone () const { return new BoundNullaryMethod ( *this ); }
41014078 void (C::*member)();
@@ -4110,9 +4087,6 @@ namespace Clara {
41104087 if ( value )
41114088 function ( obj );
41124089 }
4113- virtual void setFlag ( C& p ) const {
4114- function ( p );
4115- }
41164090 virtual bool takesArg () const { return false ; }
41174091 virtual IArgFunction<C>* clone () const { return new BoundUnaryFunction ( *this ); }
41184092 void (*function)( C& );
@@ -4126,20 +4100,27 @@ namespace Clara {
41264100 convertInto ( stringValue, value );
41274101 function ( obj, value );
41284102 }
4129- virtual void setFlag ( C& obj ) const {
4130- typename RemoveConstRef<T>::type value;
4131- convertInto ( true , value );
4132- function ( obj, value );
4133- }
41344103 virtual bool takesArg () const { return !IsBool<T>::value; }
41354104 virtual IArgFunction<C>* clone () const { return new BoundBinaryFunction ( *this ); }
41364105 void (*function)( C&, T );
41374106 };
41384107
41394108 } // namespace Detail
41404109
4141- struct Parser {
4142- Parser () : separators( " \t =:" ) {}
4110+ inline std::vector<std::string> argsToVector ( int argc, char const * const * const argv ) {
4111+ std::vector<std::string> args ( static_cast <std::size_t >( argc ) );
4112+ for ( std::size_t i = 0 ; i < static_cast <std::size_t >( argc ); ++i )
4113+ args[i] = argv[i];
4114+
4115+ return args;
4116+ }
4117+
4118+ class Parser {
4119+ enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional };
4120+ Mode mode;
4121+ std::size_t from;
4122+ bool inQuotes;
4123+ public:
41434124
41444125 struct Token {
41454126 enum Type { Positional, ShortOpt, LongOpt };
@@ -4148,38 +4129,75 @@ namespace Clara {
41484129 std::string data;
41494130 };
41504131
4151- void parseIntoTokens ( int argc, char const * const argv[], std::vector<Parser::Token>& tokens ) const {
4132+ Parser () : mode( None ), from( 0 ), inQuotes( false ){}
4133+
4134+ void parseIntoTokens ( std::vector<std::string> const & args, std::vector<Token>& tokens ) {
41524135 const std::string doubleDash = " --" ;
4153- for ( int i = 1 ; i < argc && argv[i] != doubleDash; ++i )
4154- parseIntoTokens ( argv[i] , tokens);
4155- }
4156- void parseIntoTokens ( std::string arg, std::vector<Parser::Token>& tokens ) const {
4157- while ( !arg.empty () ) {
4158- Parser::Token token ( Parser::Token::Positional, arg );
4159- arg = " " ;
4160- if ( token.data [0 ] == ' -' ) {
4161- if ( token.data .size () > 1 && token.data [1 ] == ' -' ) {
4162- token = Parser::Token ( Parser::Token::LongOpt, token.data .substr ( 2 ) );
4163- }
4164- else {
4165- token = Parser::Token ( Parser::Token::ShortOpt, token.data .substr ( 1 ) );
4166- if ( token.data .size () > 1 && separators.find ( token.data [1 ] ) == std::string::npos ) {
4167- arg = " -" + token.data .substr ( 1 );
4168- token.data = token.data .substr ( 0 , 1 );
4169- }
4170- }
4171- }
4172- if ( token.type != Parser::Token::Positional ) {
4173- std::size_t pos = token.data .find_first_of ( separators );
4174- if ( pos != std::string::npos ) {
4175- arg = token.data .substr ( pos+1 );
4176- token.data = token.data .substr ( 0 , pos );
4177- }
4178- }
4179- tokens.push_back ( token );
4136+ for ( std::size_t i = 1 ; i < args.size () && args[i] != doubleDash; ++i )
4137+ parseIntoTokens ( args[i], tokens);
4138+ }
4139+
4140+ void parseIntoTokens ( std::string const & arg, std::vector<Token>& tokens ) {
4141+ for ( std::size_t i = 0 ; i <= arg.size (); ++i ) {
4142+ char c = arg[i];
4143+ if ( c == ' "' )
4144+ inQuotes = !inQuotes;
4145+ mode = handleMode ( i, c, arg, tokens );
4146+ }
4147+ }
4148+ Mode handleMode ( std::size_t i, char c, std::string const & arg, std::vector<Token>& tokens ) {
4149+ switch ( mode ) {
4150+ case None: return handleNone ( i, c );
4151+ case MaybeShortOpt: return handleMaybeShortOpt ( i, c );
4152+ case ShortOpt:
4153+ case LongOpt:
4154+ case SlashOpt: return handleOpt ( i, c, arg, tokens );
4155+ case Positional: return handlePositional ( i, c, arg, tokens );
4156+ default : throw std::logic_error ( " Unknown mode" );
41804157 }
41814158 }
4182- std::string separators;
4159+
4160+ Mode handleNone ( std::size_t i, char c ) {
4161+ if ( inQuotes ) {
4162+ from = i;
4163+ return Positional;
4164+ }
4165+ switch ( c ) {
4166+ case ' -' : return MaybeShortOpt;
4167+ #ifdef CLARA_PLATFORM_WINDOWS
4168+ case ' /' : from = i+1 ; return SlashOpt;
4169+ #endif
4170+ default : from = i; return Positional;
4171+ }
4172+ }
4173+ Mode handleMaybeShortOpt ( std::size_t i, char c ) {
4174+ switch ( c ) {
4175+ case ' -' : from = i+1 ; return LongOpt;
4176+ default : from = i; return ShortOpt;
4177+ }
4178+ }
4179+ Mode handleOpt ( std::size_t i, char c, std::string const & arg, std::vector<Token>& tokens ) {
4180+ if ( std::string ( " \t :=\0 " , 5 ).find ( c ) == std::string::npos )
4181+ return mode;
4182+
4183+ std::string optName = arg.substr ( from, i-from );
4184+ if ( mode == ShortOpt )
4185+ for ( std::size_t j = 0 ; j < optName.size (); ++j )
4186+ tokens.push_back ( Token ( Token::ShortOpt, optName.substr ( j, 1 ) ) );
4187+ else if ( mode == SlashOpt && optName.size () == 1 )
4188+ tokens.push_back ( Token ( Token::ShortOpt, optName ) );
4189+ else
4190+ tokens.push_back ( Token ( Token::LongOpt, optName ) );
4191+ return None;
4192+ }
4193+ Mode handlePositional ( std::size_t i, char c, std::string const & arg, std::vector<Token>& tokens ) {
4194+ if ( inQuotes || std::string ( " \t\0 " , 3 ).find ( c ) == std::string::npos )
4195+ return mode;
4196+
4197+ std::string data = arg.substr ( from, i-from );
4198+ tokens.push_back ( Token ( Token::Positional, data ) );
4199+ return None;
4200+ }
41834201 };
41844202
41854203 template <typename ConfigT>
@@ -4482,21 +4500,21 @@ namespace Clara {
44824500 return oss.str ();
44834501 }
44844502
4485- ConfigT parse ( int argc, char const * const argv[] ) const {
4503+ ConfigT parse ( std::vector<std::string> const & args ) const {
44864504 ConfigT config;
4487- parseInto ( argc, argv , config );
4505+ parseInto ( args , config );
44884506 return config;
44894507 }
44904508
4491- std::vector<Parser::Token> parseInto ( int argc, char const * argv[] , ConfigT& config ) const {
4492- std::string processName = argv [0 ];
4509+ std::vector<Parser::Token> parseInto ( std::vector<std::string> const & args , ConfigT& config ) const {
4510+ std::string processName = args [0 ];
44934511 std::size_t lastSlash = processName.find_last_of ( " /\\ " );
44944512 if ( lastSlash != std::string::npos )
44954513 processName = processName.substr ( lastSlash+1 );
44964514 m_boundProcessName.set ( config, processName );
44974515 std::vector<Parser::Token> tokens;
44984516 Parser parser;
4499- parser.parseIntoTokens ( argc, argv , tokens );
4517+ parser.parseIntoTokens ( args , tokens );
45004518 return populate ( tokens, config );
45014519 }
45024520
@@ -4527,7 +4545,7 @@ namespace Clara {
45274545 arg.boundField .set ( config, tokens[++i].data );
45284546 }
45294547 else {
4530- arg.boundField .setFlag ( config );
4548+ arg.boundField .set ( config, " true " );
45314549 }
45324550 break ;
45334551 }
@@ -6306,10 +6324,10 @@ namespace Catch {
63066324 Catch::cout () << " For more detail usage please see the project docs\n " << std::endl;
63076325 }
63086326
6309- int applyCommandLine ( int argc, char const * argv[] , OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
6327+ int applyCommandLine ( int argc, char const * const * const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
63106328 try {
63116329 m_cli.setThrowOnUnrecognisedTokens ( unusedOptionBehaviour == OnUnusedOptions::Fail );
6312- m_unusedTokens = m_cli.parseInto ( argc, argv, m_configData );
6330+ m_unusedTokens = m_cli.parseInto ( Clara::argsToVector ( argc, argv ) , m_configData );
63136331 if ( m_configData.showHelp )
63146332 showHelp ( m_configData.processName );
63156333 m_config.reset ();
@@ -6333,16 +6351,13 @@ namespace Catch {
63336351 m_config.reset ();
63346352 }
63356353
6336- int run ( int argc, char const * argv[] ) {
6354+ int run ( int argc, char const * const * const argv ) {
63376355
63386356 int returnCode = applyCommandLine ( argc, argv );
63396357 if ( returnCode == 0 )
63406358 returnCode = run ();
63416359 return returnCode;
63426360 }
6343- int run ( int argc, char * argv[] ) {
6344- return run ( argc, const_cast <char const **>( argv ) );
6345- }
63466361
63476362 int run () {
63486363 if ( m_configData.showHelp )
@@ -7512,7 +7527,7 @@ namespace Catch {
75127527 return os;
75137528 }
75147529
7515- Version libraryVersion ( 1 , 4 , 0 , " " , 0 );
7530+ Version libraryVersion ( 1 , 5 , 0 , " " , 0 );
75167531
75177532}
75187533
@@ -8677,7 +8692,7 @@ namespace Catch {
86778692
86788693 virtual void assertionStarting ( AssertionInfo const & ) CATCH_OVERRIDE {}
86798694
8680- virtual bool assertionEnded ( AssertionStats const & assertionStats ) {
8695+ virtual bool assertionEnded ( AssertionStats const & assertionStats ) CATCH_OVERRIDE {
86818696 assert ( !m_sectionStack.empty () );
86828697 SectionNode& sectionNode = *m_sectionStack.back ();
86838698 sectionNode.assertions .push_back ( assertionStats );
0 commit comments