Nebula
Loading...
Searching...
No Matches
IO::Path Class Reference

#include <path.h>

Detailed Description

A path is an abstraction around file paths.

It encapsulates the folder path, an optional file name and accompanying file type.

A path lives entirely within Nebulas file system, meaning all paths are relative to content folders, either in 'work' or 'export'.

Public Types

enum  FileTypes { Texture , Model , Material , Mesh }

Public Member Functions

 Path ()
 Constructor.
 ~Path ()
 Destructor.
 Path (const Path &path)
 Copy constructor.
void Clear ()
 Clear the path.
bool IsEmpty () const
 Returns true if path is empty.
bool IsFolder () const
 Returns true if the path is a folder.
bool IsFile () const
 Returns true if the path is a file.
const Util::String AsString () const
 Serialize to string.
bool operator== (const Path &path) const
 Comparison test.
bool operator< (const Path &path) const
 Less test.
bool operator> (const Path &path) const
 Greater test.
Path operator/ (const char *folder) const
 Append to folder path.
Path operator/ (const Util::String &folder) const
 Append to folder path.
Path operator/ (const Path &folder) const
 Append to folder path.
IO::URI WorkURI (const char *workFolder) const
 Convert to a URI seated in the provided folder.
IO::URI WorkURI (const Util::String &workFolder) const
 Convert to a URI seated in the provided folder.
IO::URI ExportURI () const
 Convert to a folder in 'export'.
void SetFolder (const Util::String &folder)
 Set the folder.
void ClearFolder ()
 Clear the folder.
void SetFile (const Util::String &file, const Util::String &type)
 Set the file.
void ClearFile ()
 Clear the file.
const Util::String & GetFolderAndFile () const
 Get folder and file path.
const Util::String & GetFile () const
 Get file.
const Util::String & GetFolder () const
 Get folder.
const Util::String & GetType () const
 Get type.
Util::String GetWorkFile () const
 Get file with work extension.
Util::String GetExportFile () const
 Get file with export extension.

Static Public Member Functions

static Path Parse (const Util::String &serialized)
 Parse from serialized Path.
static Path Folder (const Util::String &folder)
 Construct from folder.
static Path FolderAndFile (const Util::String &type, const Util::String &folderAndFile)
 Construct from file type, combined folder and file path.
static Path FolderAndFile (const char *type, const Util::String &folderAndFile)
 Construct from file type, combined folder and file path.
static Path File (const Util::String &folder, const Util::String &file, const Util::String &type)
 Construct from folder, file and type separately.
static Path File (const Util::String &folder, const Util::String &file, const char *type)
 Construct from folder, file and type separately.
static void AddExportMapping (const Util::StringAtom &ns, const Util::StringAtom &extension)
 Add an export binding using namespace -> file extension to use with ExportURI. Adding the same binding again is allowed, binding a namespace to another extension is not.
static void AddWorkMapping (const Util::StringAtom &ns, const Util::StringAtom &extension)
 Add a work binding using namespace -> file extension to use with WorkURI. Adding the same binding again is allowed, binding a namespace to another extension is not.
static void SetWorkRoot (const Util::StringAtom &root)
 Set the work folder.

Static Public Attributes

static Util::Dictionary< Util::StringAtom, Util::StringAtom > ExportExtensions
static Util::Dictionary< Util::StringAtom, Util::StringAtom > WorkExtensions
static Util::StringAtom WorkRoot

Private Member Functions

void Build ()
 Build fileAndFolder.

Private Attributes

bool isFile
Util::String folder
Util::String file
Util::String type
Util::String folderAndFile

Member Enumeration Documentation

◆ FileTypes

Enumerator
Texture 
Model 
Material 
Mesh 

Constructor & Destructor Documentation

◆ Path() [1/2]

IO::Path::Path ( )

Constructor.

◆ ~Path()

IO::Path::~Path ( )

Destructor.

◆ Path() [2/2]

IO::Path::Path ( const Path & path)

Copy constructor.

Member Function Documentation

◆ AddExportMapping()

void IO::Path::AddExportMapping ( const Util::StringAtom & ns,
const Util::StringAtom & extension )
inlinestatic

Add an export binding using namespace -> file extension to use with ExportURI. Adding the same binding again is allowed, binding a namespace to another extension is not.

Several systems read the same namespace, such as graphics and physics both reading meshes, and each registers the mappings it needs regardless of setup order.

They have to agree though.

◆ AddWorkMapping()

void IO::Path::AddWorkMapping ( const Util::StringAtom & ns,
const Util::StringAtom & extension )
inlinestatic

Add a work binding using namespace -> file extension to use with WorkURI. Adding the same binding again is allowed, binding a namespace to another extension is not.

Several systems read the same namespace and each registers the mappings it needs regardless of setup order.

They have to agree though.

◆ AsString()

const Util::String IO::Path::AsString ( ) const

Serialize to string.

◆ Build()

void IO::Path::Build ( )
private

Build fileAndFolder.

◆ Clear()

void IO::Path::Clear ( )

Clear the path.

◆ ClearFile()

void IO::Path::ClearFile ( )

Clear the file.

◆ ClearFolder()

void IO::Path::ClearFolder ( )

Clear the folder.

◆ ExportURI()

URI IO::Path::ExportURI ( ) const

Convert to a folder in 'export'.

◆ File() [1/2]

Path IO::Path::File ( const Util::String & folder,
const Util::String & file,
const char * type )
static

Construct from folder, file and type separately.

◆ File() [2/2]

Path IO::Path::File ( const Util::String & folder,
const Util::String & file,
const Util::String & type )
static

Construct from folder, file and type separately.

◆ Folder()

Path IO::Path::Folder ( const Util::String & folder)
static

Construct from folder.

◆ FolderAndFile() [1/2]

Path IO::Path::FolderAndFile ( const char * type,
const Util::String & folderAndFile )
static

Construct from file type, combined folder and file path.

◆ FolderAndFile() [2/2]

Path IO::Path::FolderAndFile ( const Util::String & type,
const Util::String & folderAndFile )
static

Construct from file type, combined folder and file path.

◆ GetExportFile()

Util::String IO::Path::GetExportFile ( ) const

Get file with export extension.

◆ GetFile()

const Util::String & IO::Path::GetFile ( ) const

Get file.

◆ GetFolder()

const Util::String & IO::Path::GetFolder ( ) const

Get folder.

◆ GetFolderAndFile()

const Util::String & IO::Path::GetFolderAndFile ( ) const

Get folder and file path.

◆ GetType()

const Util::String & IO::Path::GetType ( ) const

Get type.

◆ GetWorkFile()

Util::String IO::Path::GetWorkFile ( ) const

Get file with work extension.

◆ IsEmpty()

bool IO::Path::IsEmpty ( ) const

Returns true if path is empty.

◆ IsFile()

bool IO::Path::IsFile ( ) const

Returns true if the path is a file.

◆ IsFolder()

bool IO::Path::IsFolder ( ) const

Returns true if the path is a folder.

◆ operator/() [1/3]

Path IO::Path::operator/ ( const char * folder) const

Append to folder path.

◆ operator/() [2/3]

Path IO::Path::operator/ ( const Path & folder) const

Append to folder path.

◆ operator/() [3/3]

Path IO::Path::operator/ ( const Util::String & folder) const

Append to folder path.

◆ operator<()

bool IO::Path::operator< ( const Path & path) const

Less test.

◆ operator==()

bool IO::Path::operator== ( const Path & path) const

Comparison test.

◆ operator>()

bool IO::Path::operator> ( const Path & path) const

Greater test.

◆ Parse()

Path IO::Path::Parse ( const Util::String & serialized)
static

Parse from serialized Path.

◆ SetFile()

void IO::Path::SetFile ( const Util::String & file,
const Util::String & type )

Set the file.

◆ SetFolder()

void IO::Path::SetFolder ( const Util::String & folder)

Set the folder.

◆ SetWorkRoot()

void IO::Path::SetWorkRoot ( const Util::StringAtom & root)
inlinestatic

Set the work folder.

◆ WorkURI() [1/2]

URI IO::Path::WorkURI ( const char * workFolder) const

Convert to a URI seated in the provided folder.

◆ WorkURI() [2/2]

URI IO::Path::WorkURI ( const Util::String & workFolder) const

Convert to a URI seated in the provided folder.

Member Data Documentation

◆ ExportExtensions

Util::Dictionary< Util::StringAtom, Util::StringAtom > IO::Path::ExportExtensions
static

◆ file

Util::String IO::Path::file
private

◆ folder

Util::String IO::Path::folder
private

◆ folderAndFile

Util::String IO::Path::folderAndFile
private

◆ isFile

bool IO::Path::isFile
private

◆ type

Util::String IO::Path::type
private

◆ WorkExtensions

Util::Dictionary< Util::StringAtom, Util::StringAtom > IO::Path::WorkExtensions
static

◆ WorkRoot

Util::StringAtom IO::Path::WorkRoot
static

The documentation for this class was generated from the following files:
  • /github/workspace/code/foundation/io/path.h
  • /github/workspace/code/foundation/io/path.cc