39#include "exceptions.hpp"
54 chemin() { members.clear(); index = 0; };
55 chemin(
const std::string & path);
71 void clear() { members.clear(); index = 0; };
75 bool operator != (
const chemin & ref)
const {
return !((*this) == ref); };
92 std::string
front()
const {
if(
empty())
throw exception_range(
"cannot get front() from an empty chemin");
return members.front(); };
97 std::string
back()
const {
if(
empty())
throw exception_range(
"cannot get back() from an empty chemin");
return members.back(); };
108 unsigned int size()
const {
return members.size(); };
111 bool empty()
const {
return members.empty(); };
131 std::string
display(
bool relative =
false)
const;
136 std::string
namify()
const;
143 const std::string &
operator[] (
unsigned int x)
const;
146 std::deque<std::string> members;
class chemin definition
Definition: chemin.hpp:51
void clear()
default copy constructor is OK
Definition: chemin.hpp:71
std::string back() const
get the last member of the path
Definition: chemin.hpp:97
std::string front() const
get the first member of the path
Definition: chemin.hpp:92
const std::string & operator[](unsigned int x) const
Definition: chemin.cpp:161
void decrease_index() const
set the index to the previous member. If the member is the first of the path, this call does nothing
Definition: chemin.hpp:125
void push_back(const std::string &x)
add a member at the end of the path
Definition: chemin.cpp:72
void pop_front()
Definition: chemin.cpp:92
bool empty() const
return true if the path is an empty path (having no members)
Definition: chemin.hpp:111
void operator+=(const chemin &ref)
concatenate a path to this object
Definition: chemin.cpp:81
chemin()
constucts an empty path
Definition: chemin.hpp:54
std::string namify() const
Definition: chemin.cpp:140
bool operator==(const chemin &ref) const
compaires two path
Definition: chemin.hpp:74
void increase_index() const
set the index to the next member. If the member is the last of the path this call does nothing
Definition: chemin.hpp:122
std::string display(bool relative=false) const
return a string corresponding to the expected value of an absolute path
Definition: chemin.cpp:119
bool is_the_beginning_of(const chemin &ref) const
return true if 'this' is the beginning of ref
Definition: chemin.cpp:58
chemin operator+(const chemin &ref) const
concatenate a path with us another
Definition: chemin.hpp:84
unsigned int size() const
returns the size of the path in number of members
Definition: chemin.hpp:108
void set_index(unsigned int val) const
set the index to an arbitrary value. An exception is thrown if the given value is greater or equal th...
Definition: chemin.cpp:112
unsigned int get_index() const
Definition: chemin.hpp:119
void pop_back()
removes the last member of the path from this object
Definition: chemin.cpp:102
exception used to report out or range value or argument
Definition: exceptions.hpp:109