libzypp  15.28.6
zypp::repo::RepoVarExpand Class Reference

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

#include <RepoVariables.h>

Public Types

typedef function< const
std::string *(const
std::string &)> 
VarRetriever
 Function taking a variable name and returning a pointer to the variable value or nullptr if unset. More...
 

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

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

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

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 382 of file RepoVariables.cc.

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 385 of file RepoVariables.cc.


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