Detailed Description
class FiftyoneDegrees::Common::Value< T >
Encapsulates a value returned an instance of ResultsBase for a specified property.
An instance contains either the value, or the reason which there is no value.
Before retrieving the value itself, its presence should first be checked using the hasValue() method. The typed value can be returned either using the getValue() method, or more simply, by dereferencing (similarly to an iterator). If there is no value, then an exception will be thrown.
Usage Example
- Template Parameters
-
T the type of the value e.g. string
- Examples
- Hash/GettingStarted.cpp.
Public Member Functions | |
Constructors | |
| Value () | |
| Default constructor. | |
Value Methods | |
| bool | hasValue () const |
| Indicates whether or not a valid value has been returned by the ResultsBase instance. | |
| fiftyoneDegreesResultsNoValueReason | getNoValueReason () const |
| Indicates the reason why valid values are not available. | |
| const char * | getNoValueMessage () const |
| Gets a message explaining why there is no value. | |
| T | getValue () const |
| Gets the value contained in the Value instance. | |
| void | setValue (T targetValue) |
| Set the value to be contained in the Value instance. | |
| void | setNoValueReason (fiftyoneDegreesResultsNoValueReason reason, const char *message) |
| Set the reason there is no value available. | |
Operators | |
| T | operator* () const |
| Gets the value contained in the Value instance. | |
Member Function Documentation
◆ getNoValueMessage()
|
inline |
Gets a message explaining why there is no value.
Calling this if hasValue() returned true will result in undefined behavior.
- Returns
- message explaining the reason for the missing value
- Examples
- Hash/GettingStarted.cpp.
◆ getNoValueReason()
|
inline |
Indicates the reason why valid values are not available.
This can be called if hasValue() returns false. For a more detailed message, call getNoValueMessage().
- Returns
- enum indicating the reason for no valid values
◆ getValue()
|
inline |
Gets the value contained in the Value instance.
If there is no valid value, then an exception will be thrown. To prevent an exception, the hasValue() method should be checked first.
- Returns
- value
- Examples
- Hash/GettingStarted.cpp.
◆ hasValue()
|
inline |
Indicates whether or not a valid value has been returned by the ResultsBase instance.
- Returns
- true if there is a valid value
- Examples
- Hash/GettingStarted.cpp.
◆ operator*()
|
inline |
Gets the value contained in the Value instance.
If there is no valid value, then an exception will be thrown. To prevent an exception, the hasValue() method should be checked first.
- Returns
- value
◆ setNoValueReason()
|
inline |
Set the reason there is no value available.
This will be used if an exception is thrown by the setValue method.
- Parameters
-
reason the reason enum indicating why the value is missing message the message containing a fuller description on why the value is missing
◆ setValue()
|
inline |
Set the value to be contained in the Value instance.
- Parameters
-
targetValue the value to set
The documentation for this class was generated from the following file:
