/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #ifndef CLIUTIL_H #define CLIUTIL_H #include #include #include #include // for std::pair #include namespace pvxs { struct ArgVal { std::string value; bool defined = false; ArgVal() = default; ArgVal(std::nullptr_t) {} ArgVal(const std::string& value) :value(value), defined(true) {} ArgVal(const char* value) :value(value), defined(true) {} inline explicit operator bool() const { return defined; } inline const std::string& operator*() const { if(defined) return value; throw std::logic_error("Undefined argument value"); } template inline V as() const { return parseTo(**this); } }; bool operator==(const ArgVal& rhs, const ArgVal& lhs); struct GetOpt { GetOpt(int argc, char *argv[], const char *spec); const char *argv0; std::vector positional; std::vector> arguments; bool success = false; }; } // namespace pvxs #endif // CLIUTIL_H