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

Class ExeName

tests/catch.hpp:7187–7227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7185 };
7186
7187 class ExeName : public ComposableParserImpl<ExeName> {
7188 std::shared_ptr<std::string> m_name;
7189 std::shared_ptr<BoundValueRefBase> m_ref;
7190
7191 template<typename LambdaT>
7192 static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {
7193 return std::make_shared<BoundLambda<LambdaT>>( lambda) ;
7194 }
7195
7196 public:
7197 ExeName() : m_name( std::make_shared<std::string>( "<executable>" ) ) {}
7198
7199 explicit ExeName( std::string &ref ) : ExeName() {
7200 m_ref = std::make_shared<BoundValueRef<std::string>>( ref );
7201 }
7202
7203 template<typename LambdaT>
7204 explicit ExeName( LambdaT const& lambda ) : ExeName() {
7205 m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );
7206 }
7207
7208 // The exe name is not parsed out of the normal tokens, but is handled specially
7209 auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
7210 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
7211 }
7212
7213 auto name() const -> std::string { return *m_name; }
7214 auto set( std::string const& newName ) -> ParserResult {
7215
7216 auto lastSlash = newName.find_last_of( "\\/" );
7217 auto filename = ( lastSlash == std::string::npos )
7218 ? newName
7219 : newName.substr( lastSlash+1 );
7220
7221 *m_name = filename;
7222 if( m_ref )
7223 return m_ref->setValue( filename );
7224 else
7225 return ParserResult::ok( ParseResultType::Matched );
7226 }
7227 };
7228
7229 class Arg : public ParserRefImpl<Arg> {
7230 public:

Callers 1

makeCommandLineParserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected