rookie_yaml
library
Classes
AliasNode
Introduction
YamlSourceNodes
Anchors and Aliases
A node that is a pointer to another node.
BytesToScalar <T >
Bytes To Scalar
A delegate that accepts the bytes/code units of a scalar from the underlying
SourceIterator .
A class that dumps comments based on the CommentStyle .
ConcreteNode <T >
Dumping Types
A shallow sandboxed dumpable view of a Dart type that is not an alias.
ContentResolver <O >
Types of Tags
Lazy Scalar Resolvers
Resolves a Scalar 's parsed content and requires the function to return
null if mapping fails. This allows the parser to provide a (partial) kind.
Avoid throwing within the mapping function.
CustomResolver <S , T >
Resolvers
Custom Resolvers
A resolver for any Dart object dumped as YAML.
CustomTriggers
Resolvers
Custom Resolvers
Bytes To Scalar
Object from Sequence
Object from Mapping
A class with callbacks to some of the inner workings of the parser.
CustomValue <T >
A value inferred using a custom ContentResolver tag.
DartValue <T >
Any Dart value that is not an int or null.
Directive
YamlDocument
A valid YAML directive
DocumentParser <Doc , R >
A YamlDocument parser.
DumpableAsAlias
Dumping Types
An alias to an anchor that has been declared.
DumpableNode <T >
Dumping Types
An object that can be dumped.
GlobalTag <T >
YamlDocument
Types of Tags
Declaring Tags in Code
Describes a tag shorthand notation for specifying node tags. It must begin
with the %TAG directive.
IterableDumper
Dumping Sequence
A dumper for an Iterable .
MapDumper
Dumping Mapping
A dumper for a Map .
Mapping
Introduction
YamlSourceNodes
A YAML Map which mirrors an actual Dart Map in equality and shape.
MappingToObject <K , V , T >
Object from Mapping
A delegate that directly maps a YAML map to an object T and accepts an
object key K and object value V. No intermediate Map is constructed.
Both the key and value are presented at the same time after the complete
entry has been parsed. You must override the parsed method.
NodeKind
Custom Resolvers
Represents the kind of node to be parsed.
NodeProperty
Custom Resolvers
Node anchor and/or tag.
NodeSpan
Offset information for a parsed YAML node.
NodeTag <T >
Types of Tags
Declaring Tags in Code
Represents a TagShorthand shorthand that has (not) been resolved to a
GlobalTag prefix after it has been parsed.
NullView
A wrapper class for null. While it may seem counterintuitive, some
nulls in YAML cannot be represented/non-existent but are implicit such
as:
ObjectDumper
Dumping Scalars
Dumping Sequence
Dumping Mapping
A class used to dump objects.
ObjectFromIterable <E , T >
Object from Sequence
A resolver that creates a delegate that accepts elements.
ObjectFromMap <K , V , T >
Object from Mapping
A resolver that creates a delegate that accepts a key-value pair.
ObjectFromScalarBytes <T >
Bytes To Scalar
A resolver that creates a delegate which accepts the bytes/code units
representing a scalar.
ParsedProperty
Custom Resolvers
A node's parsed property.
ReservedDirective
YamlDocument
Represents any unknown directive which YAML, by default, reserves for
future use. Typically any that is not a YamlDirective or a GlobalTag .
ResolvedTag
Types of Tags
Declaring Tags in Code
Custom Resolvers
Represents any Tag resolved to a GlobalTag prefix or declared in
verbatim as a VerbatimTag
Scalar <T >
Introduction
YamlSourceNodes
Any value that is not a Sequence or Mapping .
ScalarDumper
Dumping Scalars
A persistent dumper for scalars.
ScalarResolver <O >
Lazy Scalar Resolvers
A resolver for a Scalar . The type emitted by this resolver lives within
the scalar itself or acts as the type inferred when directly parsed as a
Dart object.
ScalarValue <T >
A wrapper class that safely wraps types inferred from content parsed
within a scalar.
Sequence
Introduction
YamlSourceNodes
A YAML List which mirrors an actual Dart List in equality and shape.
SequenceToObject <E , T >
Object from Sequence
A delegate that maps an iterable to an object T and accepts an object E.
No intermediate List or Iterable is constructed. You must override the
parsed method.
SourceIterator
An iterator that iterates over any parsable YAML source string.
SourceLine
Represents a single line's source information with an inclusive start index
and end index.
SourceNodeTriggers
Triggers for loading YamlSourceNode s.
SpecificTag <T >
Types of Tags
Declaring Tags in Code
Represents a Tag that can be represented as a GlobalTag or
TagShorthand . YAML requires a parsed node to be resolved as a
SpecificTag or be represented as is as a VerbatimTag .
Tag
Introduction to Tags
Describes the kind of native data structure represented by a YAML node.
TagHandle
Introduction to Tags
Types of Tags
Declaring Tags in Code
Represents a prefix for any Tag declared in YAML
TagShorthand
Types of Tags
Declaring Tags in Code
A tag shorthand for a node that may (not) be resolved to a GlobalTag .
UnicodeIterator
A SourceIterator that iterates the utf16/utf32 unicode points of a source
string/file.
VerbatimTag
Types of Tags
Declaring Tags in Code
Represents a tag explicitly declared in its raw form. Never resolved to
GlobalTag
A comment parsed in a document
YamlDirective
YamlDocument
Specifies the version a YAML document conforms to.
YamlDocument
YamlDocument
Dumping YAML Documents
A document representing the entire YAML string or a single
scalar/collection node within a group of documents in YAML.
YamlDumper
A yaml dumper.
YamlSafeInt
A safe representation of an integer parsed from a YAML source string.
This wrapper guarantees that an integer will be dumped in the same form
as it was parsed.
YamlSourceNode
Introduction
YamlSourceNodes
A node parsed from a YAML source string.
Functions
deepCopyReference (Object ? object )
→ Object ?
Recursively copies all elements of a Map or List
dumpableObject (Object ? object , {bool unpackAnchor = false })
→ DumpableNode <Object ? >
Dumping Types
Creates a dumpable node view of the object.
dumpableType <T > (T object )
→ ConcreteNode <T >
Dumping Types
Creates a dumpable concrete view of the object. In this view, the object
can accept node properties.
dumpObject (Object ? object , {required YamlDumper dumper , int indent = 0 , bool includeYamlDirective = false , Iterable <Directive > ? directives , OnProperties ? objectProperties , bool includeGlobalTags = true , bool includeDocumendEnd = false })
→ String
Dumping Scalars
Dumping Sequence
Dumping Mapping
Dumping Types
Dumping YAML Documents
Dumps an object with the specified indent. Uses the dumper provided.
flowInBlockDumper <T > ({required T dumper (), required DumpedCollection dump (T dumper ), required void onDump (DumpedCollection dumped ) })
→ void
Dumps an flow node embedded within a block node that is being iteratively
rather than recursively.
getLineCount (RuneOffset start , RuneOffset end )
→ int
Number of lines from start to end. This assumes the end is exclusive
and its line is ignored.
identity <I > (I object )
→ I
Expands an object as itself.
isGenericNode (ParsedProperty ? property )
→ bool
Custom Resolvers
Whether the node with the property should be parsed as a generic !!map
or !!seq or !!str.
isYamlMapTag (TagShorthand tag )
→ bool
Supported Schema Tags
Whether a tag is a valid Map or Mapping tag.
isYamlScalarTag (TagShorthand tag )
→ bool
Supported Schema Tags
Whether a tag is a valid Scalar tag.
isYamlSequenceTag (TagShorthand tag )
→ bool
Supported Schema Tags
Whether a tag is a valid List or Set or Sequence tag.
isYamlTag (TagShorthand tag )
→ bool
Supported Schema Tags
Whether a tag is valid tag in the yaml schema. A yaml tag uses the
TagHandleVariant.secondary handle.
iterateAndChunk (SourceIterator iterator , {required void onChar (int char ), required bool exitIf (int ? previous , int current ) })
→ OnChunk
Reads and buffers all characters that fail the exitIf predicate or until
the end of the current line, that is, until the line's lineFeed is emitted
and no more characters are present in the line (whichever condition comes
first).
iteratedIsEOF (int ? char )
→ bool
Whether a char from a SourceIterator is not a valid unicode character.
loadAllDocuments (YamlSource source , {bool throwOnMapDuplicate = false , List <ScalarResolver <Object ? > > ? resolvers , void logger (bool isInfo , String message )? })
→ List <YamlDocument >
YamlDocument
Loads every document. Each document's root node will always be a
YamlSourceNode .
loadAsDartObjects (YamlSource source , {bool dereferenceAliases = false , bool throwOnMapDuplicate = true , CustomTriggers ? triggers , void logger (bool isInfo , String message )? })
→ List <Object ? >
Built-in Dart types
Loads every document's root node as a Dart object. This function
guarantees that every object returned will be a primitive Dart type or a
type inferred via the triggers provided.
loadDartObject <T > (YamlSource source , {bool dereferenceAliases = false , bool throwOnMapDuplicate = true , CustomTriggers ? triggers , void logger (bool isInfo , String message )? })
→ T?
Built-in Dart types
Loads the first node as a Dart object. This function guarantees that
every object returned will be a primitive Dart type or a type inferred via
the triggers provided. A nullable T is returned in case the object could
not be parsed.
loadNodes (YamlSource source , {bool throwOnMapDuplicate = false , List <ScalarResolver <Object ? > > ? resolvers , void logger (bool isInfo , String message )? })
→ Iterable <YamlSourceNode >
YamlSourceNodes
Loads every document's root node as a YamlSourceNode .
loadYamlNode <T extends YamlSourceNode > (YamlSource source , {bool throwOnMapDuplicate = false , List <ScalarResolver <Object ? > > ? resolvers , void logger (bool isInfo , String message )? })
→ T?
YamlSourceNodes
Loads the first document's root as a YamlSourceNode
skipWhitespace (SourceIterator iterator , {bool skipTabs = false , int ? max , List <int > ? previouslyRead })
→ List <int >
Skips any whitespace and returns the whitespace characters skipped. If
skipTabs is true, then tabs \t will also be skipped.
takeFromIteratorUntil <T > (SourceIterator iterator , {required bool includeCharAtCursor , required T mapper (int char ), required void onMapped (T mapped ), required bool stopIf (int count , int possibleNext ) })
→ int
Returns the number of characters taken until a character failed the
stopIf test, that is, evaluated to false.
throwForCurrentLine (SourceIterator iterator , {required String message , RuneOffset ? end })
→ Never
Throw a YamlParseException with the current active line whose characters
are being iterated. The line is highlighted from the start to the end.
throwWithApproximateRange (SourceIterator iterator , {required String message , required RuneOffset current , required int charCountBefore })
→ Never
Throws a YamlParseException for a source string with an end offset at the
current offset and a start offset approximately at least charCountBefore
behind.
throwWithRangedOffset (SourceIterator iterator , {required String message , required RuneOffset start , required RuneOffset end })
→ Never
Throws a YamlParseException for a source string with the start and end
offset specified.
throwWithSingleOffset (SourceIterator iterator , {required String message , required RuneOffset offset })
→ Never
Throws a YamlParseException pointing to a single char at the specified
offset.
unwrappedDumpable (DumpableNode <Object ? > dumpable , {required void onIterable (Iterable <Object ? > iterable ), required void onMap (Map <Object ? , Object ? > map ), required void onScalar () })
→ void
Unwraps a wrapped dumpable object and calls the relevant callback.
yamlSourceNodeDeepEqual (YamlSourceNode thiz , YamlSourceNode that )
→ bool
YamlSourceNodes
Checks if 2 YamlSourceNode are equal based on the YAML spec.
Typedefs
AdvancedResolvers
= Map <TagShorthand , CustomResolver <Object , Object ? > >
A map with CustomResolver s associated with a local tag.
AfterCollection <T >
= OnResolvedObject <NodeStyle , T >
Called when a custom object from a MappingToObject or SequenceToObject
has been parsed completely.
AfterScalar <T >
= OnResolvedObject <ScalarStyle , T >
Called when a custom object from a ScalarLikeDelegate has been parsed
completely.
AliasFunction <Ref >
= Ref Function(String alias , Ref reference , NodeSpan nodeSpan )
A builder function for an Alias or any referenced Dart-built in type.
AsLocalTag
= String ? Function(ResolvedTag ? tag )
A callback that formats a ResolvedTag and returns a local/verbatim tag
that can be dumped before the object.
CharWriter
= void Function(int char )
Bytes To Scalar
Callback for writing utf code units from a SourceIterator .
Compose
= DumpableNode <Object ? > Function(Object ? object )
Callback for creating a DumpableNode .
DocumentBuilder <Doc , R >
= Doc Function(ParsedDirectives directives , DocumentInfo documentInfo , RootNode <R > rootNode )
Callback for creating a document with the current parser's information.
DocumentInfo
= ({YamlDocType docType , bool hasExplicitEnd , bool hasExplicitStart , int index } )
Contains information about a document's position in the YAML bytes/string
and its type.
DumpedCollection
= ({bool applyTrailingComments , String node , bool preferExplicit } )
Information about a dumped Iterable or Map .
DumpedScalar
= ({bool isMultiline , String node , int tentativeOffsetFromMargin } )
A scalar dumped.
LineInfo
= ({RuneOffset current , RuneOffset start } )
Represents the active line's span information. This is intentionally
different from RuneSpan because we prefer to iterate the source string
lazily and only split it when we encounter a \n terminator.
MapDuplicateHandler
= void Function(RuneOffset keyStart , RuneOffset keyEnd , String message )
A callback for handling map duplicates
ObjectProperties
= ({Map <String , Object ? > anchors , Map <TagHandle , GlobalTag > globalTags } )
Anchors and GlobalTag s obtained from a dumped object.
OnChunk
= ({int ? charOnExit , bool sourceEnded } )
Represents information returned after a call to bufferChunk method
of the SourceIterator
OnCustomList <E , T >
= OnObject <T , SequenceToObject <E , T > >
Callback that creates a SequenceToObject .
OnCustomMap <K , V , T >
= OnObject <T , MappingToObject <K , V , T > >
Callback that creates a MappingToObject .
OnCustomScalar <T >
= OnObject <T , BytesToScalar <T > >
Callback that creates a ScalarLikeDelegate.
OnObject <T , D extends ObjectDelegate<T > >
= D Function()
Template callback for an object T using a parsing delegate D.
OnProperties
= void Function(Iterable <MapEntry <TagHandle , GlobalTag > > tags , Iterable <(String , Object ? ) > anchors )
Callback for properties captured after a YamlDumper has fully dumped an
object.
OnResolvedObject <S , T >
= void Function(S style , T object , String ? anchor , NodeSpan span )
Called when a custom object T of style S has been completely parsed.
ParsedDirectives
= ({Iterable <GlobalTag > tags , List <ReservedDirective > unknown , YamlDirective ? version } )
Contains all parsed Directive s of a document.
PushAnchor
= void Function(String ? anchor , DumpableNode <Object ? > object )
A callback for updating an anchor if present.
ResolverCreator <R >
= ContentResolver <R > Function(NodeTag tag )
Callback for creating a ContentResolver tag.
RootNode <T >
= ({Map <String , T > anchors , List <YamlComment > comments , T root } )
Contains information about the document's root yaml node and any comments
parsed within the document. YAML spec bluntly states that a comment should
not be associated with a node.
RuneOffset
= ({int columnIndex , int lineIndex , int offset } )
Offset information.
RuneSpan
= ({RuneOffset end , RuneOffset start } )
A chunk of a YAML source.
ScalarFunction <T >
= YamlObjectBuilder<ScalarStyle , ScalarValue <Object ? > , T >
A builder function for a scalar or a Dart built-in type that is not a Map
or List
YamlCollectionBuilder <O >
= YamlObjectBuilder<NodeStyle , Object ? , O >
A constructor for collection-like builders.
Exceptions / Errors
YamlParseException
Represents an exception throw when parsing of a YAML source string fails.