Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# core.internal.parseoptions

parse configuration options
License:
Boost License 1.0.

Source core/internal/parseoptions.d

struct `MemVal`;
  UDA for field treated as memory value
bool `initConfigOptions`(CFG)(ref CFG `cfg`, string `cfgname`);
  initialize members of struct CFG from rt_config options
  options will be read from the environment, the command line or embedded into the executable as configured (see rt.config)
  fields of the struct are populated by parseOptions().
bool `parseOptions`(CFG)(ref CFG `cfg`, string `opt`);
  initialize members of struct CFG from a string of sub-options.
  fields of the struct are populated by listing them as space separated sub-options :value, e.g. "precise:1 profile:1"
  supported field value types:
  - strings (without spaces)
  - integer types (positive values only)
  - bool
  - float
  If the struct has a member "help" it is called if it is found as a sub-option. If the struct has a member "errorName", is used as the name reported in error messages. Otherwise the struct name is used.
bool `rt_parseOption`(T)(const(char)[] `optname`, ref inout(char)[] `str`, ref T `res`, const(char)[] `errName`);
  Parses an individual option `optname` value from a provided string `str`. The option type is given by the type T of the field `res` to which the parsed value will be written too. In case of an error, `errName` will be used to display an error message and the failure of the parsing will be indicated by a falsy return value.
  For boolean values, '0/n/N' (false) or '1/y/Y' (true) are accepted.
  Parameters:

  const(char)[] `optname` | name of the option to parse
  inout(char)[] `str` | raw string to parse the option value from
  T `res` | reference to the resulting data field that the option should be parsed too
  const(char)[] `errName` | full-text name of the option which should be displayed in case of errors

  Returns:
  false if a parsing error happened.

Copyright © 1999-2022 by the D Language Foundation | Page generated by Ddoc on Sat Sep 10 10:03:07 2022