DART
6.7.3
|
Retrieve local resources from sample data files given file URI. More...
#include <DartResourceRetriever.hpp>
Public Member Functions | |
DartResourceRetriever () | |
Constructor. More... | |
~DartResourceRetriever () override=default | |
Destructor. More... | |
bool | exists (const common::Uri &uri) override |
Returns whether the resource specified by a URI exists. More... | |
common::ResourcePtr | retrieve (const common::Uri &uri) override |
Returns the resource specified by a URI or nullptr on failure. More... | |
std::string | getFilePath (const common::Uri &uri) override |
Returns absolute file path to uri ; an empty string if unavailable. More... | |
virtual std::string | readAll (const Uri &uri) |
Reads all data from the resource of uri, and returns it as a string. More... | |
Static Public Member Functions | |
template<typename... Args> | |
static std::shared_ptr< DartResourceRetriever > | create (Args &&... args) |
Private Member Functions | |
void | addDataDirectory (const std::string &packageDirectory) |
bool | resolveDataUri (const common::Uri &uri, std::string &relativePath) const |
Private Attributes | |
common::ResourceRetrieverPtr | mLocalRetriever |
std::vector< std::string > | mDataDirectories |
Retrieve local resources from sample data files given file URI.
The scheme and authority should be "file" and "sample", respectively.
Example of a sample data URI:
DartResourceRetriever searches files in the following order: 1) Preprocessor, DART_DATA_LOCAL_PATH: Path to the data directory in the source directory (e.g., [DART_SRC_ROOT]/data/). 2) Preprocessor, DART_DATA_GLOBAL_PATH: Path to the data directory installed in a system directory. The location can be varied depending on OS (e.g., Linux: /usr/local/share/doc/dart/data/). 3) environment variable, DART_DATA_PATH: Path to the data directory specified by the user.
dart::utils::DartResourceRetriever::DartResourceRetriever | ( | ) |
Constructor.
|
overridedefault |
Destructor.
|
private |
|
inlinestatic |
|
overridevirtual |
Returns whether the resource specified by a URI exists.
Implements dart::common::ResourceRetriever.
|
overridevirtual |
Returns absolute file path to uri
; an empty string if unavailable.
This base class returns an empty string by default.
Reimplemented from dart::common::ResourceRetriever.
|
virtualinherited |
Reads all data from the resource of uri, and returns it as a string.
[in] | uri | URI to the resource to be retrieved. |
std::runtime_error | when failed to read sucessfully. |
|
private |
|
overridevirtual |
Returns the resource specified by a URI or nullptr on failure.
Implements dart::common::ResourceRetriever.
|
private |
|
private |