1
1
/*
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
4
4
* ----------------------------------------------------------
5
5
* This file has been merged from multiple headers. Please don't edit it directly
6
6
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -3618,7 +3618,7 @@ namespace Catch {
3618
3618
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
3619
3619
// #included from: ../external/clara.h
3620
3620
3621
- // Version 0.0.1.1
3621
+ // Version 0.0.2.3
3622
3622
3623
3623
// Only use header guard if we are not using an outer namespace
3624
3624
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
@@ -3934,6 +3934,10 @@ namespace Tbc {
3934
3934
#include < stdexcept>
3935
3935
#include < memory>
3936
3936
3937
+ #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
3938
+ #define CLARA_PLATFORM_WINDOWS
3939
+ #endif
3940
+
3937
3941
// Use optional outer namespace
3938
3942
#ifdef STITCH_CLARA_OPEN_NAMESPACE
3939
3943
STITCH_CLARA_OPEN_NAMESPACE
@@ -3957,9 +3961,6 @@ namespace Clara {
3957
3961
const unsigned int consoleWidth = 80 ;
3958
3962
#endif
3959
3963
3960
- // Use this to try and stop compiler from warning about unreachable code
3961
- inline bool isTrue ( bool value ) { return value; }
3962
-
3963
3964
using namespace Tbc ;
3964
3965
3965
3966
inline bool startsWith ( std::string const & str, std::string const & prefix ) {
@@ -3995,14 +3996,6 @@ namespace Clara {
3995
3996
else
3996
3997
throw std::runtime_error ( " Expected a boolean value but did not recognise:\n '" + _source + " '" );
3997
3998
}
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
- }
4006
3999
4007
4000
template <typename ConfigT>
4008
4001
struct IArgFunction {
@@ -4012,7 +4005,6 @@ namespace Clara {
4012
4005
IArgFunction ( IArgFunction const & ) = default;
4013
4006
#endif
4014
4007
virtual void set ( ConfigT& config, std::string const & value ) const = 0;
4015
- virtual void setFlag ( ConfigT& config ) const = 0;
4016
4008
virtual bool takesArg () const = 0;
4017
4009
virtual IArgFunction* clone () const = 0;
4018
4010
};
@@ -4034,9 +4026,6 @@ namespace Clara {
4034
4026
void set ( ConfigT& config, std::string const & value ) const {
4035
4027
functionObj->set ( config, value );
4036
4028
}
4037
- void setFlag ( ConfigT& config ) const {
4038
- functionObj->setFlag ( config );
4039
- }
4040
4029
bool takesArg () const { return functionObj->takesArg (); }
4041
4030
4042
4031
bool isSet () const {
@@ -4049,7 +4038,6 @@ namespace Clara {
4049
4038
template <typename C>
4050
4039
struct NullBinder : IArgFunction<C>{
4051
4040
virtual void set ( C&, std::string const & ) const {}
4052
- virtual void setFlag ( C& ) const {}
4053
4041
virtual bool takesArg () const { return true ; }
4054
4042
virtual IArgFunction<C>* clone () const { return new NullBinder ( *this ); }
4055
4043
};
@@ -4060,9 +4048,6 @@ namespace Clara {
4060
4048
virtual void set ( C& p, std::string const & stringValue ) const {
4061
4049
convertInto ( stringValue, p.*member );
4062
4050
}
4063
- virtual void setFlag ( C& p ) const {
4064
- convertInto ( true , p.*member );
4065
- }
4066
4051
virtual bool takesArg () const { return !IsBool<M>::value; }
4067
4052
virtual IArgFunction<C>* clone () const { return new BoundDataMember ( *this ); }
4068
4053
M C::* member;
@@ -4075,11 +4060,6 @@ namespace Clara {
4075
4060
convertInto ( stringValue, value );
4076
4061
(p.*member)( value );
4077
4062
}
4078
- virtual void setFlag ( C& p ) const {
4079
- typename RemoveConstRef<M>::type value;
4080
- convertInto ( true , value );
4081
- (p.*member)( value );
4082
- }
4083
4063
virtual bool takesArg () const { return !IsBool<M>::value; }
4084
4064
virtual IArgFunction<C>* clone () const { return new BoundUnaryMethod ( *this ); }
4085
4065
void (C::*member)( M );
@@ -4093,9 +4073,6 @@ namespace Clara {
4093
4073
if ( value )
4094
4074
(p.*member)();
4095
4075
}
4096
- virtual void setFlag ( C& p ) const {
4097
- (p.*member)();
4098
- }
4099
4076
virtual bool takesArg () const { return false ; }
4100
4077
virtual IArgFunction<C>* clone () const { return new BoundNullaryMethod ( *this ); }
4101
4078
void (C::*member)();
@@ -4110,9 +4087,6 @@ namespace Clara {
4110
4087
if ( value )
4111
4088
function ( obj );
4112
4089
}
4113
- virtual void setFlag ( C& p ) const {
4114
- function ( p );
4115
- }
4116
4090
virtual bool takesArg () const { return false ; }
4117
4091
virtual IArgFunction<C>* clone () const { return new BoundUnaryFunction ( *this ); }
4118
4092
void (*function)( C& );
@@ -4126,20 +4100,27 @@ namespace Clara {
4126
4100
convertInto ( stringValue, value );
4127
4101
function ( obj, value );
4128
4102
}
4129
- virtual void setFlag ( C& obj ) const {
4130
- typename RemoveConstRef<T>::type value;
4131
- convertInto ( true , value );
4132
- function ( obj, value );
4133
- }
4134
4103
virtual bool takesArg () const { return !IsBool<T>::value; }
4135
4104
virtual IArgFunction<C>* clone () const { return new BoundBinaryFunction ( *this ); }
4136
4105
void (*function)( C&, T );
4137
4106
};
4138
4107
4139
4108
} // namespace Detail
4140
4109
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:
4143
4124
4144
4125
struct Token {
4145
4126
enum Type { Positional, ShortOpt, LongOpt };
@@ -4148,38 +4129,75 @@ namespace Clara {
4148
4129
std::string data;
4149
4130
};
4150
4131
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 ) {
4152
4135
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" );
4180
4157
}
4181
4158
}
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
+ }
4183
4201
};
4184
4202
4185
4203
template <typename ConfigT>
@@ -4482,21 +4500,21 @@ namespace Clara {
4482
4500
return oss.str ();
4483
4501
}
4484
4502
4485
- ConfigT parse ( int argc, char const * const argv[] ) const {
4503
+ ConfigT parse ( std::vector<std::string> const & args ) const {
4486
4504
ConfigT config;
4487
- parseInto ( argc, argv , config );
4505
+ parseInto ( args , config );
4488
4506
return config;
4489
4507
}
4490
4508
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 ];
4493
4511
std::size_t lastSlash = processName.find_last_of ( " /\\ " );
4494
4512
if ( lastSlash != std::string::npos )
4495
4513
processName = processName.substr ( lastSlash+1 );
4496
4514
m_boundProcessName.set ( config, processName );
4497
4515
std::vector<Parser::Token> tokens;
4498
4516
Parser parser;
4499
- parser.parseIntoTokens ( argc, argv , tokens );
4517
+ parser.parseIntoTokens ( args , tokens );
4500
4518
return populate ( tokens, config );
4501
4519
}
4502
4520
@@ -4527,7 +4545,7 @@ namespace Clara {
4527
4545
arg.boundField .set ( config, tokens[++i].data );
4528
4546
}
4529
4547
else {
4530
- arg.boundField .setFlag ( config );
4548
+ arg.boundField .set ( config, " true " );
4531
4549
}
4532
4550
break ;
4533
4551
}
@@ -6306,10 +6324,10 @@ namespace Catch {
6306
6324
Catch::cout () << " For more detail usage please see the project docs\n " << std::endl;
6307
6325
}
6308
6326
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 ) {
6310
6328
try {
6311
6329
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 );
6313
6331
if ( m_configData.showHelp )
6314
6332
showHelp ( m_configData.processName );
6315
6333
m_config.reset ();
@@ -6333,16 +6351,13 @@ namespace Catch {
6333
6351
m_config.reset ();
6334
6352
}
6335
6353
6336
- int run ( int argc, char const * argv[] ) {
6354
+ int run ( int argc, char const * const * const argv ) {
6337
6355
6338
6356
int returnCode = applyCommandLine ( argc, argv );
6339
6357
if ( returnCode == 0 )
6340
6358
returnCode = run ();
6341
6359
return returnCode;
6342
6360
}
6343
- int run ( int argc, char * argv[] ) {
6344
- return run ( argc, const_cast <char const **>( argv ) );
6345
- }
6346
6361
6347
6362
int run () {
6348
6363
if ( m_configData.showHelp )
@@ -7512,7 +7527,7 @@ namespace Catch {
7512
7527
return os;
7513
7528
}
7514
7529
7515
- Version libraryVersion ( 1 , 4 , 0 , " " , 0 );
7530
+ Version libraryVersion ( 1 , 5 , 0 , " " , 0 );
7516
7531
7517
7532
}
7518
7533
@@ -8677,7 +8692,7 @@ namespace Catch {
8677
8692
8678
8693
virtual void assertionStarting ( AssertionInfo const & ) CATCH_OVERRIDE {}
8679
8694
8680
- virtual bool assertionEnded ( AssertionStats const & assertionStats ) {
8695
+ virtual bool assertionEnded ( AssertionStats const & assertionStats ) CATCH_OVERRIDE {
8681
8696
assert ( !m_sectionStack.empty () );
8682
8697
SectionNode& sectionNode = *m_sectionStack.back ();
8683
8698
sectionNode.assertions .push_back ( assertionStats );
0 commit comments