RAUL  0.5.1
Public Member Functions | Static Public Member Functions | List of all members
Raul::Path Class Reference

Simple wrapper around standard string with useful path-specific methods. More...

#include <Path.hpp>

Public Member Functions

 Path ()
 Construct an uninitialzed path, because the STL is annoying. More...
 
 Path (const std::basic_string< char > &path)
 Construct a Path from an std::string. More...
 
 Path (const char *cpath)
 Construct a Path from a C string. More...
 
bool is_child_of (const Path &parent) const
 
bool is_parent_of (const Path &child) const
 
Symbol name () const
 Return the name of this object (everything after the last '/'). More...
 
Path parent () const
 Return the parent's path. More...
 
Path relative_to_base (const Path &base) const
 Return path relative to soe base path (chop prefix)
 
const std::string base () const
 Return path with a trailing "/". More...
 

Static Public Member Functions

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)
 
static std::string nameify (const std::basic_string< char > &str)
 
static void replace_invalid_chars (std::string &str, bool replace_slash=false)
 
static bool descendant_comparator (const Path &parent, const Path &child)
 Return true if child is equal to, or a descendant of parent.
 

Detailed Description

Simple wrapper around standard string with useful path-specific methods.

This enforces that a Path is a valid OSC path (though it is used for GraphObject paths, which aren't directly OSC paths but a portion of one).

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).

Valid characters are the 95 printable ASCII characters (32-126), excluding: space # * , ? [ ] { }

Constructor & Destructor Documentation

Raul::Path::Path ( )
inline

Construct an uninitialzed path, because the STL is annoying.

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

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)
inline

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.

Member Function Documentation

Symbol Raul::Path::name ( ) const
inline

Return the name of this object (everything after the last '/').

This is the "method name" for OSC paths.

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.

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.


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