C# Class YAML.Preprocessor

Implements a class that pre-processes a YAML file and handles pre-processor directives to include other files, set variables, and handle variable substitution. The pre-processor also strips comments from the contents fed back to the parser.
Inheritance: IDisposable
Exibir arquivo Open project: agardiner/hfmcmd Class Usage Examples

Protected Properties

Property Type Description
_files Stack
_lines Stack
_log ILog
_process Stack
_streams Stack
_variables object>.Dictionary

Public Methods

Method Description
Dispose ( ) : void

Disposes of each open file.

Preprocessor ( string file, object>.Dictionary variables ) : System

Constructs a YAML Preprocessor instance.

ReadLine ( ) : string

Reads the next line of input from the YAML source.

Protected Methods

Method Description
HandleDirective ( string line ) : void

Handles a pre-processor directive (i.e. a line starting with %).

IncludeFile ( string file ) : void

Includes the specified file, pushing the new file onto the stack, so that lines come from the new file until it is completed.

SubstituteVariables ( string line, object>.Dictionary variables ) : string

Substitutes a value for any variables used in the supplied string. The variable values to be substituted are in the supplied dictionary.

Method Details

Dispose() public method

Disposes of each open file.
public Dispose ( ) : void
return void

HandleDirective() protected method

Handles a pre-processor directive (i.e. a line starting with %).
protected HandleDirective ( string line ) : void
line string
return void

IncludeFile() protected method

Includes the specified file, pushing the new file onto the stack, so that lines come from the new file until it is completed.
protected IncludeFile ( string file ) : void
file string
return void

Preprocessor() public method

Constructs a YAML Preprocessor instance.
public Preprocessor ( string file, object>.Dictionary variables ) : System
file string The source file that will drive the YAML parsing /// process. Note that this file may include other files, but all this /// is transparent to the YAMLParser.
variables object>.Dictionary A Variables collection of variable names /// and values. The Variables collection may be modified by the /// Preprocessor in response to preprocessor directives to set/unset /// variables etc.
return System

ReadLine() public method

Reads the next line of input from the YAML source.
public ReadLine ( ) : string
return string

SubstituteVariables() protected method

Substitutes a value for any variables used in the supplied string. The variable values to be substituted are in the supplied dictionary.
protected SubstituteVariables ( string line, object>.Dictionary variables ) : string
line string
variables object>.Dictionary
return string

Property Details

_files protected_oe property

protected Stack _files
return Stack

_lines protected_oe property

protected Stack _lines
return Stack

_log protected_oe static_oe property

protected static ILog _log
return ILog

_process protected_oe property

protected Stack _process
return Stack

_streams protected_oe property

protected Stack _streams
return Stack

_variables protected_oe property

protected Dictionary _variables
return object>.Dictionary