OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osvr::util::ResourcePath Class Reference

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

#include <osvr/Util/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. The name may include slashes for multiple levels.
 
ResourcePath GetChild (const char *childName) const
 
Base Portion String Accessors

Gets the entire path as a string.

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

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

Definition at line 61 of file ResourcePath.h.

Constructor & Destructor Documentation

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

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

Go to parent path.

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

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.

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.

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