Struct gpp::Context[][src]

pub struct Context {
    pub macros: HashMap<String, String>,
    pub inactive_stack: u32,
    pub used_if: bool,
    pub allow_exec: bool,
    pub in_stack: Vec<Child>,
}
Expand description

Context of the current processing.

Contains a set of currently defined macros, as well as the number of nested if statements that are being ignored; this is so that if the parser failed an if statement, and it is currently ignoring data, it knows how many endifs it needs to encounter before resuming reading data again. Only if this value is 0 then the parser will read data. It also stores whether the current if group has been accepted; this is for if groups with over three parts.

There are no limits on what variable names can be; by directly altering Context::macros, you can set variable names not possible with #defines. However, when replacing variable names in text the variable name must be surrounded by two characters that are not alphanumeric or an underscore.

Fields

macros: HashMap<String, String>

Map of all currently defined macros.

inactive_stack: u32

Number of layers of inactive if statements.

used_if: bool

Whether the current if statement has been accepted.

allow_exec: bool

Whether #exec and #in commands are allowed.

in_stack: Vec<Child>

The stack of processes that #in is piping to.

Implementations

Create a new empty context with no macros or inactive stack and exec commands disallowed.

Create a new empty context with no macros or inactive stack and exec commands allowed.

Create a context from a map of macros.

Create a context from an iterator over tuples.

Set whther exec commands are allowed.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.