Devel Lib
Devel::IO::CPath Class Reference

A class that encapsulates the functionality of std::filesystem::path. More...

#include <Path.h>

Public Member Functions

 CPath ()=default
 Default constructor.
 
 CPath (fs::path i_oPath)
 Construct from a std::filesystem::path. More...
 
 CPath (const CPath &i_oPath)
 Copy constructor. More...
 
 CPath (CPath &&i_oPath) noexcept
 Move constructor. More...
 
void setPath (fs::path i_oPath)
 Sets the path. More...
 
fs::path replaceFilename (const fs::path &i_oFilename)
 Replaces the filename in the path. More...
 
fs::path replaceExtension (const fs::path &i_oExtension)
 Replaces the extension in the path. More...
 
fs::path getRootName () const
 Returns the root name of the path. More...
 
fs::path getRootPath () const
 Returns the root directory of the path. More...
 
fs::path getRelativePath () const
 Returns the relative path. More...
 
fs::path getParentPath () const
 Returns the parent path. More...
 
fs::path getFileNameWithoutExtension () const
 Returns the filename without extension. More...
 
fs::path getFileExtension () const
 Returns the file extension. More...
 
fs::path getAbsolutePath () const
 Returns the absolute path. More...
 
fs::path removeFilename ()
 Removes the filename from the path. More...
 
const fs::path & getPath () const
 Returns the encapsulated fs::path object. More...
 
std::string toStdString () const
 Converts the path to a standard string. More...
 
std::wstring toStdWString () const
 Converts the path to a standard wide string. More...
 
bool hasRootName () const
 Checks if the path has a root name. More...
 
bool hasRootDirectory () const
 Checks if the path has a root directory. More...
 
bool hasRelativePath () const
 Checks if the path has a relative path. More...
 
bool hasParentPath () const
 Checks if the path has a parent path. More...
 
bool hasFilename () const
 Checks if the path has a filename. More...
 
bool hasFileNameWithoutExtension () const
 Checks if the path has a filename without extension. More...
 
bool hasExtension () const
 Checks if the path has an extension. More...
 
bool isAbsolutePath () const
 Checks if the path is absolute. More...
 
bool isRelativePath () const
 Checks if the path is relative. More...
 
auto begin ()
 Returns an iterator to the beginning of the path. More...
 
auto end ()
 Returns an iterator to the end of the path. More...
 
bool exists () const
 Checks whether the path exists. More...
 
CPathoperator= (fs::path i_oPath)
 Assigns a new path to the object. More...
 
CPathoperator= (const CPath &i_oPath)
 Assigns a new path to the object. More...
 
CPathoperator= (CPath &&i_oPath)
 Assigns a new path to the object. More...
 
CPathoperator+= (const fs::path &i_oPath)
 Appends a path to the current path. More...
 
CPathoperator+= (const CPath &i_oPath)
 Appends a path to the current path. More...
 

Static Public Member Functions

static bool exists (const fs::path &i_oPath)
 Checks whether a path exists. More...
 

Detailed Description

A class that encapsulates the functionality of std::filesystem::path.

This class provides an interface for manipulating and inspecting file paths.

Example

Devel::IO::CPath myPath("/home/user/myfile.txt");
fs::path parentPath = myPath.getParentPath();
std::cout << "Parent path: " << parentPath << std::endl;
fs::path withoutExt = myPath.getFileNameWithoutExtension();
std::cout << "File name without extension: " << withoutExt << std::endl;
A class that encapsulates the functionality of std::filesystem::path.
Definition: Path.h:28

Constructor & Destructor Documentation

◆ CPath() [1/3]

Devel::IO::CPath::CPath ( fs::path  i_oPath)
inlineexplicit

Construct from a std::filesystem::path.

Parameters
i_oPath- The path to encapsulate.

◆ CPath() [2/3]

Devel::IO::CPath::CPath ( const CPath i_oPath)
inline

Copy constructor.

Parameters
i_oPath- The path to copy.

◆ CPath() [3/3]

Devel::IO::CPath::CPath ( CPath &&  i_oPath)
inlinenoexcept

Move constructor.

Parameters
i_oPath- The path to move.

Member Function Documentation

◆ begin()

auto Devel::IO::CPath::begin ( )
inline

Returns an iterator to the beginning of the path.

Returns
An iterator to the beginning of the path.

◆ end()

auto Devel::IO::CPath::end ( )
inline

Returns an iterator to the end of the path.

Returns
An iterator to the end of the path.

◆ exists() [1/2]

bool Devel::IO::CPath::exists ( ) const
inline

Checks whether the path exists.

Returns
true if the path exists, false otherwise.

◆ exists() [2/2]

static bool Devel::IO::CPath::exists ( const fs::path &  i_oPath)
inlinestatic

Checks whether a path exists.

Parameters
i_oPath- The path to check.
Returns
true if the path exists, false otherwise.

◆ getAbsolutePath()

fs::path Devel::IO::CPath::getAbsolutePath ( ) const
inline

Returns the absolute path.

Returns
The absolute path as an fs::path object.

◆ getFileExtension()

fs::path Devel::IO::CPath::getFileExtension ( ) const
inline

Returns the file extension.

Returns
The file extension as an fs::path object.

◆ getFileNameWithoutExtension()

fs::path Devel::IO::CPath::getFileNameWithoutExtension ( ) const
inline

Returns the filename without extension.

Returns
The filename without extension as an fs::path object.

◆ getParentPath()

fs::path Devel::IO::CPath::getParentPath ( ) const
inline

Returns the parent path.

Returns
The parent path as an fs::path object.

◆ getPath()

const fs::path& Devel::IO::CPath::getPath ( ) const
inline

Returns the encapsulated fs::path object.

Returns
The encapsulated fs::path object.

◆ getRelativePath()

fs::path Devel::IO::CPath::getRelativePath ( ) const
inline

Returns the relative path.

Returns
The relative path as an fs::path object.

◆ getRootName()

fs::path Devel::IO::CPath::getRootName ( ) const
inline

Returns the root name of the path.

Returns
The root name as an fs::path object.

◆ getRootPath()

fs::path Devel::IO::CPath::getRootPath ( ) const
inline

Returns the root directory of the path.

Returns
The root directory as an fs::path object.

◆ hasExtension()

bool Devel::IO::CPath::hasExtension ( ) const
inline

Checks if the path has an extension.

Returns
true if the path has an extension, false otherwise.

◆ hasFilename()

bool Devel::IO::CPath::hasFilename ( ) const
inline

Checks if the path has a filename.

Returns
true if the path has a filename, false otherwise.

◆ hasFileNameWithoutExtension()

bool Devel::IO::CPath::hasFileNameWithoutExtension ( ) const
inline

Checks if the path has a filename without extension.

Returns
true if the path has a filename without extension, false otherwise.

◆ hasParentPath()

bool Devel::IO::CPath::hasParentPath ( ) const
inline

Checks if the path has a parent path.

Returns
true if the path has a parent path, false otherwise.

◆ hasRelativePath()

bool Devel::IO::CPath::hasRelativePath ( ) const
inline

Checks if the path has a relative path.

Returns
true if the path has a relative path, false otherwise.

◆ hasRootDirectory()

bool Devel::IO::CPath::hasRootDirectory ( ) const
inline

Checks if the path has a root directory.

Returns
true if the path has a root directory, false otherwise.

◆ hasRootName()

bool Devel::IO::CPath::hasRootName ( ) const
inline

Checks if the path has a root name.

Returns
true if the path has a root name, false otherwise.

◆ isAbsolutePath()

bool Devel::IO::CPath::isAbsolutePath ( ) const
inline

Checks if the path is absolute.

Returns
true if the path is absolute, false otherwise.

◆ isRelativePath()

bool Devel::IO::CPath::isRelativePath ( ) const
inline

Checks if the path is relative.

Returns
true if the path is relative, false otherwise.

◆ operator+=() [1/2]

CPath& Devel::IO::CPath::operator+= ( const CPath i_oPath)
inline

Appends a path to the current path.

Parameters
i_oPath- The path to append.
Returns
A reference to the object.

◆ operator+=() [2/2]

CPath& Devel::IO::CPath::operator+= ( const fs::path &  i_oPath)
inline

Appends a path to the current path.

Parameters
i_oPath- The path to append.
Returns
A reference to the object.

◆ operator=() [1/3]

CPath& Devel::IO::CPath::operator= ( const CPath i_oPath)
inline

Assigns a new path to the object.

Parameters
i_oPath- The new path.
Returns
A reference to the object.

◆ operator=() [2/3]

CPath& Devel::IO::CPath::operator= ( CPath &&  i_oPath)
inline

Assigns a new path to the object.

Parameters
i_oPath- The new path.
Returns
A reference to the object.

◆ operator=() [3/3]

CPath& Devel::IO::CPath::operator= ( fs::path  i_oPath)
inline

Assigns a new path to the object.

Parameters
i_oPath- The new path.
Returns
A reference to the object.

◆ removeFilename()

fs::path Devel::IO::CPath::removeFilename ( )
inline

Removes the filename from the path.

Returns
The path without the filename as an fs::path object.

◆ replaceExtension()

fs::path Devel::IO::CPath::replaceExtension ( const fs::path &  i_oExtension)
inline

Replaces the extension in the path.

Parameters
i_oExtension- The new extension.
Returns
The new path as an fs::path object.

◆ replaceFilename()

fs::path Devel::IO::CPath::replaceFilename ( const fs::path &  i_oFilename)
inline

Replaces the filename in the path.

Parameters
i_oFilename- The new filename.
Returns
The new path as an fs::path object.

◆ setPath()

void Devel::IO::CPath::setPath ( fs::path  i_oPath)
inline

Sets the path.

Parameters
i_oPath- The new path.

◆ toStdString()

std::string Devel::IO::CPath::toStdString ( ) const
inline

Converts the path to a standard string.

Returns
The path as a standard string.

◆ toStdWString()

std::wstring Devel::IO::CPath::toStdWString ( ) const
inline

Converts the path to a standard wide string.

Returns
The path as a standard wide string.

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