MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ExeName

Class ExeName

Source/ThirdParty/catch2/catch.hpp:9293–9333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

makeCommandLineParserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected