dyaml.emitter
YAML emitter. Code based on PyYAML: http://www.pyyaml.org
Types 7
structScalarAnalysis
Nested Templates
AnalysisFlagsprivate aliasisNewLine = among!('\n', '\u0085', '\u2028', '\u2029')
private aliasisSpecialChar = among!('#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\\', '\'', '"', '%', '@', '`')
private aliasisFlowIndicator = among!(',', '?', '[', ']', '{', '}')
private aliasisSpace = among!('\0', '\n', '\r', '\u0085', '\u2028', '\u2029', ' ', '\t')
Fields
private TagDirective[] defaultTagDirectives_Default tag handle shortcuts and replacements.private Range stream_Stream to write to.private Appender!(EmitterFunction[]) states_Stack of states.private EmitterFunction state_Current state.private Event event_Event we're currently emitting.private Appender!(int[]) indents_Stack of previous indentation levels.private int indent_Current indentation level.private uint flowLevel_Level of nesting in flow context. If 0, we're in block context.private Context context_Current context.private uint line_Characteristics of the last emitted character: Line.private uint column_Column.private bool whitespace_Whitespace character?private bool indentation_indentation space, '-', '?', or ':'?private bool openEnded_Does the document require an explicit document indicator?private bool canonical_Formatting details. Canonical scalar format?private uint bestIndent_Best indentation width.private uint bestWidth_Best text width.private LineBreak bestLineBreak_Best line break character/s.private TagDirective[] tagDirectives_Tag directive handle - prefix pairs.private string preparedAnchor_Anchor/alias to process.private string preparedTag_Tag to process.private ScalarAnalysis analysis_Analysis result of the current scalar.private ScalarStyle style_Style of the current scalar.Methods
private
bool needMoreEvents() @safe nothrowIn some cases, we wait for a few next events before emitting.private
bool needEvents(in uint count) @safe nothrowDetermines if we need specified number of more events.private
void increaseIndent(const Flag!"flow" flow = No.flow, const bool indentless = false) @safeIncrease indentation level.private
bool eventTypeIs(in EventID id) const pure @safeDetermines if the type of current event is as specified. Throws if no event.private
void expectNode(const Context context) @safeHandle a new node. Context specifies where in the document we are.private
string prepareVersion(const string YAMLVersion) static @safePrepare YAML version string for output.private
void encodeChar(Writer)(ref Writer writer, in dchar c) static @safeEncode an Unicode character for tag directive and write it to writer.private
string prepareTagHandle(const string handle) static @safePrepare tag directive handle for output.private
string prepareTagPrefix(const string prefix) static @safePrepare tag directive prefix for output.private
ScalarAnalysis analyzeScalar(string scalar) static @safeAnalyze specifed scalar and return the analysis result.private
void writeIndicator(const scope char[] indicator,
const Flag!"needWhitespace" needWhitespace,
const Flag!"whitespace" whitespace = No.whitespace,
const Flag!"indentation" indentation = No.indentation) @safeWrite an indicator (e.g. ":", "[", ">", etc.).private
void writeTagDirective(const string handle, const string prefix) @safeWrite a tag directive.Constructors
Nested Templates
ContextDescribes context (where we are in the document).RAII struct used to write out scalar values.
Fields
private dcharNoneUsed as "null" UTF-32 character.private string text_UTF-8 encoded text of the scalar to write.private bool split_Can we split the scalar into multiple lines?private bool spaces_Are we currently going over spaces in the text?private bool breaks_Are we currently going over line breaks in the text?private size_t startByte_Start and end byte of the text range we're currently working with.private size_t nextEndByte_End byte of the text range including the currently processed character.private long startChar_Start and end character of the text range we're currently working with.Methods
private
dchar nextChar() @property pure @safeGet next character and move end of the text range to it.private
size_t determineBlockHints(char[] hints, uint bestIndent) const pure @safeDetermine hints (indicators) for block scalar.private
void initBlock(const char indicator) @safeInitialize for block scalar writing with specified indicator.private
void writeCurrentRange(const Flag!"UpdateColumn" updateColumn) @safeWrite out the current text range.private
void writeIndent(const Flag!"ResetSpace" resetSpace) @safeWrite indentation, optionally resetting whitespace/indentation flags.private
void updateBreaks(in dchar c, const Flag!"UpdateSpaces" updateSpaces) pure @safeUpdate the line breaks_ flag, optionally updating the spaces_ flag.