xtd 0.2.0
Loading...
Searching...
No Matches

◆ try_parse()

static bool xtd::version::try_parse ( const xtd::ustring input,
version result 
)
staticnoexcept

Tries to convert the string representation of a version number to an equivalent xtd::version object, and returns a value that indicates whether the conversion succeeded.

Parameters
inputA string that contains a version number to convert.
resultWhen this method returns, contains the xtd::version equivalent of the number that is contained in input, if the conversion succeeded. If input is empty, or if the conversion fails, result is empty when the method returns.
Returns
true if the input parameter was converted successfully; otherwise, false.
Remarks
The xtd::version::try_parse method is similar to the xtd::version::parse method, except that it doesn't throw an exception if the conversion fails. Instead, it returns false if input is null, has fewer than two or more than four components, has at least one component that is not an integer, has at least one component that is less than zero, or has at least one component that is greater than std::numeric_limits<int32>::max(). For the parse operation to succeed, the input parameter must be in the following format:
major.minor[.build[.revision]] 
where major, minor, build, and revision are the string representations of the version number's four components: major version number, minor version number, build number, and revision number, respectively. Optional components are shown in square brackets ([ and ]). The components must appear in order and must be separated by periods.