BDE 4.14.0 Production release
|
Provide a type for an error code with an optional error message.
This component defines a complex-constrained value-semantic attribute class bdld::DatumError
representing an error code with an optional descriptive error message. This component holds a reference to the error message that was supplied at construction. Accessors inside Datum
class that need to return an error value, return an instance of DatumError
.
This section illustrates intended use of this component.
Suppose we need a function to verify if newly created password meets basic security requirements. Password must contain at least one uppercase letter, one lowercase letter, one numeral and one special symbol. The following code illustrates how to use bdld::DatumError
to notify user about password weaknesses.
First, we need to write a verification function:
Passed string analysis:
Result compilation:
Next, we need to create password for verification and call our function:
Then, check the results:
Finally, we can print the result to the output stream: