libzypp: zypp::repo::RepoVarExpand Class Reference

libzypp 17.38.10

zypp::repo::RepoVarExpand Class Reference

Functor expanding repo variables in a string. More...

`#include <zypp/repo/RepoVariables.h>`

## Public Types
using | VarRetriever = function<const std::string *(const std::string &)>
| Function taking a variable name and returning a pointer to the variable value or `nullptr` if unset.

## Public Member Functions
std::string | operator() (const std::string &value_r, VarRetriever varRetriever_r) const
| Return a copy of value_r with embedded variables expanded.
std::string | operator() (std::string &&value_r, VarRetriever varRetriever_r) const

## Detailed Description

Functor expanding repo variables in a string.

Known variables are determined by a callback function taking a variable name and returning a pointer to the variable value or `nullptr` if unset.

The `$` character introduces variable expansion. A valid variable name is any non-empty case-insensitive sequence of [[:alnum:]_]. The variable name to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name.

When braces are used, the matching ending brace is the first `}` not escaped by a backslash and not within an embedded variable expansion. Within braces only `$`, `}` and `backslash` are escaped by a backslash. There is no escaping outside braces, to stay comaptible with `YUM` (which does not support braces).

- `${variable}` If `variable` is unset the original is preserved like in `YUM`. Otherwise, the value of `variable` is substituted.

- `${variable:-word}` (default value) If `variable` is unset or empty, the expansion of `word` is substituted. Otherwise, the value of `variable` is substituted.

- `${variable:+word}` (alternate value) If variable is unset or empty nothing is substituted. Otherwise, the expansion of `word` is substituted.

Definition at line 57 of file RepoVariables.h.

## Member Typedef Documentation

## ◆ VarRetriever

using zypp::repo::RepoVarExpand::VarRetriever = function<const std::string *(const std::string &)>

Function taking a variable name and returning a pointer to the variable value or `nullptr` if unset.

Definition at line 60 of file RepoVariables.h.

## Member Function Documentation

## ◆ operator()() [1/2]

std::string zypp::repo::RepoVarExpand::operator() | ( | const std::string & | value_r,
|  | VarRetriever | varRetriever_r ) const

Return a copy of value_r with embedded variables expanded.

Definition at line 381 of file RepoVariables.cc.

## ◆ operator()() [2/2]

std::string zypp::repo::RepoVarExpand::operator() | ( | std::string && | value_r,
|  | VarRetriever | varRetriever_r ) const

Definition at line 384 of file RepoVariables.cc.

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

- zypp/repo/RepoVariables.h
- zypp/repo/RepoVariables.cc