Drake
FindResourceResult Class Reference

Models the outcome of drake::FindResource. More...

#include <drake/common/find_resource.h>

Public Member Functions

optional< std::string > get_absolute_path () const
 Returns the absolute path to the resource, iff the resource was found. More...
 
std::string get_absolute_path_or_throw () const
 Either returns the get_absolute_path() iff the resource was found, or else throws runtime_error. More...
 
optional< std::string > get_error_message () const
 Returns the error message, iff the resource was not found. More...
 
std::string get_resource_path () const
 Returns the resource_path asked of FindResource. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 FindResourceResult (const FindResourceResult &)=default
 
FindResourceResultoperator= (const FindResourceResult &)=default
 
 FindResourceResult (FindResourceResult &&)=default
 
FindResourceResultoperator= (FindResourceResult &&)=default
 

Static Public Member Functions

static FindResourceResult make_success (std::string resource_path, std::string absolute_path)
 Returns a success result (the requested resource was found). More...
 
static FindResourceResult make_error (std::string resource_path, std::string error_message)
 Returns an error result (the requested resource was NOT found). More...
 
static FindResourceResult make_empty ()
 Returns an empty error result (no requested resource). More...
 

Detailed Description

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.)

Constructor & Destructor Documentation

FindResourceResult ( const FindResourceResult )
default

Member Function Documentation

optional< string > get_absolute_path ( ) const

Returns the absolute path to the resource, iff the resource was found.

Here is the caller graph for this function:

string get_absolute_path_or_throw ( ) const

Either returns the get_absolute_path() iff the resource was found, or else throws runtime_error.

Here is the call graph for this function:

Here is the caller graph for this function:

optional< 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.

Here is the caller graph for this function:

string get_resource_path ( ) const

Returns the resource_path asked of FindResource.

(This may be empty only in the make_empty() case.)

Result make_empty ( )
static

Returns an empty error result (no requested resource).

Result make_error ( std::string  resource_path,
std::string  error_message 
)
static

Returns an error result (the requested resource was NOT found).

Precondition
neither string parameter is empty
Parameters
resource_paththe value passed to FindResource

Here is the caller graph for this function:

Result make_success ( std::string  resource_path,
std::string  absolute_path 
)
static

Returns a success result (the requested resource was found).

Precondition
neither string parameter is empty
Parameters
resource_paththe value passed to FindResource
base_pathan absolute base path that precedes resource_path

Here is the caller graph for this function:

FindResourceResult& operator= ( FindResourceResult &&  )
default
FindResourceResult& operator= ( const FindResourceResult )
default

The documentation for this class was generated from the following files: