11 # pragma warning(disable : 4251)
189 ArgParse(
int argc,
const char** argv);
197 : m_impl(std::move(other.m_impl))
248 ArgParse& exit_on_error(
bool exit_on_error);
253 void abort(
bool aborted =
true);
256 bool aborted()
const;
266 int parse_args(
int argc,
const char** argv);
285 void print_help()
const;
290 void briefusage()
const;
322 Arg& add_argument(
const char* argname);
348 return argx(argname,
args...);
352 Arg&
arg(
const char* argname) {
return add_argument(argname); }
357 return argx(argname,
args...);
387 using Action = std::function<void(cspan<const char*> myargs)>;
391 using ArgAction = std::function<void(Arg& arg, cspan<const char*> myargs)>;
480 m_argparse.params()[dest()] =
val;
493 m_argparse.params()[dest()] = 0;
504 m_argparse.params()[dest()] = 1;
519 #if OIIO_MSVS_BEFORE_2017
626 if (myarg[0][0] ==
'-')
627 myarg = myarg.subspan(1);
629 int n =
int(myarg.size());
631 for (
int i = 0; i <
n; ++i)
632 vals[i] = Strutil::from_string<T>(myarg[i]);
634 pl[arg.
dest()] = vals[0];
648 if (myarg[0][0] ==
'-')
649 myarg = myarg.subspan(1);
654 int nnew =
int(myarg.size());
657 for (
int i = 0; i < nold; ++i)
658 vals[i] = Strutil::from_string<T>(pv->get_string_indexed(i));
659 for (
int i = 0; i < nnew; ++i)
660 vals[i + nold] = Strutil::from_string<T>(myarg[i]);
662 pl[arg.
dest()] = vals[0];
673 static Action do_nothing();
710 return { &cparams(), name };
715 return { &
params(), name };
729 std::shared_ptr<Impl> m_impl;
730 Arg& argx(
const char* argname, ...);
731 friend class ArgOption;
744 int options(
const char* intro, ...);
748 int parse(
int argc,
const char** argv) {
return parse_args(argc, argv); }
751 typedef std::function<void(const ArgParse& ap, std::ostream&)>
callback_t;
755 void set_postoption_help(
callback_t callback);
758 void usage()
const { print_help(); }
765 #define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1
766 #define OIIO_ARGPARSE_SUPPORTS_HUMAN_PARAMNAME 1
OIIO_API std::string geterror(bool clear=true)
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
OIIO_API bool has_error()
Is there a pending global error message waiting to be retrieved?
ArgParse(ArgParse &&other)
Move constructor.
ArgParse & argparse()
Get a reference to the ArgParse that owns this Arg.
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
Arg & arg(const char *argname, T...args)
Shorter synonym for add_argument().
GLboolean GLboolean GLboolean GLboolean a
Arg & dest(string_view dest)
std::function< void(cspan< const char * > myargs)> Action
Holder for a callback that takes a span of C strings as arguments.
static ArgAction store_true()
Return an action that stores 1 into its destination attribute.
std::string help(const App *app, const Error &e)
Printout the full help string on error (if this fn is set, the old default for CLI11) ...
Arg & add_argument(const char *argname, T...args)
static ArgAction store_false()
Return an action that stores 0 into its destination attribute.
Arg & action(Action &&func)
Add an arbitrary action: func(cspan<const char*>)
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
GLenum const GLfloat * params
String-related utilities, all in namespace Strutil.
basic_string_view< char > string_view
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 size_t basevalues() const noexcept
Arg & action(void(*func)())
Add an arbitrary action: func()
Arg & defaultval(const T &val)
AttrDelegate< ParamValueList > operator[](string_view name)
Access a single argument result by name.
constexpr size_type size() const noexcept
GLuint const GLchar * name
static ArgAction store_const(const T &value)
int parse(int argc, const char **argv)
static ArgAction append()
GLsizeiptr const void GLenum usage
AttrDelegate< const ParamValueList > operator[](string_view name) const
Access a single argument result by name.
TypeDesc type() const noexcept
std::function< void(Arg &arg, cspan< const char * > myargs)> ArgAction
LeafData & operator=(const LeafData &)=delete
static ArgAction store_const(const char *value)
**If you just want to fire and args
Arg & arg(const char *argname)
Shorter synonym for add_argument().
Arg & action(int(*func)(int, const char **))
std::function< void(const ArgParse &ap, std::ostream &)> callback_t
#define OIIO_NAMESPACE_END
ParamValueList & params()
Directly access the ParamValueList that holds the argument results.
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
constexpr pointer data() const noexcept
#define OIIO_NAMESPACE_BEGIN