= Chronicle Wire and YAML 2 
:toc: manual
:css-signature: demo
:toc-placement: preamble

= YAML 2 Specifiucation Compliance

Chronicle wire supports a subset of the features available from the YAML 2 specification.
This section lists those features and suggests other ways in Chronicle Wire to define the same
thing.

==  YAML 2 features supported in Chronicle Wire
The list below lists the features of the specification that are implemented in Chronicle Wire.

NOTE: The numbers refer to the section in the YAML 2 specification. See http://yaml.org/spec/1.2/spec.html for more information.

|===============
| Feature                     | Strict YAML Specification Compliance | Equivalent Operations in Chronicle Wire
|Section 2_1, `SequenceOfScalars` | Yes  |
|Section 2_2, `MappingScalarsToScalars` | Yes |
|Section 2_3, `MappingScalarsToSequences` | Yes |
|Section 2_4, `SequenceOfMappings` | No | https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#24-sequence-of-mappings-player-statistics[Section 2.4, Sequence of Mappings]
|Section 2_5, `SequenceOfSequences` | Yes |
|Section 2_6, `MappingOfMappings` | Yes |
|Section 2_7, `TwoDocumentsInAStream` | No | 
https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#27-two-documents-in-a-stream-each-with-a-leading-comment[Section 2.7, Two Documents in a Stream]
|Section 2_8, `PlayByPlayFeed` | No | https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#28-play-by-play-feed-from-a-game[Section 2.8, Play by Play Feed from a Game]
|Section 2_9, `SingleDocumentWithTwoComments` | No | https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#29-single-document-with-two-comments[Section 2.9, Single Document with Two Comments]
|Section 2_10, `NodeAppearsTwiceInThisDocument` | No |
|Section 2_11, `MappingBetweenSequences` | No |
|Section 2_12, `CompactNestedMapping` | No |  https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#212-compact-nested-mapping[Section 2.12, Compact Nested Mapping]
|Section 2_13, `InLiteralsNewlinesArePreserved` | No |
|Section 2_14, `InThefoldedScalars` | No | 
https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#214-in-the-folded-scalars-newlines-become-spaces[Section 2.14, In the folded scalars, newlines become spaces]
|Section 2_15, `FoldedNewlines` | No |
|Section 2_16, `IndentationDeterminesScope` | No | https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#216-indentation-determines-scope[Section 2.16, Indentation determines scope]
|Section 2_17, `QuotedScalars` | No |  https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#217-quoted-scalars[Section 2.17, Quoted Scalars]
|Section 2_18, `Multi_lineFlowScalars` | No |  https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#218-multi-line-flow-scalars[Section 2.18, Multi-line Flow Scalars]
|Section 2_19, `Integers` | Yes |
|Section 2_20, `FloatingPoint` | Yes |
|Section 2_21, `Miscellaneous` | No |   https://github.com/OpenHFT/Chronicle-Wire/blob/master/YAML2SpecificationCompliance.adoc#221-miscellaneous[Section 2.21, Miscellaneous]
|Section 2_22, `Timestamps` | Yes |
|Section 2_23, `VariousExplicitTags` | No |
|Section 2_24, `GlobalTags` | No |
|Section 2_25, `UnorderedSets` | No |
|Section 2_26, `OrderedMappings` | No |
|Section 2_27, `Invoice` | No |
|Section 2_28, `LogFile` | No |
|===============

== Yaml 2 Equivalent Operation in Chronicle-Wire

The section numbering below reflects that of the fix specification - see http://yaml.org/spec/1.2/spec.html

=== 2.4 Sequence of Mappings (player statistics)

.Yaml Spec Example
----
 -
   name: Mark McGwire
   hr:   65
   avg:  0.278
 -
   name: Sammy Sosa
   hr:   63
   avg:  0.288
----

.Chronicle-Wire equivalent:
----
[
    {
      name: Mark McGwire,
      hr:   65,
      avg:  0.278
    },
    {
      name: Sammy Sosa,
      hr:   63,
      avg:  0.288
    }
]
----


=== 2.7 Two Documents in a Stream (each with a leading comment)

.Yaml Spec Example
----
# Ranking of 1998 home runs
---
- Mark McGwire
- Sammy Sosa
- Ken Griffey

# Team ranking
---
- Chicago Cubs
- St Louis Cardinals
----

.Chronicle-Wire equivalent:

----
[
# Ranking of 1998 home runs
- Mark McGwire
- Sammy Sosa
- Ken Griffey
,
# Team ranking
- Chicago Cubs
- St Louis Cardinals
]
----

=== 2.8 Play by Play Feed from a Game

.Yaml Spec Example
[source,yaml]
----
---
time: 20:03:20
player: Sammy Sosa
action: strike (miss)
...
---
time: 20:03:47
player: Sammy Sosa
action: grand slam
...
----

.Chronicle-Wire equivalent:
----
[
  {
    time: 20:03:20
    player: Sammy Sosa
    action: strike (miss)
  },
  {
    time: 20:03:47
    player: Sammy Sosa
    action: grand slam
  }
]
----


=== 2.9 Single Document with Two Comments

.Yaml Spec Example
----
---
hr: # 1998 hr ranking
  - Mark McGwire
  - Sammy Sosa
rbi:
  # 1998 rbi ranking
  - Sammy Sosa
  - Ken Griffey
----

.Chronicle-Wire equivalent:
----
hr: # 1998 hr ranking
  - Mark McGwire
  - Sammy Sosa
rbi:
  # 1998 rbi ranking
  - Sammy Sosa
  - Ken Griffey
----

=== 2.12 Compact Nested Mapping

.Yaml Spec Example
[source,yaml]
----
---
# Products purchased
- item    : Super Hoop
  quantity: 1
- item    : Basketball
  quantity: 4
- item    : Big Shoes
  quantity: 1
----

.Chronicle-Wire equivalent:
[source,yaml]
----
# Products purchased
-  {item: Super Hoop,
    quantity: 1}
-  {item: Basketball,
    quantity: 4}
-  {item: Big Shoes,
    quantity: 1}
----


=== 2.14 In the folded scalars, newlines become spaces

.Yaml Spec Example
[source,yaml]
----
--- >
  Mark McGwire's
  year was crippled
  by a knee injury.
----

.Chronicle-Wire equivalent:
[source,yaml]
----
[Mark McGwire's
  year was crippled
  by a knee injury.]
----

=== 2.16 Indentation determines scope

.Yaml Spec Example
[source,yaml]
----
name: Mark McGwire
accomplishment: >
  Mark set a major league
  home run record in 1998.
stats: |
  65 Home Runs
  0.278 Batting Average
----

.Chronicle-Wire equivalent:
[source,yaml]
----
name: Mark McGwire
accomplishment:
  Mark set a major league home run record in 1998.
stats:
-  65 Home Runs,
-  0.278 Batting Average
----

=== 2.17 Quoted Scalars

.Yaml Spec Example
[source,yaml]
----
unicode: "Sosa did fine.\u263A"
control: "\b1998\t1999\t2000\n"
hex esc: "\x0d\x0a is \r\n"

single: '"Howdy!" he cried.'
quoted: ' # Not a ''comment''.'
tie-fighter: '|\-*-/|'
----

.Chronicle-Wire equivalent:
[source,yaml]
----
unicode: "Sosa did fine.\u263A"
control: "\b1998\t1999\t2000\n"
hex esc: "\x0d\x0a is \r\n"
single: "Howdy! he cried.",
quoted: " # Not a ''comment''."
tie-fighter: '|\-*-/|'
----

=== 2.18 Multi-line Flow Scalars

.Yaml Spec Example
[source,yaml]
----
plain:
  This unquoted scalar
  spans many lines.

quoted: "So does this
  quoted scalar.\n"
----

.Chronicle-Wire equivalent:
[source,yaml]
----
plain: "
  This unquoted scalar
  spans many lines."
quoted: "So does this
  quoted scalar.\n"
----

=== 2.21 Miscellaneous

.Yaml Spec Example
[source,yaml]
----
null:
booleans: [ true, false ]
string: '012345'
----

.Chronicle-Wire equivalent:
[source,yaml]
----
{
null: ,
booleans: [ true, false ],
string: '012345'
}
----

'''
https://github.com/OpenHFT/Chronicle-Wire[Back to Chronicle Wire project]
