-
Notifications
You must be signed in to change notification settings - Fork 58
/
style.dart
79 lines (61 loc) · 2.25 KB
/
style.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) 2014, the Dart project authors.
// Copyright (c) 2006, Kirill Simonov.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
// ignore_for_file: constant_identifier_names
import 'yaml_node.dart';
/// An enum of source scalar styles.
class ScalarStyle {
/// No source style was specified.
///
/// This usually indicates a scalar constructed with [YamlScalar.wrap].
static const ANY = ScalarStyle._('ANY');
/// The plain scalar style, unquoted and without a prefix.
///
/// See http://yaml.org/spec/1.2/spec.html#style/flow/plain.
static const PLAIN = ScalarStyle._('PLAIN');
/// The literal scalar style, with a `|` prefix.
///
/// See http://yaml.org/spec/1.2/spec.html#id2795688.
static const LITERAL = ScalarStyle._('LITERAL');
/// The folded scalar style, with a `>` prefix.
///
/// See http://yaml.org/spec/1.2/spec.html#id2796251.
static const FOLDED = ScalarStyle._('FOLDED');
/// The single-quoted scalar style.
///
/// See http://yaml.org/spec/1.2/spec.html#style/flow/single-quoted.
static const SINGLE_QUOTED = ScalarStyle._('SINGLE_QUOTED');
/// The double-quoted scalar style.
///
/// See http://yaml.org/spec/1.2/spec.html#style/flow/double-quoted.
static const DOUBLE_QUOTED = ScalarStyle._('DOUBLE_QUOTED');
final String name;
/// Whether this is a quoted style ([SINGLE_QUOTED] or [DOUBLE_QUOTED]).
bool get isQuoted => this == SINGLE_QUOTED || this == DOUBLE_QUOTED;
const ScalarStyle._(this.name);
@override
String toString() => name;
}
/// An enum of collection styles.
class CollectionStyle {
/// No source style was specified.
///
/// This usually indicates a collection constructed with [YamlList.wrap] or
/// [YamlMap.wrap].
static const ANY = CollectionStyle._('ANY');
/// The indentation-based block style.
///
/// See http://yaml.org/spec/1.2/spec.html#id2797293.
static const BLOCK = CollectionStyle._('BLOCK');
/// The delimiter-based block style.
///
/// See http://yaml.org/spec/1.2/spec.html#id2790088.
static const FLOW = CollectionStyle._('FLOW');
final String name;
const CollectionStyle._(this.name);
@override
String toString() => name;
}