OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
|
OPENASSETIO_CORE_EXPORT openassetio::Str | substitute (std::string_view input, const openassetio::InfoDictionary &substitutions) |
| Substitute placeholders in a given string using the provided dictionary mapping of tokens to values. More...
|
|
Indicator of platform type associate with a path.
Enumerator |
---|
kSystem |
Use the current system platform to determine path type.
|
kPOSIX |
Assume a POSIX path.
|
kWindows |
Assume a Windows path (including UNC).
|
OPENASSETIO_CORE_EXPORT openassetio::Str openassetio::v1::utils::substitute |
( |
std::string_view |
input, |
|
|
const openassetio::InfoDictionary & |
substitutions |
|
) |
| |
Substitute placeholders in a given string using the provided dictionary mapping of tokens to values.
The input string can contain placeholders in the form of {key}
where key
is a key in the provided dictionary. The placeholder will be replaced by the corresponding value from the dictionary.
All placeholders must be valid keys in the dictionary. If a placeholder is not found in the dictionary, an exception will be thrown.
Integers can be zero-padded in the format string. For example, {key:03d}
will replace the placeholder with the integer value of key
from the dictionary, padded with zeros to a width of 3 digits. The format specifier follows libfmt
/ Python format string syntax.
Note that no format specifiers other than zero-padding are officially supported, though other specifiers may work. This is to keep the interop surface area as small as possible, e.g. to ease cross-language support.
- Parameters
-
input | The string in which substitutions are to be made. |
substitutions | The dictionary containing the keys to be replaced and their corresponding values. |
- Returns
- The input string with all valid substitutions made.
- Exceptions
-
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License