Qore FileLocationHandler Module Reference  1.0
FileLocationHandler::FileLocationHandler Class Reference

The main class. More...

Inheritance diagram for FileLocationHandler::FileLocationHandler:

Static Public Member Methods

static binary getBinaryFileFromLocation (string location)
 Returns binary data for the given file location. More...
 
static data getFileFromLocation (bool text, string location)
 Returns the file data from the given location. More...
 
static list< stringgetSupportedSchemes ()
 Retuns a list of supported schemes. More...
 
static string getTextFileFromLocation (string location)
 Returns string data for the given file location. More...
 
static bool isSchemeSupported (string scheme)
 Returns True if the scheme is supported. More...
 
static registerHandler (string scheme, code handler)
 Register a new location handler. More...
 

Static Private Member Methods

static string forceEncoding (string str, *string encoding)
 Returns a string tagged with the given encoding, if any.
 
static *hash< auto > getOptions (reference< string > location)
 Returns a hash option options from the location string.
 
static data getTextOrBin (data d, bool text, *string encoding)
 Helper method to eturn data in the expected format. More...
 
static Mutex handler_lock ()
 The location handler lock to ensure atomic operations.
 

Static Private Attributes

static hash< string, code > cache
 The location handler cache; scheme -> handler;. More...
 

Detailed Description

The main class.

Member Function Documentation

◆ getBinaryFileFromLocation()

static binary FileLocationHandler::FileLocationHandler::getBinaryFileFromLocation ( string  location)
static

Returns binary data for the given file location.

Parameters
locationthe location of the file data
Returns
the resource data as a binary value
Exceptions
LOCATION-ERRORthe location string cannotbe parsed; unknown location scheme; invalid location option

◆ getFileFromLocation()

static data FileLocationHandler::FileLocationHandler::getFileFromLocation ( bool  text,
string  location 
)
static

Returns the file data from the given location.

Parameters
texta flag if the data should be returned as text or not
locationthe location string
Exceptions
LOCATION-ERRORinvalid location or empty location string

◆ getSupportedSchemes()

static list<string> FileLocationHandler::FileLocationHandler::getSupportedSchemes ( )
static

Retuns a list of supported schemes.

Returns
a list of supported schemes

◆ getTextFileFromLocation()

static string FileLocationHandler::FileLocationHandler::getTextFileFromLocation ( string  location)
static

Returns string data for the given file location.

Parameters
locationthe location of the file data
Returns
the resource data as a string
Exceptions
LOCATION-ERRORthe location string cannotbe parsed; unknown location scheme; invalid location option

◆ getTextOrBin()

static data FileLocationHandler::FileLocationHandler::getTextOrBin ( data  d,
bool  text,
*string  encoding 
)
staticprivate

Helper method to eturn data in the expected format.

Parameters
dthe file data
texta flag if the data should be returned as a string or not
encodingany encoding for string data
Returns
the data in the required format with the expected encoding (if applicable)

◆ isSchemeSupported()

static bool FileLocationHandler::FileLocationHandler::isSchemeSupported ( string  scheme)
static

Returns True if the scheme is supported.

Parameters
schemethe scheme to check
Returns
True if the scheme is supported

◆ registerHandler()

static FileLocationHandler::FileLocationHandler::registerHandler ( string  scheme,
code  handler 
)
static

Register a new location handler.

Parameters
schemethe scheme for the location
handlerthe handler for the location, must have the signature:
data sub (string scheme, bool text, string location) {}
Exceptions
LOCATION-HANDLER-ERRORthe given location handler scheme has already been registered

Member Data Documentation

◆ cache

hash<string, code> FileLocationHandler::FileLocationHandler::cache
staticprivate

The location handler cache; scheme -> handler;.

Handlers have the signature:

data sub (string scheme, bool text, string location) {}