The YAML_STREAM_SEQUENCE function creates a new YAML_Stream_Sequence object, which can be used to hold a complete YAML document with a top-level sequence of items. Each item consists of variables of type YAML_Map, YAML_Sequence, YAML_Value, YAML_Alias, Hash, List, or a regular IDL array or scalar, including !NULL. YAML_Stream_Sequence is a subclass of YAML_Sequence, and inherits all of the methods and properties of that class.

Note: Printing a YAML_Stream_Sequence object will automatically call YAML_SERIALIZE and the output will be in YAML format.

Example


Create a YAML_Stream_Sequence and print out in YAML format:

stream = YAML_Stream_Sequence()
stream.comments = 'my yaml comment'
stream.Add, YAML_Sequence(1, 2)
stream.Add, YAML_Map('test', 123)
print, stream

In the output, note the three dashes ---, indicating the start of the document:

# my yaml comment
---
- - 1
- 2
- test: 123

If you parse a YAML stream with a single document containing a sequence, then the result will be a YAML_Stream_Sequence. For example:

yaml = [ $
'---', $
'- 123', $
'- hello']
yp = yaml_parse(yaml)
help, yp, yp[0], yp[1]

IDL prints:

YP              YAML_STREAM_SEQUENCE  <ID=7  NELEMENTS=2>
<Expression>    LONG64    =                    123
<Expression>    STRING    = 'hello'

Syntax


Result = YAML_Stream_Sequence( [Value1, Value2, ... Valuen])

Return Value


Returns a reference to a newly-created YAML_Stream_Sequence object.

Arguments


Valuen

Each Value argument can be a variable or expression of type YAML_Map, YAML_Sequence, YAML_Value, Hash, List, or a regular IDL array or scalar, including !NULL. If no Value argument is supplied, an empty YAML_Stream_Sequence is returned.

Note: See YAML_SERIALIZE for the list of allowed IDL types and their corresponding YAML type.

Keywords


None

Properties


All properties can be set and retrieved using the dot "." operator.

COMMENTS

Set this property to a string or string array containing the global YAML comments for this stream. This will include any comments that start with a "#" at the beginning of the line, as well as any "%YAML" lines. For example:

yp = yaml_stream_sequence()
yp.Add, 123
yp.comments = ['My File', '%YAML 1.1']
print, yaml_serialize(yp)

IDL prints:

# My File
%YAML 1.1
---
- 123

Conversely, when a YAML stream gets parsed, if there are any global comments, then the resulting YAML_Stream will have the COMMENT property set. For example:

yaml = [ $
'# YAML is fun', $
'%YAML 1.1', $
'---', $
'- 123']
yp = yaml_parse(yaml)
help, yp
print, yp.comments

IDL prints:

YP              YAML_STREAM_SEQUENCE  <ID=14  NELEMENTS=1>
YAML is fun
%YAML 1.1

Note: The "#" character will automatically be prepended to comments when serializing, and will automatically be removed when parsing.

GLOBAL_TAGS

Set this property to a string or string array containing up to four global YAML %TAG values for this stream. For example:

stream = YAML_Stream_Sequence(123, 'abc')
stream.global_tags = '!idl! tag:rsinc.com,1977:'
print, stream

IDL prints:

%TAG !idl! tag:rsinc.com,1977:
---
- 123
- abc

Conversely, when a YAML stream gets parsed, if there are any global tags, then the resulting YAML_Stream_Sequence will have the GLOBAL_TAGS property set. For example:

yaml = [ $
'%TAG !idl! tag:rsinc.com,1977:', $
'---', $
'- abc']
yp = yaml_parse(yaml)
help, yp, yp.global_tags

IDL prints:

YP              YAML_STREAM_SEQUENCE  <ID=31  NELEMENTS=1>  GLOBAL_TAGS=1
<Expression>    STRING    = '!idl! tag:rsinc.com,1977:'

Note: You can have a maximum of four global tags.

TAG

Set this property to a string containing the local YAML tag values for this sequence. For example, here we add both a global and a local tag:

stream = YAML_Stream_Sequence()
stream.global_tags = '!idl! tag:rsinc.com,1977:'
stream.tag = 'c'
print, stream

IDL prints:

%TAG !idl! tag:rsinc.com,1977:
--- !idl/abc

Conversely, when a YAML stream gets parsed, if there is a local tag, then the resulting YAML_Stream_Sequence will have the TAG property set. For example:

yaml = [ $
'%TAG !idl! tag:rsinc.com,1977:', $
'--- !idl/abc', $
'- abc']
yp = yaml_parse(yaml)
help, yp, yp.tag

IDL prints:

YP              YAML_STREAM_SEQUENCE  <ID=16  NELEMENTS=1>  TAG='!idl/abc' GLOBAL_TAGS=1
<Expression>    STRING    = '!idl/abc'

Methods and Additional Information

See YAML_Sequence.

Variable Information


HELP

The HELP procedure provides general information:

IDL> stream = YAML_Stream_Sequence(1, 2, 'abc', 4, 5)
IDL> stream.tag = '!idl! tag:rsinc.com,1977:'
IDL> help, stream
STREAM          YAML_STREAM_SEQUENCE  <ID=19  NELEMENTS=5>  TAG='!idl! tag:rsinc.com,1977:'

PRINT and Implied Print

The PRINT procedure and Implied Print serialize the output in YAML format. Using the stream from above:

IDL> print, stream
IDL> stream

In both cases IDL prints:

--- !idl! tag:rsinc.com,1977:
- 1
- 2
- abc
- 4
- 5

Version History


8.9

Introduced

See Also


YAML_Map, YAML_Multidoc, YAML_Sequence, YAML_Stream_Map, YAML_Value, YAML_PARSE, YAML_SERIALIZE