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
TagDirective[] defaultTagDirectives_Default tag handle shortcuts and replacements.
Range stream_Stream to write to.
Appender!(EmitterFunction[]) states_Stack of states.
EmitterFunction state_Current state.
Queue!Event events_Event queue.
Event event_Event we're currently emitting.
Appender!(int[]) indents_Stack of previous indentation levels.
int indent_Current indentation level.
uint flowLevel_Level of nesting in flow context. If 0, we're in block context.
Context context_Current context.
uint line_Characteristics of the last emitted character: Line.
uint column_Column.
bool whitespace_Whitespace character?
bool indentation_indentation space, '-', '?', or ':'?
bool openEnded_Does the document require an explicit document indicator?
bool canonical_Formatting details. Canonical scalar format?
uint bestIndent_Best indentation width.
uint bestWidth_Best text width.
LineBreak bestLineBreak_Best line break character/s.
TagDirective[] tagDirectives_Tag directive handle - prefix pairs.
string preparedAnchor_Anchor/alias to process.
string preparedTag_Tag to process.
ScalarAnalysis analysis_Analysis result of the current scalar.
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.
EmitterFunction popState() @safePop and return the newest state in states_.
void pushState(string D)() @safe
int popIndent() @safePop and return the newest indent in indents_.
void writeString(const scope char[] str) @safeWrite a string to the file/stream.
bool needMoreEvents() @safe nothrowIn some cases, we wait for a few next events before emitting.
bool needEvents(in uint count) @safe nothrowDetermines if we need specified number of more events.
void increaseIndent(const Flag!"flow" flow = No.flow, const bool indentless = false) @safeIncrease indentation level.
bool eventTypeIs(in EventID id) const pure @safeDetermines if the type of current event is as specified. Throws if no event.
void expectStreamStart() @safeHandle start of a file/stream.
void expectNothing() @safeExpect nothing, throwing if we still have something.
void expectDocumentStart(Flag!"first" first)() @safeHandle start of a document.
void expectDocumentEnd() @safeHandle end of a document.
void expectRootNode() @safeHandle the root node of a document.
void expectMappingNode(const bool simpleKey = false) @safeHandle a mapping node.
void expectSequenceNode() @safeHandle a sequence node.
void expectNode(const Context context) @safeHandle a new node. Context specifies where in the document we are.
void expectAlias() @safeHandle an alias.
void expectScalar() @safeHandle a scalar.
void expectFlowSequence() @safeHandle a flow sequence.
void expectFlowSequenceItem(Flag!"first" first)() @safeHandle a flow sequence item.
void expectFlowMapping() @safeHandle a flow mapping.
void expectFlowMappingKey(Flag!"first" first)() @safeHandle a key in a flow mapping.
void expectFlowMappingSimpleValue() @safeHandle a simple value in a flow mapping.
void expectFlowMappingValue() @safeHandle a complex value in a flow mapping.
void expectBlockSequence() @safeHandle a block sequence.
void expectBlockSequenceItem(Flag!"first" first)() @safeHandle a block sequence item.
void expectBlockMapping() @safeHandle a block mapping.
void expectBlockMappingKey(Flag!"first" first)() @safeHandle a key in a block mapping.
void expectBlockMappingSimpleValue() @safeHandle a simple value in a block mapping.
void expectBlockMappingValue() @safeHandle a complex value in a block mapping.
bool checkEmptySequence() const @safe pure nothrowCheck if an empty sequence is next.
bool checkEmptyMapping() const @safe pure nothrowCheck if an empty mapping is next.
bool checkEmptyDocument() const @safe pure nothrowCheck if an empty document is next.
bool checkSimpleKey() @safeCheck if a simple key is next.
void processScalar() @safeProcess and write a scalar.
void processAnchor(const string indicator) @safeProcess and write an anchor/alias.
void processTag() @safeProcess and write a tag.
ScalarStyle chooseScalarStyle() @safeDetermine style to write the current scalar in.
string prepareVersion(const string YAMLVersion) @safePrepare YAML version string for output.
void encodeChar(Writer)(ref Writer writer, in dchar c) @safeEncode an Unicode character for tag directive and write it to writer.
string prepareTagHandle(const string handle) @safePrepare tag directive handle for output.
string prepareTagPrefix(const string prefix) @safePrepare tag directive prefix for output.
string prepareTag(in string tag) @safePrepare tag for output.
string prepareAnchor(const string anchor) @safePrepare anchor for output.
ScalarAnalysis analyzeScalar(string scalar) @safeAnalyze specifed scalar and return the analysis result.
void writeStreamStart() @safeStart the YAML stream (write the unicode byte order mark).
void writeStreamEnd() @safeEnd the YAML stream.
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.).
void writeIndent() @safeWrite indentation.
void writeLineBreak(const scope char[] data = null) @safeStart new line.
void writeVersionDirective(const string versionText) @safeWrite a YAML version directive.
void writeTagDirective(const string handle, const string prefix) @safeWrite a tag directive.
void nextExpected(string D)() @safe
void nextExpected(EmitterFunction f) @safe
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).
structScalarWriter(Range, CharType)

RAII struct used to write out scalar values.

Fields
dchar.max dcharNoneUsed as "null" UTF-32 character.
Emitter!(Range, CharType) * emitter_Emitter used to emit the scalar.
string text_UTF-8 encoded text of the scalar to write.
bool split_Can we split the scalar into multiple lines?
bool spaces_Are we currently going over spaces in the text?
bool breaks_Are we currently going over line breaks in the text?
size_t startByte_Start and end byte of the text range we're currently working with.
size_t nextEndByte_End byte of the text range including the currently processed character.
long startChar_Start and end character of the text range we're currently working with.
Methods
int opCmp(ref Emitter!(Range, CharType)) @disable
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.
dchar nextChar() @property pure @safeGet next character and move end of the text range to it.
dchar charAtStart() @property const pure @safeGet character at start of the text range.
bool tooWide() @property const pure @safe nothrowIs the current line too wide?
size_t determineBlockHints(char[] hints, uint bestIndent) const pure @safeDetermine hints (indicators) for block scalar.
void initBlock(const char indicator) @safeInitialize for block scalar writing with specified indicator.
void writeCurrentRange(const Flag!"UpdateColumn" updateColumn) @safeWrite out the current text range.
void writeLineBreaks() @safeWrite line breaks in the text range.
void writeStartLineBreak() @safeWrite line break if start of the text range is a newline.
void writeIndent(const Flag!"ResetSpace" resetSpace) @safeWrite indentation, optionally resetting whitespace/indentation flags.
void updateRangeStart() pure @safe nothrowMove start of text range to its end.
void updateBreaks(in dchar c, const Flag!"UpdateSpaces" updateSpaces) pure @safeUpdate the line breaks flag, optionally updating the spaces flag.
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.