Ocean
Ocean::IO::Path Class Referenceabstract

This class holds a path. More...

Inheritance diagram for Ocean::IO::Path:

Public Types

enum  Type {
  TYPE_INVALID = 0 , TYPE_FILE = 1 , TYPE_DIRECTORY = 2 , TYPE_ABSOLUTE = 4 ,
  TYPE_RELATIVE = 8 , TYPE_NETWORK = 16
}
 Definition of different path types. More...
 
enum  Separator { SEPARATOR_UNDEFINED = 0 , SEPARATOR_SLASH = '/' , SEPARATOR_BACKSLASH = '\\' }
 Definition of path separators. More...
 

Public Member Functions

virtual ~Path ()=default
 Destructs a path. More...
 
Type type () const
 Returns the type of this path. More...
 
bool isAbsolute () const
 Returns whether this path is absolute. More...
 
bool isRelative () const
 Returns whether this path is relative. More...
 
virtual bool isValid () const =0
 Returns whether the path is valid. More...
 
bool isNull () const
 Returns whether this path holds no valid. More...
 
virtual bool exists () const =0
 Returns whether the path exists already. More...
 
bool operator== (const Path &right) const
 Returns whether two paths are equal. More...
 
bool operator!= (const Path &path) const
 Returns whether two paths are not equal. More...
 
const std::string & operator() () const
 Returns the value of this path. More...
 
bool operator< (const Path &path) const
 Less operator comparing the actual strings of two paths. More...
 

Static Public Member Functions

static bool isSeparator (const char character)
 Returns whether a given character is a separator. More...
 
static char defaultSeparator ()
 Returns the default separator of a path. More...
 

Protected Member Functions

 Path ()=default
 Creates a new undefined path. More...
 
 Path (const Path &path)=default
 Copy constructor. More...
 
 Path (const std::string &value)
 Creates a new path. More...
 
void checkPath (const Type expectType)
 Checks the type of this path and trims it. More...
 
void trim ()
 Trims this path. More...
 
Pathoperator= (const Path &path)=default
 Default assign operator. More...
 

Protected Attributes

Type pathType_ = TYPE_INVALID
 Path type. More...
 
std::string pathValue_
 Path value. More...
 

Detailed Description

This class holds a path.

A path is the base for a file or a directory.
Each path can be absolute or relative.
Files do not end with a separator, directories must end with a separator.

Member Enumeration Documentation

◆ Separator

Definition of path separators.

Enumerator
SEPARATOR_UNDEFINED 

Undefined separator.

SEPARATOR_SLASH 

Slash as separator.

SEPARATOR_BACKSLASH 

Backslash as separator.

◆ Type

Definition of different path types.

Enumerator
TYPE_INVALID 

Invalid path type.

TYPE_FILE 

File path.

TYPE_DIRECTORY 

Directory path.

TYPE_ABSOLUTE 

Absolute path.

TYPE_RELATIVE 

Relative path.

TYPE_NETWORK 

Network path.

Constructor & Destructor Documentation

◆ ~Path()

virtual Ocean::IO::Path::~Path ( )
virtualdefault

Destructs a path.

◆ Path() [1/3]

Ocean::IO::Path::Path ( )
protecteddefault

Creates a new undefined path.

◆ Path() [2/3]

Ocean::IO::Path::Path ( const Path path)
protecteddefault

Copy constructor.

Parameters
pathThe path to copy

◆ Path() [3/3]

Ocean::IO::Path::Path ( const std::string &  value)
explicitprotected

Creates a new path.

Parameters
valuePath value

Member Function Documentation

◆ checkPath()

void Ocean::IO::Path::checkPath ( const Type  expectType)
protected

Checks the type of this path and trims it.

Parameters
expectTypeExpected path type

◆ defaultSeparator()

static char Ocean::IO::Path::defaultSeparator ( )
static

Returns the default separator of a path.

Returns
The default separator for the current platform

◆ exists()

virtual bool Ocean::IO::Path::exists ( ) const
pure virtual

Returns whether the path exists already.

Returns
True, if so

Implemented in Ocean::IO::File, and Ocean::IO::Directory.

◆ isAbsolute()

bool Ocean::IO::Path::isAbsolute ( ) const
inline

Returns whether this path is absolute.

If the path is invalid the result is False.

Returns
True, if so

◆ isNull()

bool Ocean::IO::Path::isNull ( ) const
inline

Returns whether this path holds no valid.

Returns
True, if so

◆ isRelative()

bool Ocean::IO::Path::isRelative ( ) const
inline

Returns whether this path is relative.

If the path is invalid the result is False.

Returns
True, if so

◆ isSeparator()

static bool Ocean::IO::Path::isSeparator ( const char  character)
static

Returns whether a given character is a separator.

Parameters
characterCharacter to check for a separator
Returns
True, if so

◆ isValid()

virtual bool Ocean::IO::Path::isValid ( ) const
pure virtual

Returns whether the path is valid.

Returns
True, if so

Implemented in Ocean::IO::File, and Ocean::IO::Directory.

◆ operator!=()

bool Ocean::IO::Path::operator!= ( const Path path) const
inline

Returns whether two paths are not equal.

Parameters
pathRight path to compare
Returns
True, if so

◆ operator()()

const std::string & Ocean::IO::Path::operator() ( ) const
inline

Returns the value of this path.

Returns
Path value

◆ operator<()

bool Ocean::IO::Path::operator< ( const Path path) const
inline

Less operator comparing the actual strings of two paths.

Parameters
pathThe second path to compare

◆ operator=()

Path& Ocean::IO::Path::operator= ( const Path path)
protecteddefault

Default assign operator.

Parameters
pathThe path to assign

◆ operator==()

bool Ocean::IO::Path::operator== ( const Path right) const

Returns whether two paths are equal.

Parameters
rightRight path to compare
Returns
True, if so

◆ trim()

void Ocean::IO::Path::trim ( )
protected

Trims this path.

◆ type()

Path::Type Ocean::IO::Path::type ( ) const
inline

Returns the type of this path.

Returns
Path type.

Field Documentation

◆ pathType_

Type Ocean::IO::Path::pathType_ = TYPE_INVALID
protected

Path type.

◆ pathValue_

std::string Ocean::IO::Path::pathValue_
protected

Path value.


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