MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / ExeName

Class ExeName

extern/Catch2/catch.hpp:9298–9338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9296 };
9297
9298 class ExeName : public ComposableParserImpl<ExeName> {
9299 std::shared_ptr<std::string> m_name;
9300 std::shared_ptr<BoundValueRefBase> m_ref;
9301
9302 template<typename LambdaT>
9303 static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {
9304 return std::make_shared<BoundLambda<LambdaT>>( lambda) ;
9305 }
9306
9307 public:
9308 ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {}
9309
9310 explicit ExeName( std::string &ref ) : ExeName() {
9311 m_ref = std::make_shared<BoundValueRef<std::string>>( ref );
9312 }
9313
9314 template<typename LambdaT>
9315 explicit ExeName( LambdaT const& lambda ) : ExeName() {
9316 m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );
9317 }
9318
9319 // The exe name is not parsed out of the normal tokens, but is handled specially
9320 auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9321 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9322 }
9323
9324 auto name() const -> std::string { return *m_name; }
9325 auto set( std::string const& newName ) -> ParserResult {
9326
9327 auto lastSlash = newName.find_last_of( "\\/" );
9328 auto filename = ( lastSlash == std::string::npos )
9329 ? newName
9330 : newName.substr( lastSlash+1 );
9331
9332 *m_name = filename;
9333 if( m_ref )
9334 return m_ref->setValue( filename );
9335 else
9336 return ParserResult::ok( ParseResultType::Matched );
9337 }
9338 };
9339
9340 class Arg : public ParserRefImpl<Arg> {
9341 public:

Callers 1

makeCommandLineParserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected