Skip to content
Snippets Groups Projects
Commit 724b034c authored by Mark Olesen's avatar Mark Olesen
Browse files

argList enhancement: added convenience methods for accessing options

Oriented somewhat on dictionary methods.

Return the argument string associated with the named option:
    Info<< "-foo: " << args.option("foo") << nl;

Return true if the named option is found
    if (args.optionFound("foo")) ...

Return an IStringStream to the named option
    old:      value = readScalar(IStringStream(args.options()["foo"])());
    newer:    value = readScalar(args.optionLookup("foo")());
    also:     List<scalar> lst(args.optionLookup("foo")());

Read a value from the named option
    newest:   value = args.optionRead<scalar>("foo");

Read a value from the named option if present.
    old:  if (args.options().found("foo"))
          {
              value = readScalar(IStringStream(args.options()["foo"])());
          }
    new:  args.optionReadIfPresent("foo", value);

Read a List of values from the named option
    patches = args.optionReadList<word>("patches");

Didn't bother adding optionReadListIfPresent<T>(const word&), since it
probably wouldn't be common anyhow.
parent 1d2a94c3
Branches
Tags
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment