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

Class ExeName

test/expected/catch.hpp:9232–9272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9230 };
9231
9232 class ExeName : public ComposableParserImpl<ExeName> {
9233 std::shared_ptr<std::string> m_name;
9234 std::shared_ptr<BoundValueRefBase> m_ref;
9235
9236 template<typename LambdaT>
9237 static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {
9238 return std::make_shared<BoundLambda<LambdaT>>( lambda) ;
9239 }
9240
9241 public:
9242 ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {}
9243
9244 explicit ExeName( std::string &ref ) : ExeName() {
9245 m_ref = std::make_shared<BoundValueRef<std::string>>( ref );
9246 }
9247
9248 template<typename LambdaT>
9249 explicit ExeName( LambdaT const& lambda ) : ExeName() {
9250 m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );
9251 }
9252
9253 // The exe name is not parsed out of the normal tokens, but is handled specially
9254 auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9255 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9256 }
9257
9258 auto name() const -> std::string { return *m_name; }
9259 auto set( std::string const& newName ) -> ParserResult {
9260
9261 auto lastSlash = newName.find_last_of( "\\/" );
9262 auto filename = ( lastSlash == std::string::npos )
9263 ? newName
9264 : newName.substr( lastSlash+1 );
9265
9266 *m_name = filename;
9267 if( m_ref )
9268 return m_ref->setValue( filename );
9269 else
9270 return ParserResult::ok( ParseResultType::Matched );
9271 }
9272 };
9273
9274 class Arg : public ParserRefImpl<Arg> {
9275 public:

Callers 1

makeCommandLineParserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected