VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
vrs::FileSpec Struct Reference

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.
 

Static Public Member Functions

static int parseUri (const string &uri, string &outScheme, string &outPath, map< string, string > &outQueryParams)
 
static int decodeQuery (const string &query, string &outKey, string &outValue)
 
static int urldecode (const string &in, string &out)
 

Public Attributes

string fileHandlerName
 
string fileName
 
string uri
 
vector< string > chunks
 
vector< int64_t > chunkSizes
 
map< string, string > extras
 

Detailed Description

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.

Member Function Documentation

◆ fromPathJsonUri()

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.

Parameters
pathJsonUria path, a json spec, or a URI
defaultFileHandlerNameprovide a default FileHandler name. DiskFile by default.
Returns
A status code, 0 meaning apparent success. Note that the validation is superficial, a file might not exists, the requested filehandler may not be available, etc.

◆ getExtraAsBool()

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.

◆ getExtraAsDouble()

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.

◆ getExtraAsInt()

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.

◆ getExtraAsInt64()

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.

◆ getExtraAsUInt64()

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.


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