Skip to content
Snippets Groups Projects
  • Mark Olesen's avatar
    724b034c
    argList enhancement: added convenience methods for accessing options · 724b034c
    Mark Olesen authored
    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.
    724b034c
    History
    argList enhancement: added convenience methods for accessing options
    Mark Olesen authored
    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.