Falaise
4.0.1
SuperNEMO Software Toolkit
|
Class representing a filesystem path as held by a property_set. More...
#include <falaise/config/path.h>
Public Member Functions | |
path ()=default | |
Default constructor. More... | |
path (std::string const &p) | |
Construct path from a std::string. More... | |
operator std::string () const | |
Conversion to std::string. More... | |
bool | operator== (path const &other) const |
Equality operator. More... | |
bool | operator!= (path const &other) const |
Inequality operator. More... | |
bool | operator== (std::string const &other) const |
Equality operator for path against a string. More... | |
bool | operator!= (std::string const &other) const |
Inequality operator for path against a string. More... | |
Class representing a filesystem path as held by a property_set.
Filesystem paths can be defined in datatools::properties syntax as:
Parsing of the properties file will expand any mount points or environment variables so that fetching the path will return a std::string
containing the resolved absolute path.
path provides a simple type to distinguish raw std::string
from explicit paths allowing users to validate that a property_set value is a true path. It is nothing more than a simple holder of the std::string for the absolute path and may be used as:
A path can be constructed from any string whose value is a valid path as understood by datatools::fetch_path_with_env. Examples are:
auto x = falaise::config::path{"/foo/bar/baz.txt"};
auto x = falaise::config::path{"bar/baz.txt"};
The string may also include environment variables, e.g. $HOME
or ${HOME}
, which will be expanded if they exist, otherwise a invalid_path_error is thrown. When running in a program that provides the datatools::kernel service, paths can also be supplied as:
@falaise:foo/bar.txt
urn:subject:object
Note that in all cases, path does not check that a file exists at the location specified by the path. If you require more specific filesystem functionality, you should use the value of path in a full library such as boost::filesystem or C++17's std::filesystem if available.
|
default |
Default constructor.
falaise::config::path::path | ( | std::string const & | p | ) |
Construct path from a std::string.
Not declared explicit as we allow conversions for compatibility with existing use of filesystem paths as std::string.
[in] | p |
invalid_path_error | if p is not a valid path string |
|
inline |
Conversion to std::string.
Inequality operator.
|
inline |
Inequality operator for path against a string.
Equality operator.
|
inline |
Equality operator for path against a string.