OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library yaml.yaml_document; |
| 6 |
| 7 import 'dart:collection'; |
| 8 |
| 9 import 'package:source_span/source_span.dart'; |
| 10 |
| 11 import 'yaml_node.dart'; |
| 12 |
| 13 /// A YAML document, complete with metadata. |
| 14 class YamlDocument { |
| 15 /// The contents of the document. |
| 16 final YamlNode contents; |
| 17 |
| 18 /// The span covering the entire document. |
| 19 final SourceSpan span; |
| 20 |
| 21 /// The version directive for the document, if any. |
| 22 final VersionDirective versionDirective; |
| 23 |
| 24 /// The tag directives for the document. |
| 25 final List<TagDirective> tagDirectives; |
| 26 |
| 27 /// Whether the beginning of the document was implicit (versus explicit via |
| 28 /// `===`). |
| 29 final bool startImplicit; |
| 30 |
| 31 /// Whether the end of the document was implicit (versus explicit via `...`). |
| 32 final bool endImplicit; |
| 33 |
| 34 /// Users of the library should not use this constructor. |
| 35 YamlDocument.internal(this.contents, this.span, this.versionDirective, |
| 36 List<TagDirective> tagDirectives, {this.startImplicit: false, |
| 37 this.endImplicit: false}) |
| 38 : tagDirectives = new UnmodifiableListView(tagDirectives); |
| 39 |
| 40 String toString() => contents.toString(); |
| 41 } |
| 42 |
| 43 /// A directive indicating which version of YAML a document was written to. |
| 44 class VersionDirective { |
| 45 /// The major version number. |
| 46 final int major; |
| 47 |
| 48 /// The minor version number. |
| 49 final int minor; |
| 50 |
| 51 VersionDirective(this.major, this.minor); |
| 52 |
| 53 String toString() => "%YAML $major.$minor"; |
| 54 } |
| 55 |
| 56 /// A directive describing a custom tag handle. |
| 57 class TagDirective { |
| 58 /// The handle for use in the document. |
| 59 final String handle; |
| 60 |
| 61 /// The prefix that the handle maps to. |
| 62 final String prefix; |
| 63 |
| 64 TagDirective(this.handle, this.prefix); |
| 65 |
| 66 String toString() => "%TAG $handle $prefix"; |
| 67 } |
OLD | NEW |