RAUL 0.8.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions
Raul::Path Class Reference
Realtime Audio Utility Library

A URI which is a path (for example a filesystem or OSC path). More...

`#include <Path.hpp>`

Inheritance diagram for Raul::Path:
Collaboration diagram for Raul::Path:

List of all members.

## Public Member Functions

| Path ()
| Construct an uninitialzed path, because the STL is annoying.
| Path (const std::basic_string< char > &path)
| Construct a Path from an std::string.
| Path (const char *cpath)
| Construct a Path from a C string.
| Path (const Path &copy)
| Construct a Path from another path.
bool | is_root () const
bool | is_child_of (const Path &parent) const
bool | is_parent_of (const Path &child) const
Path | child (const std::string &s) const
Path | child (const Path &p) const
Path | operator+ (const Path &p) const
const char * | symbol () const
| Return the symbol of this path (everything after the last '/').
Path | parent () const
| Return the parent's path.
Path | child (const Raul::Symbol &symbol) const
| Return the path's child with the given name (symbol)
Path | relative_to_base (const Path &base) const
| Return path relative to some base path (chop prefix)
const std::string | base () const
| Return path with a trailing "/".
const std::string | base_no_scheme () const
| Return path with a trailing "/".

## Static Public Member Functions

static const Path | root ()
| Return the root path.
static void | set_root (const Raul::URI &uri)
| Set the root path.
static bool | is_path (const Raul::URI &uri)
static bool | is_valid (const std::basic_string< char > &path)
static bool | is_valid_name (const std::basic_string< char > &name)
static std::string | pathify (const std::basic_string< char > &str)
| Convert a string to a valid full path.
static std::string | nameify (const std::basic_string< char > &str)
| Convert a string to a valid name (or "method" - tokens between slashes)
static void | replace_invalid_chars (std::string &str, size_t start, bool replace_slash=false)
| Replace any invalid characters in str with a suitable replacement.
static bool | descendant_comparator (const Path &parent, const Path &child)
| Return true if child is equal to, or a descendant of parent.

## Detailed Description

A URI which is a path (for example a filesystem or OSC path).

This enforces that a Path is a valid path, where each fragment is a valid Symbol, separated by exactly one slash (/).

A path is divided by slashes (/). The first character MUST be a slash, and the last character MUST NOT be a slash (except in the special case of the root path "/", which is the only valid single-character path). A Path is actually a URI, the relative path is appended to the root URI automatically, so a Patch can always be used as a URI.

## Constructor & Destructor Documentation

Raul::Path::Path | ( |  | ) | `[inline]`

Construct an uninitialzed path, because the STL is annoying.

Referenced by root().

Raul::Path::Path | ( | const std::basic_string< char > & | path | ) |

Construct a Path from an std::string.

It is a fatal error to construct a Path from an invalid string, use is_valid first to check.

Raul::Path::Path | ( | const char * | cpath | ) |

Construct a Path from a C string.

It is a fatal error to construct a Path from an invalid string, use is_valid first to check.

Raul::Path::Path | ( | const Path & | copy | ) | `[inline]`

Construct a Path from another path.

This is faster than constructing a path from the other path's string representation, since validity checking is avoided.

## Member Function Documentation

const Path Raul::Path::root | ( |  | ) | `[static]`

Return the root path.

The default root path is the URI "path:/"

A Path is either the root path, or a child of a root path (i.e. the root path followed by a sequence of Symbols separated by '/')

References Path().

Referenced by base(), descendant_comparator(), parent(), pathify(), and symbol().

void Raul::Path::set_root | ( | const Raul::URI & | uri | ) | `[static]`

Set the root path.

The default root path is the URI "path:/"

Note this should be done on application start up. Changing the root path while any Path objects exist will break things horribly; don't!

The root can be set to any URI, there are no restrictions on valid characters and such like there are for relative paths (but it must be a valid URI, i.e. begin with a scheme, and in particular not begin with '/'). Relative paths are appended to the root path's URI, i.e. every Path, as a string, begins with the root URI. The part after that is a strict path (a sequence of Symbols separated by '/').

string Raul::Path::pathify | ( | const std::basic_string< char > & | str | ) | `[static]`

Convert a string to a valid full path.

The returned string is a valid relative path without the root prefix, i.e. the returned string starts with '/' followed by valid symbols, each separated by '/'.

References Raul::URI::chop_scheme(), replace_invalid_chars(), and root().

string Raul::Path::nameify | ( | const std::basic_string< char > & | str | ) | `[static]`

Convert a string to a valid name (or "method" - tokens between slashes)

This will strip all slashes, etc, and always return a valid name/method.

References replace_invalid_chars().

const char* Raul::Path::symbol | ( |  | ) | const`[inline]`

Return the symbol of this path (everything after the last '/').

This is e.g. the "method name" for OSC paths, the filename for filesystem paths, etc. The empty string may be returned (if the path is the root path).

References root().

Path Raul::Path::parent | ( |  | ) | const`[inline]`

Return the parent's path.

Calling this on the path "/" will return "/". This is the (deepest) "container path" for OSC paths.

References root().

const std::string Raul::Path::base | ( |  | ) | const`[inline]`

Return path with a trailing "/".

Returned value is guaranteed to be a valid parent path, i.e. a valid child path can be made using parent.base() + child_name.

References root().

Referenced by base_no_scheme(), and child().

const std::string Raul::Path::base_no_scheme | ( |  | ) | const`[inline]`

Return path with a trailing "/".

Returned value is guaranteed to be a valid parent path, i.e. a valid child path can be made using parent.base() + child_name.

References base().

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

- Path.hpp
- Path.cpp