| 8979 | }; |
| 8980 | |
| 8981 | class ExeName : public ComposableParserImpl<ExeName> { |
| 8982 | std::shared_ptr<std::string> m_name; |
| 8983 | std::shared_ptr<BoundValueRefBase> m_ref; |
| 8984 | |
| 8985 | template<typename LambdaT> |
| 8986 | static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> { |
| 8987 | return std::make_shared<BoundLambda<LambdaT>>( lambda) ; |
| 8988 | } |
| 8989 | |
| 8990 | public: |
| 8991 | ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {} |
| 8992 | |
| 8993 | explicit ExeName( std::string &ref ) : ExeName() { |
| 8994 | m_ref = std::make_shared<BoundValueRef<std::string>>( ref ); |
| 8995 | } |
| 8996 | |
| 8997 | template<typename LambdaT> |
| 8998 | explicit ExeName( LambdaT const& lambda ) : ExeName() { |
| 8999 | m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda ); |
| 9000 | } |
| 9001 | |
| 9002 | // The exe name is not parsed out of the normal tokens, but is handled specially |
| 9003 | auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { |
| 9004 | return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); |
| 9005 | } |
| 9006 | |
| 9007 | auto name() const -> std::string { return *m_name; } |
| 9008 | auto set( std::string const& newName ) -> ParserResult { |
| 9009 | |
| 9010 | auto lastSlash = newName.find_last_of( "\\/" ); |
| 9011 | auto filename = ( lastSlash == std::string::npos ) |
| 9012 | ? newName |
| 9013 | : newName.substr( lastSlash+1 ); |
| 9014 | |
| 9015 | *m_name = filename; |
| 9016 | if( m_ref ) |
| 9017 | return m_ref->setValue( filename ); |
| 9018 | else |
| 9019 | return ParserResult::ok( ParseResultType::Matched ); |
| 9020 | } |
| 9021 | }; |
| 9022 | |
| 9023 | class Arg : public ParserRefImpl<Arg> { |
| 9024 | public: |
no outgoing calls
no test coverage detected