serializer.yamlstream - Palamecia/mint GitHub Wiki
Module
load serializer.yamlstream
This module provides the Serializer.YamlStream class which allow to read and write YAML documents.
Packages
Classes
Serializer.YamlAlias
This class represents a YAML alias. An alias node is denoted by the *
indicator. The alias refers to the most recent preceding node having the same
anchor.
Public members
Modifiers | Member | Description |
---|---|---|
const |
data | Returns the data of the referenced node. |
const |
new | Creates a new alias node. The document parameter must be the instance of Se... |
const |
node | Returns the referenced node. |
const |
toString | Returns the string representation of the alias. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
anchor | Internal anchor. |
final |
document | Internal document. |
Serializer.YamlComment
This class represents a YAML comment.
Public members
Modifiers | Member | Description |
---|---|---|
const |
new | Creates a new comment for the content described by content . If the conten ... |
const |
toString | Returns the string representation of the comment. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
content | Internal content text. |
Serializer.YamlDirective
This class represents a YAML directive. Each document may be associated with a set of directives. A directive has a name and an optional sequence of parameters.
Public members
Modifiers | Member | Description |
---|---|---|
const |
getComment | Returns the comment associated to the directive or none if no comment were ... |
const |
getName | Returns the name of the directive. |
const |
getParameters | Returns the parameters sequence of the directive. |
const |
new | Creates a new directive with the given name name and parameters parameter... |
const |
setComment | Sets the comment associated to the directive. |
const |
toString | Returns the string representation of the processing instruction. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
comment | Internal comment. |
final |
name | Internal directive name. |
final |
parameters | Internal parameters set. |
Serializer.YamlDocument
This class represents a YAML document. A YAML document starts with the
sequence ---
and ends with an optional sequence ...
or with the begining
of the next document or the end of the stream. Each document is completely
independent from the rest.
Public members
Modifiers | Member | Description |
---|---|---|
const |
append | Appends node at the end of the document. |
const |
data | Returns the content of the document as a sequence of hashes and arrays corres... |
const |
getAlias | Returns the alias target of the anchor anchor. |
const |
getRootNode | Returns the root node of the document. |
const |
isEmpty | Returns true if the document is empty; otherwise returns false . |
const |
remove | Removes node from the document. |
const |
setAlias | Sets the alias target of the anchor anchor to node . |
const |
setRootNode | Sets the root node of the document. |
const |
toString | Returns the string representation of the document. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
aliases | Internal aliases. |
final |
comments | Internal comment. |
final |
root | Internal root node. |
Serializer.YamlMapping
This class represents a YAML mapping. The content of a mapping node is an unordered set of key/value node pairs, with the restriction that each of the keys is unique. YAML places no further restrictions on the nodes. In particular, keys may be arbitrary nodes, the same node may be used as the value of several key/value pairs and a mapping could even contain itself as a key or a value.
Public members
Modifiers | Member | Description |
---|---|---|
const |
clear | Resets the mapping. |
const |
data | Returns the content of the mapping as a sequence of hashes and arrays corresp... |
const |
in | Returns true if the mapping contains key ; otherwise returns false . |
const |
insert | Inserts the node node with the key given by key . If key is already cont... |
const |
isEmpty | Returns true if the mapping is empty; otherwise returns false . |
const |
new | Creates a new empty mapping node. |
const |
remove | Removes key and the associated value from the document. |
const |
size | Returns the number of elements in the mapping. |
const |
toHash | Returns the content of the mapping as a sequence of hashes and arrays corresp... |
const |
toString | Returns the string representation of the mapping for the indentation level gi... |
Private members
Modifiers | Member | Description |
---|---|---|
final |
children | Internal child node mapping. |
Serializer.YamlScalar
This class represents a YAML scalar. The content of a scalar node is an opaque datum that can be presented as a series of zero or more Unicode characters.
Public members
Modifiers | Member | Description |
---|---|---|
const |
!= | Returns false if other is the same node than self ; otherwise returns ``... |
const |
== | Returns true if other is the same node than self ; otherwise returns f ... |
const |
data | Returns the content of the scalar as an instance of string, number, boolean, ... |
const |
getTag | Returns the Serializer.YamlTag of the node. |
const |
new | Creates a new empty scalar node. |
const |
setTag | Sets the Serializer.YamlTag of the node. |
const |
toCanonicalForm | Returns the string representation of the scalar in its canonical form. |
const |
toString | Returns the string representation of the scalar. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
tag | Internal tag. |
final |
value | Internal value. |
Serializer.YamlSequence
This class represents a YAML sequence. The content of a sequence node is an ordered series of zero or more nodes. In particular, a sequence may contain the same node more than once. It could even contain itself.
Public members
Modifiers | Member | Description |
---|---|---|
const |
append | Appends node at the end of the sequence. |
const |
clear | Resets the sequence. |
const |
data | Returns the content of the sequence as a sequence of hashes and arrays corres... |
const |
in | Returns true if the sequence contains node ; otherwise returns false . |
const |
indexOf | Returns the index of the node node if contained in the sequence; otherwise ... |
const |
insert | Inserts the node node at the index given by index . If index is negative... |
const |
isEmpty | Returns true if the sequence is empty; otherwise returns false . |
const |
lastIndexOf | Returns the index of the node node if contained in the sequence; otherwise ... |
const |
new | Creates a new empty sequence node. |
const |
remove | Removes node from the sequence. |
const |
size | Returns the number of nodes in the sequence. |
const |
toArray | Returns the content of the sequence as a sequence of hashes and arrays corres... |
const |
toString | Returns the string representation of the sequence for the indentation level g... |
Private members
Modifiers | Member | Description |
---|---|---|
final |
children | Internal child node sequence. |
Serializer.YamlStream
This class class provides a way to read and write YAML documents.
Inherits
Public members
Modifiers | Member | Description |
---|---|---|
override const |
<< | Writes the content of data to the stream using the write function, then ret... |
override const |
>> | Reads an object from the stream and stores it in data , then returns a refer... |
override const |
read | Reads the content of the stream and return it as an instance of Serializer.Ya... |
override const |
write | Writes the content of data to the stream. |
Private members
Modifiers | Member | Description |
---|---|---|
class |
Parser | This class provides a parser to convert a YAML stream to objects. |
Serializer.YamlStream.Parser
This class provides a parser to convert a YAML stream to objects.
Public members
Modifiers | Member | Description |
---|---|---|
const |
new | Creates a new parser on the stream given by stream . |
const |
parse | Returns an instance of Serializer.YamlDocument corresponding to the next YAML... |
Private members
Modifiers | Member | Description |
---|---|---|
final |
c | Internal last read character. |
final const |
discardToken | Discards the last token that was read. The same token will then be returned b... |
final |
discarded | Internal discarded state. |
final |
document | Internal current document node. |
final const |
getColumnNumber | Returns the input stream current column number. |
final const |
getLineNumber | Returns the input stream current line number. |
final const |
nextChar | Returns the next character of the stream. |
final const |
nextToken | Returns the next token of the stream. A token is a character that does not ma... |
final const |
parseBlockString | Reads the content of a YAML block string. An instance of Serializer.DocumentS... |
final const |
parseDocument | Reads the content of a document. Returns an instance of Serializer.YamlDocume... |
final const |
parseDoubleQuotedString | Reads the content of a YAML double quoted string. An instance of Serializer.D... |
final const |
parseInlineMapping | Reads the content of a YAML inline mapping. An instance of Serializer.Documen... |
final const |
parseInlineSequence | Reads the content of a YAML inline sequence. An instance of Serializer.Docume... |
final const |
parseMapping | Reads the content of a YAML mapping. An instance of Serializer.DocumentStream... |
final const |
parseMergedMapping | Reads the content of a YAML merged mapping. An instance of Serializer.Documen... |
final const |
parseNewLine | Reads the content of a new line. An instance of Serializer.DocumentStream.Inv... |
final const |
parseNode | Reads the content of a YAML node. An instance of Serializer.DocumentStream.In... |
final const |
parseSequence | Reads the content of a YAML sequence. An instance of Serializer.DocumentStrea... |
final const |
parseSingleQuotedString | Reads the content of a YAML single quoted string. An instance of Serializer.D... |
final const |
parseStream | Begins the parsin of the stream. Returns an instance of Serializer.YamlDirect... |
final const |
parseUnquotedString | Reads the content of a YAML unquoted string. An instance of Serializer.Docume... |
final const |
readUntil | Reads data from the stream until delim is found, and returns it. The read i... |
final |
stream | Internal stream object. |
final const |
yamlToScalar | Converts an identifier to an instance of Serializer.YamlScalar. |
Serializer.YamlTag
This class represents a YAML tag. The tag property identifies the type
of the native data structure presented by the node. A tag is denoted by the
!
indicator.
Default available tags are null
, bool
, int
, float
, str
, map
,
seq
, binary
and timestamp
.
Public members
Modifiers | Member | Description |
---|---|---|
class |
InvalidTag | This class provides the context of an invalid tag exception. |
const |
convert | Returns the data of the value identified identifier converted using the des... |
const |
getName | Returns the name of the tag. |
const |
new | Creates a new tag property for the type described by type . If the type pa... |
@ const |
registerType | Register a custom tag name identified by type_name . The converter must be... |
const |
toString | Returns the string representation of the tag. |
Private members
Modifiers | Member | Description |
---|---|---|
@ |
g_converters | Internal conversion functions. |
final |
name | Internal type name. |
Serializer.YamlTag.InvalidTag
This class provides the context of an invalid tag exception.
Inherits
Public members
Modifiers | Member | Description |
---|---|---|
const |
getTag | Returns the tag that raised the error. |
const |
new | Create a new instance of the exception for the given tag . |
const |
toString | Returns the exception informations as a string. |
Private members
Modifiers | Member | Description |
---|---|---|
final |
tag | Internal tag. |
Descriptions
Serializer.YamlAlias.anchor
''
Internal anchor.
Serializer.YamlAlias.data
def (const self)
Returns the data of the referenced node.
Serializer.YamlAlias.document
null
Internal document.
Serializer.YamlAlias.new
def (self, document, anchor)
Creates a new alias node. The document
parameter must be the instance
of Serializer.YamlDocument that contains the anchor. The anchor
parameter must be the anchor used by the alias.
Serializer.YamlAlias.node
def (const self)
Returns the referenced node.
Serializer.YamlAlias.toString
def (const self)
Returns the string representation of the alias.
Serializer.YamlComment.content
''
Internal content text.
Serializer.YamlComment.new
def (self, content)
Creates a new comment for the content described by content
.
If the content
parameter is an instance of Serializer.YamlComment,
this instance is returned; otherwise content
is cast to string to get
the text of the comment.
Serializer.YamlComment.toString
def (const self, level = 0)
Returns the string representation of the comment.
Serializer.YamlDirective.comment
none
Internal comment.
Serializer.YamlDirective.getComment
def (const self)
Returns the comment associated to the directive or none
if no comment
were specified.
Serializer.YamlDirective.getName
def (const self)
Returns the name of the directive.
Serializer.YamlDirective.getParameters
def (const self)
Returns the parameters sequence of the directive.
Serializer.YamlDirective.name
''
Internal directive name.
Serializer.YamlDirective.new
def (self, name, parameters)
Creates a new directive with the given name
name and parameters
parameters sequence.
Serializer.YamlDirective.parameters
[]
Internal parameters set.
Serializer.YamlDirective.setComment
def (self, comment)
Sets the comment associated to the directive.
Serializer.YamlDirective.toString
def (const self)
Returns the string representation of the processing instruction.
Serializer.YamlDocument.aliases
{}
Internal aliases.
Serializer.YamlDocument.append
def (self, node)
Appends node
at the end of the document.
Serializer.YamlDocument.comments
[]
Internal comment.
Serializer.YamlDocument.data
def (const self)
Returns the content of the document as a sequence of hashes and arrays corresponding to the YAML mappings and sequences.
Serializer.YamlDocument.getAlias
def (const self, anchor)
Returns the alias target of the anchor
anchor.
Serializer.YamlDocument.getRootNode
def (const self)
Returns the root node of the document.
Serializer.YamlDocument.isEmpty
def (const self)
Returns true
if the document is empty; otherwise returns false
.
Serializer.YamlDocument.remove
def (self, node)
Removes node
from the document.
Serializer.YamlDocument.root
none
Internal root node.
Serializer.YamlDocument.setAlias
def (self, anchor, node)
Sets the alias target of the anchor
anchor to node
.
Serializer.YamlDocument.setRootNode
def (self, node)
Sets the root node of the document.
Serializer.YamlDocument.toString
def (const self)
Returns the string representation of the document.
Serializer.YamlMapping.children
{}
Internal child node mapping.
Serializer.YamlMapping.clear
def (self)
Resets the mapping.
Serializer.YamlMapping.data
def (const self)
Returns the content of the mapping as a sequence of hashes and arrays corresponding to the YAML mappings and sequences.
Serializer.YamlMapping.in
def (const self, const key)
Returns true
if the mapping contains key
; otherwise returns
false
.
def (const self)
Returns an iterator on each elements in the mapping.
Serializer.YamlMapping.insert
def (self, key, node)
Inserts the node node
with the key given by key
. If key
is
already contained in the mapping, the associated value is updated.
Serializer.YamlMapping.isEmpty
def (const self)
Returns true
if the mapping is empty; otherwise returns false
.
Serializer.YamlMapping.new
def (self)
Creates a new empty mapping node.
def (self, content)
Creates a new mapping node for the mapping given by content
.
Serializer.YamlMapping.remove
def (self, key)
Removes key
and the associated value from the document.
Serializer.YamlMapping.size
def (const self)
Returns the number of elements in the mapping.
Serializer.YamlMapping.toHash
def (const self)
Returns the content of the mapping as a sequence of hashes and arrays corresponding to the YAML mappings and sequences.
Serializer.YamlMapping.toString
def (const self, level = 0)
Returns the string representation of the mapping for the indentation
level given by level
.
Serializer.YamlScalar.!=
def (const self, const other)
Returns false
if other
is the same node than self
; otherwise
returns true
.
Serializer.YamlScalar.==
def (const self, const other)
Returns true
if other
is the same node than self
; otherwise returns
false
.
Serializer.YamlScalar.data
def (const self)
Returns the content of the scalar as an instance of string, number,
boolean, System.Date or null
corresponding to the YAML value. If an
instance of Serializer.YamlTag is associated to the node, this instance is used
to convert the value to the expected type.
Serializer.YamlScalar.getTag
def (const self)
Returns the Serializer.YamlTag of the node.
Serializer.YamlScalar.new
def (self)
Creates a new empty scalar node.
def (self, value, tag = none)
Creates a new scalar node for the value given by value
. If tag
is a
valid Serializer.YamlTag instance, this tag is used to convert the value
to the expected type.
Serializer.YamlScalar.setTag
def (const self, tag)
Sets the Serializer.YamlTag of the node.
Serializer.YamlScalar.tag
none
Internal tag.
Serializer.YamlScalar.toCanonicalForm
def (const self)
Returns the string representation of the scalar in its canonical form.
Serializer.YamlScalar.toString
def (const self)
Returns the string representation of the scalar.
Serializer.YamlScalar.value
none
Internal value.
Serializer.YamlSequence.append
def (self, node)
Appends node
at the end of the sequence.
Serializer.YamlSequence.children
[]
Internal child node sequence.
Serializer.YamlSequence.clear
def (self)
Resets the sequence.
Serializer.YamlSequence.data
def (const self)
Returns the content of the sequence as a sequence of hashes and arrays corresponding to the YAML mappings and sequences.
Serializer.YamlSequence.in
def (const self, const node)
Returns true
if the sequence contains node
; otherwise returns
false
.
def (const self)
Returns an iterator on each nodes of the sequence.
Serializer.YamlSequence.indexOf
def (const self, node)
Returns the index of the node node
if contained in the sequence;
otherwise returns none
. Searching forward from index position 0
.
def (const self, node, from)
Returns the index of the node node
if contained in the sequence;
otherwise returns none
. Searching forward from index position from
.
Serializer.YamlSequence.insert
def (self, index, node)
Inserts the node node
at the index given by index
. If index
is
negative, the position is relative to the end of the sequence.
Serializer.YamlSequence.isEmpty
def (const self)
Returns true
if the sequence is empty; otherwise returns false
.
Serializer.YamlSequence.lastIndexOf
def (const self, node)
Returns the index of the node node
if contained in the sequence;
otherwise returns none
. Searching backward from the end of the
sequence.
def (const self, node, from)
Returns the index of the node node
if contained in the sequence;
otherwise returns none
. Searching backward from index position from
.
Serializer.YamlSequence.new
def (self)
Creates a new empty sequence node.
def (self, content)
Creates a new sequence node for the sequence given by content
.
Serializer.YamlSequence.remove
def (self, node)
Removes node
from the sequence.
Serializer.YamlSequence.size
def (const self)
Returns the number of nodes in the sequence.
Serializer.YamlSequence.toArray
def (const self)
Returns the content of the sequence as a sequence of hashes and arrays corresponding to the YAML mappings and sequences.
Serializer.YamlSequence.toString
def (const self, level = 0)
Returns the string representation of the sequence for the indentation
level given by level
.
Serializer.YamlStream.<<
def (self, data)
Writes the content of data
to the stream using the write
function, then returns a reference to the stream.
Serializer.YamlStream.>>
def (self, data)
Reads an object from the stream and stores it in data
, then returns a
reference to the stream.
Serializer.YamlStream.Parser.c
none
Internal last read character.
Serializer.YamlStream.Parser.discardToken
def (self)
Discards the last token that was read. The same token will then be returned by the next call to nextToken.
Serializer.YamlStream.Parser.discarded
false
Internal discarded state.
Serializer.YamlStream.Parser.document
none
Internal current document node.
Serializer.YamlStream.Parser.getColumnNumber
def (const self)
Returns the input stream current column number.
Serializer.YamlStream.Parser.getLineNumber
def (const self)
Returns the input stream current line number.
Serializer.YamlStream.Parser.new
def (self, stream)
Creates a new parser on the stream given by stream
.
Serializer.YamlStream.Parser.nextChar
def (self)
Returns the next character of the stream.
Serializer.YamlStream.Parser.nextToken
def (self)
Returns the next token of the stream. A token is a character that does
not match the /\s/
regex.
Serializer.YamlStream.Parser.parse
def (self)
Returns an instance of Serializer.YamlDocument corresponding to the
next YAML document in the stream or none
if no more document is
available.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseBlockString
def (self, token, level, keep_newline, keep_extra_newline, chomp_extra_newline)
Reads the content of a YAML block string.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseDocument
def (self, token)
Reads the content of a document. Returns an instance of
Serializer.YamlDocument corresponding to the YAML document or
none
if no document is available.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseDoubleQuotedString
def (self)
Reads the content of a YAML double quoted string.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseInlineMapping
def (self, inserter)
Reads the content of a YAML inline mapping.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseInlineSequence
def (self, inserter)
Reads the content of a YAML inline sequence.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseMapping
def (self, identifier, level, inserter)
Reads the content of a YAML mapping.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseMergedMapping
def (self, token, level, inserter, mapping)
Reads the content of a YAML merged mapping.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseNewLine
def (self, token, level, inserter)
Reads the content of a new line.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseNode
def (self, token, level, inserter)
Reads the content of a YAML node.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseSequence
def (self, level, inserter)
Reads the content of a YAML sequence.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseSingleQuotedString
def (self)
Reads the content of a YAML single quoted string.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseStream
def (self)
Begins the parsin of the stream. Returns an instance of
Serializer.YamlDirective corresponding to the next directive or an
instance of Serializer.YamlDocument corresponding to the next YAML
document in the stream or none
if no more document is available.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.parseUnquotedString
def (self, token, level)
Reads the content of a YAML unquoted string.
An instance of Serializer.DocumentStream.InvalidDocument is raised on error.
Serializer.YamlStream.Parser.readUntil
def (self, delim)
Reads data from the stream until delim
is found, and returns it.
The read index of the stream is then moved to the first character
identified by delim
.
Serializer.YamlStream.Parser.stream
null
Internal stream object.
Serializer.YamlStream.Parser.yamlToScalar
def (self, identifier, tag = none)
Converts an identifier to an instance of Serializer.YamlScalar.
Serializer.YamlStream.read
def (self)
Reads the content of the stream and return it as an instance of Serializer.YamlDocument. If the content of the stream is not a valid YAML, an instance of Serializer.DocumentStream.InvalidDocument is raised.
Serializer.YamlStream.write
def (self, data)
Writes the content of data
to the stream.
Serializer.YamlTag.InvalidTag.getTag
def (const self)
Returns the tag that raised the error.
Serializer.YamlTag.InvalidTag.new
def (self, tag)
Create a new instance of the exception for the given tag
.
Serializer.YamlTag.InvalidTag.tag
null
Internal tag.
Serializer.YamlTag.InvalidTag.toString
def (const self)
Returns the exception informations as a string.
Serializer.YamlTag.convert
def (self, identifier)
Returns the data of the value identified identifier
converted using
the described type. If the described type is not a valid YAML type, an
instance of Serializer.YamlTag.InvalidTag is raised.
Serializer.YamlTag.g_converters
none
Internal conversion functions.
Serializer.YamlTag.getName
def (const self)
Returns the name of the tag.
Serializer.YamlTag.name
''
Internal type name.
Serializer.YamlTag.new
def (self, type)
Creates a new tag property for the type described by type
.
If the type
parameter is an instance of Serializer.YamlTag, this
instance is returned; otherwise type
is cast to string to get the type
name.
Serializer.YamlTag.registerType
def (type_name, converter)
Register a custom tag name identified by type_name
. The converter
must be a function taking one string parameter to convert it into target
data type.
Serializer.YamlTag.toString
def (const self)
Returns the string representation of the tag.