Parse input into element and validate it against typeInfo.

Synopsis

Declared in <balcl_typeinfo.h>

static
bool
parseAndValidate(
    OptionValue* element,
    std::string_view const& input,
    TypeInfo const& typeInfo,
    std::ostream& stream,
    TypeInfo::ParseInputSource inputSource = TypeInfo::e_COMMAND_LINE);

Description

Load into the specified element the result of parsing the specified input as a value of the element‐>type(). Return true if input is parsed without error and the value satisfies the constraint of the specified typeInfo object (if any), and false with no effect on element otherwise. If the operation fails, a descriptive error message indicating the reason for the failure is written to the specified stream. If typeInfo holds no constraint that validation is considered true; nevertheless, the parse might still fail due to problems with the input format. Optionally specify inputSource indicating the source of the option text being parsed. If inputSource is not provided, input is treated as if it came from the command line. inputSource is used in handling boolean options. Boolean options supplied by command line should not have associated text, where as boolean options supplied by the environment should have the values "0", "1", "true", or "false". The behavior is undefined unless element‐>type() == typeInfo.type().

Return Value

true if parsing and validation succeed, and false otherwise

Parameters

Name

Description

element

destination for the parsed value

input

text to parse

typeInfo

type and constraint information

stream

diagnostic output stream

inputSource

source of the option text

Created with MrDocs