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