Remoto - VFS: VFS_node_type Class Reference
Remoto - VFS

The type registry for file extensions. More...

#include <VFS_node_type.h>

Static Public Member Functions

static QString getType (QString _path, QString _default="unknownType")
 Fetch the type of a file, based on path/filename.ext. More...
 
static QMap< QString, bool > initJsons ()
 Initialize the jsons library. More...
 
static QMap< QString, QString > initTypes ()
 Initialize the type library. More...
 
static bool isJsonType (QString _type)
 Check if a type is known to be json. More...
 
static bool registerType (QString type, QString handler, bool json=true)
 Add a type to the registry. More...
 
static bool unregisterType (QString type)
 Remove a type from the registry. More...
 

Static Private Attributes

static QMap< QString, bool > jsonMap = VFS_node_type::initJsons()
 The extension:isjson map. More...
 
static QMap< QString, QString > typeMap = VFS_node_type::initTypes()
 The extension:type map. More...
 

Detailed Description

The type registry for file extensions.

Because a traditional filesystem doesn't usually have a concept of metadata, some form of type detection must occur to display in a user interface. This is generally only for use with nodes like VFS_HD.

Basic types are provided and mapped to gui types, however this list is not extensive. Types can be added using the registerType() function. Duplicate types are an error.

Warning
This method of type detection may become deprecated, as generally files will be loaded by a handler plugin, and the plugin can do its detection there. Depending on the number of plugins, type collisions are going to happen at some point, and the goal is to create a system where all plugins can be loaded simultaneously.
Note
There may come a time where certain common types, like .jpg or .txt will be handled by a user-defined application or interface, in which case a default will be provded and the user can choose another option if available.

Definition at line 8 of file VFS_node_type.h.

Member Function Documentation

◆ getType()

QString VFS_node_type::getType ( QString  _path,
QString  _default = "unknownType" 
)
static

Fetch the type of a file, based on path/filename.ext.

Parameters
_pathThe path to examine
_defaultA default type to return if the type cannot be determined.
Returns
The type

This will parse the incoming path and search for a matching file extension.

Definition at line 99 of file VFS_node_type.cpp.

◆ initJsons()

QMap< QString, bool > VFS_node_type::initJsons ( )
static

Initialize the jsons library.

Returns
The jsons array

This is used when the executable starts, and populates the static private typeMap.

Warning
The json-ness of a type is recorded now but will be deprecated. The developer is responsible for knowing if the contents of a file can be parsed as json.

Definition at line 73 of file VFS_node_type.cpp.

◆ initTypes()

QMap< QString, QString > VFS_node_type::initTypes ( )
static

Initialize the type library.

Returns
The type array

This is used when the executable starts, and populates the static private typeMap.

Definition at line 34 of file VFS_node_type.cpp.

◆ isJsonType()

bool VFS_node_type::isJsonType ( QString  _type)
static

Check if a type is known to be json.

Parameters
_typeThe path to examine.
Returns
The result of searching the json map for an entry.

Definition at line 122 of file VFS_node_type.cpp.

◆ registerType()

bool VFS_node_type::registerType ( QString  type,
QString  handler,
bool  json = true 
)
static

Add a type to the registry.

Parameters
typeThe type to add.
handlerA handler type, probably in the code form: nodename:libname
jsonThe json-ness of the type
Returns
Success or failure, depending on if the type could be registered.
See also
VFS_creator::code
VFS_node_interface::code
VFS_node::code

Definition at line 139 of file VFS_node_type.cpp.

◆ unregisterType()

bool VFS_node_type::unregisterType ( QString  type)
static

Remove a type from the registry.

Parameters
typeThe type to remove
Returns
Success or failure to remove the type

Definition at line 156 of file VFS_node_type.cpp.

Member Data Documentation

◆ jsonMap

QMap< QString, bool > VFS_node_type::jsonMap = VFS_node_type::initJsons()
staticprivate

The extension:isjson map.

Definition at line 22 of file VFS_node_type.h.

◆ typeMap

QMap< QString, QString > VFS_node_type::typeMap = VFS_node_type::initTypes()
staticprivate

The extension:type map.

Definition at line 21 of file VFS_node_type.h.


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