VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Types | 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 Types

using Extras = map< string, string, std::less<> >
 

Public Member Functions

 FileSpec (string filehandler, const vector< string > &chunksIn)
 
 FileSpec (string filehandler, const vector< string > &&chunksIn)
 
 FileSpec (const vector< string > &chunksIn)
 
 FileSpec (vector< string > &&chunksIn)
 
void clear ()
 clear all the fields.
 
bool empty () const
 
bool isDiskFile () const
 
int fromPathJsonUri (string_view pathJsonUri, string_view defaultFileHandlerName={})
 
string toPathJsonUri () const
 Reverse operation as fromPathJsonUri, as possible.
 
bool fromJson (string_view 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 (string_view name) const
 Get an extra parameter, or the empty string.
 
bool getExtra (string_view name, string &outValue) const
 Get an extra parameter value, and know if a match was found.
 
bool hasExtra (string_view name) const
 Tell if an extra parameter is defined.
 
int getExtraAsInt (string_view name, int defaultValue=0) const
 
int64_t getExtraAsInt64 (string_view name, int64_t defaultValue=0) const
 
uint64_t getExtraAsUInt64 (string_view name, uint64_t defaultValue=0) const
 
double getExtraAsDouble (string_view name, double defaultValue=0) const
 
bool getExtraAsBool (string_view name, bool defaultValue=false) const
 
void setExtra (string_view name, string_view value)
 
void setExtra (string_view name, const char *value)
 
void setExtra (string_view name, bool value)
 
void setExtra (string_view name, const string &value)
 
template<typename T >
void setExtra (string_view name, T value)
 
void unsetExtra (string_view name)
 Unset an extra parameter.
 

Static Public Member Functions

static int parseUri (string_view uri, string &outScheme, string &outPath, Extras &outQueryParams)
 
static int decodeQuery (string_view query, string &outKey, string &outValue)
 
static int urldecode (string_view in, string &out)
 

Public Attributes

string fileHandlerName
 
string fileName
 
string uri
 
vector< string > chunks
 
vector< int64_t > chunkSizes
 
Extras 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 Typedef Documentation

◆ Extras

using vrs::FileSpec::Extras = map<string, string, std::less<> >

Map type with heterogeneous lookup support for string keys. Allows lookup using string_view without creating temporary string objects.

Member Function Documentation

◆ fromPathJsonUri()

int vrs::FileSpec::fromPathJsonUri ( string_view  pathJsonUri,
string_view  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 ( string_view  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 ( string_view  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 ( string_view  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 ( string_view  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 ( string_view  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: