Schim
Static Public Member Functions | Public Attributes | List of all members
Variable Struct Reference

A model representation of a variable. More...

#include <variable.h>

Static Public Member Functions

static QString allowedPatterns ()
 Return the regex pattern that represents a valid variable name.
 
static Variable find (const VariableSet &list, QString name)
 Find a variable named name inside list and return it.
 
static QString substitute (QString str, const VariableSet &variableSet)
 Substitute all variables in str with their values. More...
 

Public Attributes

QStringList names
 Contains all names that can be used to identify this variable, separated by a comma.
 

Detailed Description

A model representation of a variable.

Every variable has three fields: names, a value and a description.

The StringList names is used to identify the variable in a string. Each string in names is an alias for the variable, and must match allowedPatterns.

The value is what the variable will be replaced with when displaying text.

The description is simply a way for the user to document the variable.

Member Function Documentation

◆ substitute()

static QString Variable::substitute ( QString  str,
const VariableSet variableSet 
)
static

Substitute all variables in str with their values.

A variable is any substring in str of the forms %pattern or %{pattern}, where pattern is any pattern that matches against the regex returned by allowedPatterns.

Parameters
variableSetSupplies the values for the variables. If a variable occurs in str but is not contained in variableSet, it is assumed to have an empty value.

The documentation for this struct was generated from the following file: