LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::file::path Class Reference

#include <swoc_file.h>

Collaboration diagram for swoc::file::path:
Collaboration graph

Public Member Functions

 path ()=default
 Default construct empty path.
 
 path (const self_type &that)=default
 Copy constructor - copies the path.
 
 path (self_type &&that)=default
 Move constructor.
 
 path (const char *src)
 Construct from a null terminated string.
 
 path (std::string_view src)
 Construct from a string view.
 
 path (std::string const &p)
 Construct with a copy of p.
 
 path (std::string &&that)
 Move from an existing string.
 
self_typeoperator= (const self_type &that)=default
 Replace the path with a copy of that.
 
self_typeoperator= (self_type &&that)=default
 Replace the path with the contents of that.
 
self_typeoperator= (std::string_view p)
 Assign p as the path.
 
self_typeoperator= (std::string const &s)
 Assign s as the path.
 
self_typeoperator= (std::string &&s)
 Move s to be the path.
 
self_typeoperator= (char const *s)
 Copy s as the path.
 
self_typeoperator/= (const self_type &that)
 
self_typeoperator/= (std::string_view that)
 
bool empty () const
 Check if the path is empty.
 
bool is_absolute () const
 Check if the path is absolute.
 
bool is_relative () const
 Check if the path is not absolute.
 
self_type parent_path () const
 Path of the parent.
 
self_type relative_path () const
 
self_type filename () const
 
char const * c_str () const
 Access the path explicitly.
 
std::string const & string () const
 The path as a string.
 
self_typereserve (size_t n)
 
swoc::TextView view () const
 A view of the path.
 

Static Public Attributes

static constexpr char SEPARATOR = '/'
 Default path separator.
 

Protected Attributes

std::string _path
 File path.
 

Detailed Description

Utility class for file system paths.

Definition at line 93 of file swoc_file.h.

Constructor & Destructor Documentation

◆ path() [1/4]

swoc::file::path::path ( const char * src)
inlineexplicit

Construct from a null terminated string.

Definition at line 366 of file swoc_file.h.

◆ path() [2/4]

swoc::file::path::path ( std::string_view src)
inline

Construct from a string view.

Definition at line 368 of file swoc_file.h.

◆ path() [3/4]

swoc::file::path::path ( std::string const & p)
inline

Construct with a copy of p.

Definition at line 370 of file swoc_file.h.

◆ path() [4/4]

swoc::file::path::path ( std::string && that)
inline

Move from an existing string.

Definition at line 372 of file swoc_file.h.

Member Function Documentation

◆ c_str()

char const * swoc::file::path::c_str ( ) const
inline

Access the path explicitly.

Definition at line 399 of file swoc_file.h.

◆ empty()

bool swoc::file::path::empty ( ) const
inline

Check if the path is empty.

Definition at line 414 of file swoc_file.h.

◆ filename()

auto swoc::file::path::filename ( ) const

Filename part of the path.

Parameters
pPath.
Returns

Definition at line 38 of file swoc_file.cc.

◆ is_absolute()

bool swoc::file::path::is_absolute ( ) const
inline

Check if the path is absolute.

Definition at line 419 of file swoc_file.h.

◆ is_relative()

bool swoc::file::path::is_relative ( ) const
inline

Check if the path is not absolute.

Definition at line 424 of file swoc_file.h.

◆ operator/=() [1/2]

path & swoc::file::path::operator/= ( const self_type & that)
inline

Append or replace path with that.

If that is absolute, it replaces this. Otherwise that is appended with exactly one separator.

Parameters
thatFilesystem path.
Returns
this

Definition at line 429 of file swoc_file.h.

◆ operator/=() [2/2]

path & swoc::file::path::operator/= ( std::string_view that)

Append or replace path with that.

If that is absolute, it replaces this. Otherwise that is appended with exactly one separator.

Parameters
thatFilesystem path.
Returns
this

Definition at line 44 of file swoc_file.cc.

◆ operator=() [1/4]

path & swoc::file::path::operator= ( char const * s)
inline

Copy s as the path.

Definition at line 393 of file swoc_file.h.

◆ operator=() [2/4]

path & swoc::file::path::operator= ( std::string && s)
inline

Move s to be the path.

Definition at line 387 of file swoc_file.h.

◆ operator=() [3/4]

path & swoc::file::path::operator= ( std::string const & s)
inline

Assign s as the path.

Definition at line 381 of file swoc_file.h.

◆ operator=() [4/4]

path & swoc::file::path::operator= ( std::string_view p)
inline

Assign p as the path.

Definition at line 375 of file swoc_file.h.

◆ parent_path()

path swoc::file::path::parent_path ( ) const

Path of the parent.

Definition at line 23 of file swoc_file.cc.

◆ relative_path()

path swoc::file::path::relative_path ( ) const
Returns
Path excluding the root path, if nay.

Definition at line 30 of file swoc_file.cc.

◆ reserve()

auto swoc::file::path::reserve ( size_t n)
inline

Reserve space in the path.

Parameters
nNumber of bytes to reserve.
Returns
this.

Definition at line 479 of file swoc_file.h.

◆ string()

std::string const & swoc::file::path::string ( ) const
inline

The path as a string.

Definition at line 404 of file swoc_file.h.

◆ view()

swoc::TextView swoc::file::path::view ( ) const
inline

A view of the path.

Definition at line 409 of file swoc_file.h.

Member Data Documentation

◆ _path

std::string swoc::file::path::_path
protected

File path.

Definition at line 198 of file swoc_file.h.

◆ SEPARATOR

char swoc::file::path::SEPARATOR = '/'
staticconstexpr

Default path separator.

Definition at line 98 of file swoc_file.h.


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