PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::Filename Class Reference

#include <Puma/Filename.h>

+ Inheritance diagram for Puma::Filename:

Description

Abstraction of a filename using a smart pointer for automatic memory allocation / deallocation.

It encapsulates often needed operations like separating the path portion of the filename or the check whether the filename is absolute.

Public Member Functions

 Filename ()
 Constructor. More...
 
 Filename (const char *filename)
 Constructor. More...
 
Filenameoperator= (const char *filename)
 Assign a new filename. More...
 
bool operator~ () const
 Check if the filename is not NULL. More...
 
bool is_defined () const
 Check if the filename is not NULL. More...
 
void name (const char *filename)
 Set a new filename. More...
 
const char * name () const
 Get the filename. More...
 
const char * path ()
 Get the path portion of the filename. More...
 
const char * root ()
 Get the root of an absolute filename, i.e. More...
 
bool is_absolute () const
 Check whether the filename is absolute, i.e. More...
 
bool operator== (const Filename &filename) const
 Check if this filename equals the given. More...
 
bool operator!= (const Filename &filename) const
 Check if this filename not equals the given. More...
 
virtual void print (std::ostream &out) const
 Print this filename on the given output stream. More...
 
- Public Member Functions inherited from Puma::Printable
virtual ~Printable ()
 Destructor. More...
 
virtual void print (std::ostream &os) const =0
 Print object information on the given output stream. More...
 

Constructor & Destructor Documentation

◆ Filename() [1/2]

Puma::Filename::Filename ( )
inline

Constructor.

◆ Filename() [2/2]

Puma::Filename::Filename ( const char *  filename)
inline

Constructor.

Parameters
filenameThe filename.

Member Function Documentation

◆ is_absolute()

bool Puma::Filename::is_absolute ( ) const
inline

Check whether the filename is absolute, i.e.

starts at the root of the file system.

Returns
True if the filename is absolute.

◆ is_defined()

bool Puma::Filename::is_defined ( ) const
inline

Check if the filename is not NULL.

Returns
True if the filename is valid.

◆ name() [1/2]

const char * Puma::Filename::name ( ) const
inline

Get the filename.

Returns
The filename.

◆ name() [2/2]

void Puma::Filename::name ( const char *  filename)
inline

Set a new filename.

Parameters
filenameThe new filename.

◆ operator!=()

bool Puma::Filename::operator!= ( const Filename filename) const
inline

Check if this filename not equals the given.

Parameters
filenameThe other filename.
Returns
True if both filenames are not equal.

◆ operator=()

Filename & Puma::Filename::operator= ( const char *  filename)
inline

Assign a new filename.

Parameters
filenameThe filename.
Returns
A reference to this filename.

◆ operator==()

bool Puma::Filename::operator== ( const Filename filename) const
inline

Check if this filename equals the given.

Parameters
filenameThe other filename.
Returns
True if both filenames are equal.

◆ operator~()

bool Puma::Filename::operator~ ( ) const
inline

Check if the filename is not NULL.

Returns
True if the filename is valid.

◆ path()

const char * Puma::Filename::path ( )
inline

Get the path portion of the filename.

Returns
The path to the file.

◆ print()

virtual void Puma::Filename::print ( std::ostream &  out) const
inlinevirtual

Print this filename on the given output stream.

Parameters
outThe output stream.

Implements Puma::Printable.

◆ root()

const char * Puma::Filename::root ( )
inline

Get the root of an absolute filename, i.e.

everything up to the first path delimiter. This is for instance the drive portion of the filename on Windows (c:). On Unix systems this is simply a slash (/).

Returns
The root or NULL if filename is not absolute.