MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / ExeName

Class ExeName

Bcore/src/main/cpp/Dobby/tests/catch.hpp:5879–5918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5877};
5878
5879class ExeName : public ComposableParserImpl<ExeName> {
5880 std::shared_ptr<std::string> m_name;
5881 std::shared_ptr<BoundValueRefBase> m_ref;
5882
5883 template <typename LambdaT> static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {
5884 return std::make_shared<BoundLambda<LambdaT>>(lambda);
5885 }
5886
5887public:
5888 ExeName() : m_name(std::make_shared<std::string>("<executable>")) {
5889 }
5890
5891 explicit ExeName(std::string &ref) : ExeName() {
5892 m_ref = std::make_shared<BoundValueRef<std::string>>(ref);
5893 }
5894
5895 template <typename LambdaT> explicit ExeName(LambdaT const &lambda) : ExeName() {
5896 m_ref = std::make_shared<BoundLambda<LambdaT>>(lambda);
5897 }
5898
5899 // The exe name is not parsed out of the normal tokens, but is handled specially
5900 auto parse(std::string const &, TokenStream const &tokens) const -> InternalParseResult override {
5901 return InternalParseResult::ok(ParseState(ParseResultType::NoMatch, tokens));
5902 }
5903
5904 auto name() const -> std::string {
5905 return *m_name;
5906 }
5907 auto set(std::string const &newName) -> ParserResult {
5908
5909 auto lastSlash = newName.find_last_of("\\/");
5910 auto filename = (lastSlash == std::string::npos) ? newName : newName.substr(lastSlash + 1);
5911
5912 *m_name = filename;
5913 if (m_ref)
5914 return m_ref->setValue(filename);
5915 else
5916 return ParserResult::ok(ParseResultType::Matched);
5917 }
5918};
5919
5920class Arg : public ParserRefImpl<Arg> {
5921public:

Callers 1

makeCommandLineParserFunction · 0.85

Calls

no outgoing calls

Tested by 1

makeCommandLineParserFunction · 0.68