Arbiter  0.0.0
arbiter::util Namespace Reference


std::string stripPostfixing (const std::string path)
std::string getBasename (const std::string fullPath)
std::string getNonBasename (const std::string fullPath)
std::unique_ptr< std::string > env (const std::string &var)
 Extract an environment variable, if it exists, independent of platform.
template<typename... Paths>
std::string join (std::string path, Paths &&...paths)
 Join one or more path components "intelligently". More...

Detailed Description

General utilities.

Function Documentation

std::string arbiter::util::getBasename ( std::string  fullPath)

Returns the portion of fullPath following the last instance of the character /, if any instances exist aside from possibly the delimiter ://. If there are no other instances of /, then fullPath itself will be returned.

If fullPath ends with a trailing / or a glob indication (i.e. is a directory), these trailing characters will be stripped prior to the logic above, thus the innermost directory in the full path will be returned.

std::string arbiter::util::getNonBasename ( std::string  fullPath)

Returns everything besides the basename, as determined by getBasename. For file paths, this corresponds to the directory path above the file. For directory paths, this corresponds to all directories above the innermost directory.

template<typename... Paths>
std::string arbiter::util::join ( std::string  path,
Paths &&...  paths 

Join one or more path components "intelligently".

The result is the concatenation of path and any members of paths with exactly one slash preceding each non-empty portion of path or paths. Portions of paths will be stripped of leading slashes prior to processing, so portions containing only slashes are considered empty.

If path contains a single trailing slash preceded by a non-slash character, then that slash will be stripped prior to processing.

join("") // ""
join("/") // "/"
join("/var", "log", "arbiter.log") // "/var/log/arbiter.log"
join("/var/", "log", "arbiter.log") // "/var/log/arbiter.log"
join("", "var", "log", "arbiter.log") // "/var/log/arbiter.log"
join("/", "/var", "log", "arbiter.log") // "/var/log/arbiter.log"
join("", "/var", "log", "arbiter.log") // "/var/log/arbiter.log"
join("~", "code", "", "test.cpp", "/") // "~/code/test.cpp"
join("C:\\", "My Documents") // "C:/My Documents"
join("s3://", "bucket", "object.txt") // "s3://bucket/object.txt"
std::string arbiter::util::stripPostfixing ( std::string  path)

Returns path, less any trailing glob indicators (one or two asterisks) as well as any possible trailing slash.