resolvePathAliases#

Fully qualified name: carb::tokens::resolvePathAliases

Defined in carb/tokens/PathAlias.h

inline omni::expected<omni::string, ResolveError> carb::tokens::resolvePathAliases(
cpp::string_view srcBuf,
)#

Replaces path alias markers in a path with the full names.

Remark

This resolves a path string by replacing path alias markers with their full paths. Markers must be registered with registerPathAlias() in order to be replaced. When successful, this will always return a new string, but not all of the markers may have been replaced if unregistered markers were found.

Remark

A replaced path will never end in a trailing path separator. It is the caller’s responsibility to ensure the marker(s) in the string are appropriately separated from other path components. This behavior does however allow for path aliases to be used to construct multiple path names by piecing together different parts of a name.

Note

This operation is always thread safe.

Template Parameters:

ReturnString – The string type to return (e.g., omni::string, std::string). Defaults to omni::string.

Parameters:

srcBuf[in] The path to potentially replace path alias markers in. Any path alias markers in the string must be surrounded by “${” and “}” characters (ie: “${exampleMarker}/file.txt”). The markers will only be replaced if a path alias using the same marker name (“exampleMarker” in the previous example) is currently registered.

Returns:

An expected containing the resolved path if the tokens interface is available. The string will contain replaced markers if they were registered, or the original path if no markers were found or replaced.

Returns:

An unexpected with ResolveError if the tokens interface is not available or resolution failed.