![]() |
VRS
A file format for sensor data.
|
Generalized file descriptor class, allowing the efficient representation of complex file objects, maybe multi-chunks, with additional optional properties. More...
#include <FileSpec.h>
Public Member Functions | |
FileSpec (string filehandler, const vector< string > &chunks) | |
FileSpec (string filehandler, const vector< string > &&chunks) | |
FileSpec (const vector< string > &chunks) | |
FileSpec (vector< string > &&chunks) | |
void | clear () |
clear all the fields. | |
bool | empty () const |
bool | isDiskFile () const |
int | fromPathJsonUri (const string &pathJsonUri, const string &defaultFileHandlerName={}) |
string | toPathJsonUri () const |
Reverse operation as fromPathJsonUri, as possible. | |
bool | fromJson (const string &jsonStr) |
string | toJson () const |
int | parseUri () |
Parse the uri field already set, overwriting other fields on success. | |
bool | hasChunkSizes () const |
Tell if we have chunks and all of them has a file size. | |
int64_t | getFileSize () const |
Get the total size of the object, or -1 if don't know. | |
string | getSourceLocation () const |
Get the location of the object, which is the uri (if any), or the file handler. | |
string | getEasyPath () const |
Logical reverse operation from fromPathJsonUri, but kept minimal for logging. | |
string | getFileName () const |
Get filename, if possible. | |
string | getXXHash () const |
Get signature of the path. | |
bool | operator== (const FileSpec &rhs) const |
Test equality (for testing) | |
const string & | getExtra (const string &name) const |
Get an extra parameter, or the empty string. | |
const string & | getExtra (const string &name, const string &defaultValue) const |
Get an extra parameter, or the empty string. | |
bool | hasExtra (const string &name) const |
Tell if an extra parameter is defined. | |
int | getExtraAsInt (const string &name, int defaultValue=0) const |
int64_t | getExtraAsInt64 (const string &name, int64_t defaultValue=0) const |
uint64_t | getExtraAsUInt64 (const string &name, uint64_t defaultValue=0) const |
double | getExtraAsDouble (const string &name, double defaultValue=0) const |
bool | getExtraAsBool (const string &name, bool defaultValue=false) const |
void | setExtra (const string &name, const string &value) |
void | setExtra (const string &name, const char *value) |
void | setExtra (const string &name, bool value) |
template<typename T > | |
void | setExtra (const string &name, T value) |
void | unsetExtra (const string &name) |
Unset an extra parameter. | |
Public Attributes | |
string | fileHandlerName |
string | fileName |
string | uri |
vector< string > | chunks |
vector< int64_t > | chunkSizes |
map< string, string > | extras |
Generalized file descriptor class, allowing the efficient representation of complex file objects, maybe multi-chunks, with additional optional properties.
File specification struct, to describe a file object in more details than just a single path, possibly with multiple chunks, with a special file handler, an explicit file name (useful when the chunks are urls), and possibly a source uri. If no file handler name is specified, the object is assumed to a set of local files. Additional properties may be specified in the extras field, which has helper methods.
int vrs::FileSpec::fromPathJsonUri | ( | const string & | pathJsonUri, |
const string & | defaultFileHandlerName = {} |
||
) |
Smart setter that will parse the string given, determining if the string passed is a local file path, a uri, or a json path.
pathJsonUri | a path, a json spec, or a URI |
defaultFileHandlerName | provide a default FileHandler name. DiskFile by default. |
bool vrs::FileSpec::getExtraAsBool | ( | const string & | name, |
bool | defaultValue = false |
||
) | const |
Get an extra parameter interpreted as a bool, or a default value if not available. The value is evaluated to be true if it is either "1" or "true", o/w this returns false.
double vrs::FileSpec::getExtraAsDouble | ( | const string & | name, |
double | defaultValue = 0 |
||
) | const |
Get an extra parameter interpreted as a double, or a default value if not available, or in case of type conversion error.
int vrs::FileSpec::getExtraAsInt | ( | const string & | name, |
int | defaultValue = 0 |
||
) | const |
Get an extra parameter interpreted as an int, or a default value if not available, or in case of type conversion error.
int64_t vrs::FileSpec::getExtraAsInt64 | ( | const string & | name, |
int64_t | defaultValue = 0 |
||
) | const |
Get an extra parameter interpreted as an int64, or a default value if not available, or in case of type conversion error.
uint64_t vrs::FileSpec::getExtraAsUInt64 | ( | const string & | name, |
uint64_t | defaultValue = 0 |
||
) | const |
Get an extra parameter interpreted as an uint64, or a default value if not available, or in case of type conversion error.