Models the outcome of drake::FindResource.
After a call to FindResource, typical calling code would use get_absolute_path_or_throw(). Alternatively, get_absolute_path() will return an optional<string>, which can be manually checked to contain a value before using the path. If the resource was not found, get_error_message() will contain an error message.
For a given FindResourceResult instance, exactly one of get_absolute_path() or get_error_message() will contain a value. (Similarly, exactly one of them will not contain a value.)
#include <drake/common/find_resource.h>
◆ FindResourceResult() [1/2]
| FindResourceResult |
( |
const FindResourceResult & | | ) |
|
|
default |
◆ FindResourceResult() [2/2]
| FindResourceResult |
( |
FindResourceResult && | | ) |
|
|
default |
◆ get_absolute_path()
| std::optional< std::string > get_absolute_path |
( |
| ) |
const |
Returns the absolute path to the resource, iff the resource was found.
◆ get_absolute_path_or_throw()
| std::string get_absolute_path_or_throw |
( |
| ) |
const |
Either returns the get_absolute_path() iff the resource was found, or else throws std::exception.
◆ get_error_message()
| std::optional< std::string > get_error_message |
( |
| ) |
const |
Returns the error message, iff the resource was not found.
The string will never be empty; only the optional can be empty.
◆ get_resource_path()
| std::string get_resource_path |
( |
| ) |
const |
Returns the resource_path asked of FindResource.
(This may be empty only in the make_empty() case.)
◆ make_empty()
Returns an empty error result (no requested resource).
◆ make_error()
Returns an error result (the requested resource was NOT found).
- Precondition
- neither string parameter is empty
- Parameters
-
| resource_path | the value passed to FindResource |
◆ make_success()
Returns a success result (the requested resource was found).
- Precondition
- neither string parameter is empty
- Parameters
-
| resource_path | the value passed to FindResource |
| absolute_path | an absolute base path that precedes resource_path |
◆ operator=() [1/2]
◆ operator=() [2/2]
The documentation for this class was generated from the following file: