Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::Path Class Referencefinal

Path class is used to simplify the edition of paths. More...

#include <Path.hpp>

Public Member Functions

 Path (const char *path)
 Construct a new Path object.
 ~Path ()
const char * get_drive () const
 Get the drive of the path.
int get_num_components () const
 Get the number of components in the path.
const char * get_component (int i) const
 Get the component at a choosen position.
const char * get_tail () const
 Get the last component of the path.
const char * get_filename () const
 Get the filename of the path (can be null if there is no file).
const char * get_basename () const
 Get the basename of the file (can be null if there is no file).
const char * get_file_extension () const
 Get the file extension of the path (can be null if there is no file).
void set_drive (const char *drive)
 Set the drive of the path.
void append_component (const char *component)
 Add a component to the path (add a folder to the end of the path).
void insert_component (int i, const char *component)
 Insert a component at a specified position.
void replace_component (int i, const char *component)
 Replace a component at a specified position.
void remove_component (int i)
 Remove a compoent at a specified position.
void drop_tail ()
 Removes the last component of the path.
void set_filename (const char *filename)
 Set the filename of the path.
void set_file_extension (const char *ext)
 Set the file extension of the path file.
void absolute ()
 Make the path canonical removes the .. and . component and make it absolute.
const char * c_str () const
 Get the path string.
 operator const char * () const
 operator std::string () const

Static Public Member Functions

static Pathget_resources_path ()
 Get the standard resource path.

Friends

std::ostream & operator<< (std::ostream &output, const Path &path)

Detailed Description

Path class is used to simplify the edition of paths.

Constructor & Destructor Documentation

◆ Path()

turbo::Path::Path ( const char * path)

Construct a new Path object.

Note
this constructor remove the . and .. components of the path
See also
absolute
Parameters
pathinitial path

◆ ~Path()

turbo::Path::~Path ( )

Member Function Documentation

◆ absolute()

void turbo::Path::absolute ( )

Make the path canonical removes the .. and . component and make it absolute.

◆ append_component()

void turbo::Path::append_component ( const char * component)

Add a component to the path (add a folder to the end of the path).

Example: myPath.append_component("src");

Parameters
componentcomponent to add

◆ c_str()

const char * turbo::Path::c_str ( ) const

Get the path string.

Returns
const char* path string

◆ drop_tail()

void turbo::Path::drop_tail ( )

Removes the last component of the path.

◆ get_basename()

const char * turbo::Path::get_basename ( ) const

Get the basename of the file (can be null if there is no file).

◆ get_component()

const char * turbo::Path::get_component ( int i) const

Get the component at a choosen position.

Parameters
iposition

◆ get_drive()

const char * turbo::Path::get_drive ( ) const

Get the drive of the path.

◆ get_file_extension()

const char * turbo::Path::get_file_extension ( ) const

Get the file extension of the path (can be null if there is no file).

◆ get_filename()

const char * turbo::Path::get_filename ( ) const

Get the filename of the path (can be null if there is no file).

◆ get_num_components()

int turbo::Path::get_num_components ( ) const

Get the number of components in the path.

◆ get_resources_path()

Path * turbo::Path::get_resources_path ( )
static

Get the standard resource path.

Returns
Path* new path that needs to be deleted after usage

◆ get_tail()

const char * turbo::Path::get_tail ( ) const

Get the last component of the path.

◆ insert_component()

void turbo::Path::insert_component ( int i,
const char * component )

Insert a component at a specified position.

Parameters
iposiiton
componentcomponent to insert

◆ operator const char *()

turbo::Path::operator const char * ( ) const

◆ operator std::string()

turbo::Path::operator std::string ( ) const

◆ remove_component()

void turbo::Path::remove_component ( int i)

Remove a compoent at a specified position.

Parameters
iposition

◆ replace_component()

void turbo::Path::replace_component ( int i,
const char * component )

Replace a component at a specified position.

Parameters
iposition
componentcomponent to insert

◆ set_drive()

void turbo::Path::set_drive ( const char * drive)

Set the drive of the path.

Example: myPath.set_drive("C:");

Parameters
drivetarget drive

◆ set_file_extension()

void turbo::Path::set_file_extension ( const char * ext)

Set the file extension of the path file.

Example: myPath.set_file_extension("png");

Parameters
extextension

◆ set_filename()

void turbo::Path::set_filename ( const char * filename)

Set the filename of the path.

Parameters
filenamefile name

◆ operator<<

std::ostream & operator<< ( std::ostream & output,
const Path & path )
friend

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