OSVR-Core
Public Member Functions | List of all members
osvr::util::ResourcePath Class Reference

Class representing a host and resource path in the OSVR logical system. More...

#include <ResourcePath.h>

Public Member Functions

 ResourcePath ()
 Default constructor - initializes to osvr://localhost/ (root)
 
 ResourcePath (std::string const &url)
 Constructs from a URL string.
 
 ResourcePath (const char *url)
 
ResourcePath GetParent () const
 Go to parent path. More...
 
ResourcePath GetChild (std::string const &childName) const
 Go to the named child. More...
 
ResourcePath GetChild (const char *childName) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Does not take ownership of the argument. More...
 
Base Portion String Accessors

At any time, "osvr://" + GetHostString() + GetPathString() is the canonical form of a path.

Gets the entire path as a string.

std::string GetString () const
 
std::string GetHostString () const
 Gets the host portion of the path as a string.
 
std::string GetPathString () const
 Gets the path following the hostname as a string, starting with a leading slash. More...
 
Component-wise Accessors

Gets the number of named components.

A path at the root is defined to have depth 0.

std::size_t GetDepth () const
 
std::string GetComponent (std::size_t i) const
 Gets the identified component, where 0 is the name of the component immediately under the root. More...
 

Detailed Description

Class representing a host and resource path in the OSVR logical system.

Instances of this class always refer to an absolute path, with host and full path from the root. No assertions are made that the path is meaningful.

Paths are essentially URLs, and follow the same rules. Canonical form of ResourcePaths does not end in a slash, and usage of the . and .. pseudo-entries (for current directory and parent directory) is not supported for simplicity and security.

Paths are immutable: navigating functions return a new ResourcePath.

Enumeration ("browsing") is out of scope for this class - it may be supported in some cases by other code.

Constructor & Destructor Documentation

§ ResourcePath()

osvr::util::ResourcePath::ResourcePath ( const char *  url)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

§ GetChild() [1/2]

ResourcePath osvr::util::ResourcePath::GetChild ( std::string const &  childName) const

Go to the named child.

The name may include slashes for multiple levels.

§ GetChild() [2/2]

ResourcePath osvr::util::ResourcePath::GetChild ( const char *  childName) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Does not take ownership of the argument.

§ GetComponent()

std::string osvr::util::ResourcePath::GetComponent ( std::size_t  i) const

Gets the identified component, where 0 is the name of the component immediately under the root.

Requires that i < GetDepth()

Exceptions
std::out_of_rangeif precondition violated.

§ GetParent()

ResourcePath osvr::util::ResourcePath::GetParent ( ) const

Go to parent path.

If at the root on a host, this is a no-op

§ GetPathString()

std::string osvr::util::ResourcePath::GetPathString ( ) const

Gets the path following the hostname as a string, starting with a leading slash.


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