dyaml.emitter

YAML emitter. Code based on PyYAML: http://www.pyyaml.org

Types 7

Fields
string scalar
BitFlags!AnalysisFlags flagsAnalysis results.
Nested Templates
AnalysisFlags
private aliasisNewLine = among!('\n', '\u0085', '\u2028', '\u2029')
private aliasisSpecialChar = among!('#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\\', '\'', '"', '%', '@', '`')
private aliasisFlowIndicator = among!(',', '?', '[', ']', '{', '}')
private aliasisSpace = among!('\0', '\n', '\r', '\u0085', '\u2028', '\u2029', ' ', '\t')
structEmitter(Range, CharType) if (isOutputRange!(Range, CharType))
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 Queue!Event events_Event queue.
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
int opCmp(ref Emitter) @disable
bool opEquals(ref Emitter) @disable
void emit(Event event) @safeEmit an event.
private EmitterFunction popState() @safePop and return the newest state in states_.
private void pushState(string D)() @safe
private int popIndent() @safePop and return the newest indent in indents_.
private void writeString(const scope char[] str) @safeWrite a string to the file/stream.
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 expectStreamStart() @safeHandle start of a file/stream.
private void expectNothing() @safeExpect nothing, throwing if we still have something.
private void expectDocumentStart(Flag!"first" first)() @safeHandle start of a document.
private void expectDocumentEnd() @safeHandle end of a document.
private void expectRootNode() @safeHandle the root node of a document.
private void expectMappingNode(const bool simpleKey = false) @safeHandle a mapping node.
private void expectSequenceNode() @safeHandle a sequence node.
private void expectNode(const Context context) @safeHandle a new node. Context specifies where in the document we are.
private void expectAlias() @safeHandle an alias.
private void expectScalar() @safeHandle a scalar.
private void expectFlowSequence() @safeHandle a flow sequence.
private void expectFlowSequenceItem(Flag!"first" first)() @safeHandle a flow sequence item.
private void expectFlowMapping() @safeHandle a flow mapping.
private void expectFlowMappingKey(Flag!"first" first)() @safeHandle a key in a flow mapping.
private void expectFlowMappingSimpleValue() @safeHandle a simple value in a flow mapping.
private void expectFlowMappingValue() @safeHandle a complex value in a flow mapping.
private void expectBlockSequence() @safeHandle a block sequence.
private void expectBlockSequenceItem(Flag!"first" first)() @safeHandle a block sequence item.
private void expectBlockMapping() @safeHandle a block mapping.
private void expectBlockMappingKey(Flag!"first" first)() @safeHandle a key in a block mapping.
private void expectBlockMappingSimpleValue() @safeHandle a simple value in a block mapping.
private void expectBlockMappingValue() @safeHandle a complex value in a block mapping.
private bool checkEmptySequence() const @safe pure nothrowCheck if an empty sequence is next.
private bool checkEmptyMapping() const @safe pure nothrowCheck if an empty mapping is next.
private bool checkEmptyDocument() const @safe pure nothrowCheck if an empty document is next.
private bool checkSimpleKey() @safeCheck if a simple key is next.
private void processScalar() @safeProcess and write a scalar.
private void processAnchor(const string indicator) @safeProcess and write an anchor/alias.
private void processTag() @safeProcess and write a tag.
private ScalarStyle chooseScalarStyle() @safeDetermine style to write the current scalar in.
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 string prepareTag(in string tag) @safePrepare tag for output.
private string prepareAnchor(const string anchor) static @safePrepare anchor for output.
private ScalarAnalysis analyzeScalar(string scalar) static @safeAnalyze specifed scalar and return the analysis result.
private void writeStreamStart() @safeStart the YAML stream (write the unicode byte order mark).
private void writeStreamEnd() @safeEnd the YAML stream.
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 writeIndent() @safeWrite indentation.
private void writeLineBreak(const scope char[] data = null) @safeStart new line.
private void writeVersionDirective(const string versionText) @safeWrite a YAML version directive.
private void writeTagDirective(const string handle, const string prefix) @safeWrite a tag directive.
private void nextExpected(string D)() @safe
private void nextExpected(EmitterFunction f) @safe
private void callNext() @safe
Constructors
this(Range stream, const bool canonical, const int indent, const int width, const LineBreak lineBreak)Construct an emitter.
Nested Templates
ContextDescribes context (where we are in the document).
private structScalarWriter(Range, CharType)

RAII struct used to write out scalar values.

Fields
private dcharNoneUsed as "null" UTF-32 character.
private Emitter!(Range, CharType) * emitter_Emitter used to emit the scalar.
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 int opCmp(ref Emitter!(Range, CharType)) @disable
private bool opEquals(ref Emitter!(Range, CharType)) @disable
void writeSingleQuoted() @safeWrite text as single quoted scalar.
void writeDoubleQuoted() @safeWrite text as double quoted scalar.
void writeFolded() @safeWrite text as folded block scalar.
void writeLiteral() @safeWrite text as literal block scalar.
void writePlain() @safeWrite text as plain scalar.
private dchar nextChar() @property pure @safeGet next character and move end of the text range to it.
private dchar charAtStart() @property const pure @safeGet character at start of the text range.
private bool tooWide() @property const pure @safe nothrowIs the current line too wide?
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 writeLineBreaks() @safeWrite line breaks in the text range.
private void writeStartLineBreak() @safeWrite line break if start of the text range is a newline.
private void writeIndent(const Flag!"ResetSpace" resetSpace) @safeWrite indentation, optionally resetting whitespace/indentation flags.
private void updateRangeStart() pure @safe nothrowMove start of text range to its end.
private void updateBreaks(in dchar c, const Flag!"UpdateSpaces" updateSpaces) pure @safeUpdate the line breaks_ flag, optionally updating the spaces_ flag.
private void resetTextPosition() pure @safe nothrowMove to the beginning of text.
Constructors
this(Emitter!(Range, CharType) * emitter, string text, const bool split = true)Construct a ScalarWriter using emitter to output text.