forked from yaml/go-yaml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
98 lines (79 loc) · 3.21 KB
/
node.go
File metadata and controls
98 lines (79 loc) · 3.21 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package yaml
import "go.yaml.in/yaml/v4/internal/libyaml"
// -----------------------------------------------------------------------------
// Node-related type aliases and constants
// -----------------------------------------------------------------------------
type (
// Node represents an element in the YAML document hierarchy.
// While documents are typically encoded and decoded into higher level
// types, such as structs and maps, Node is an intermediate representation
// that allows detailed control over the content being decoded or encoded.
//
// It's worth noting that although Node offers access into details such as
// line numbers, columns, and comments, the content when re-encoded will
// not have its original textual representation preserved.
// An effort is made to render the data pleasantly, and to preserve
// comments near the data they describe, though.
//
// Values that make use of the Node type interact with the yaml package in
// the same way any other type would do, by encoding and decoding yaml data
// directly or indirectly into them.
//
// For example:
//
// var person struct {
// Name string
// Address yaml.Node
// }
// err := yaml.Unmarshal(data, &person)
//
// Or by itself:
//
// var person Node
// err := yaml.Unmarshal(data, &person)
Node = libyaml.Node
// Kind represents the type of YAML node.
Kind = libyaml.Kind
// Style represents the formatting style of a YAML node.
Style = libyaml.Style
// Marshaler interface may be implemented by types to customize their
// behavior when being marshaled into a YAML document.
Marshaler = libyaml.Marshaler
// Unmarshaler is the interface implemented by types that can unmarshal
// a YAML description of themselves.
Unmarshaler = libyaml.Unmarshaler
// IsZeroer is used to check whether an object is zero to determine whether
// it should be omitted when marshaling with the ,omitempty flag.
// One notable implementation is time.Time.
IsZeroer = libyaml.IsZeroer
)
// Kind constants define the different types of YAML nodes.
const (
// DocumentNode represents the root of a YAML document.
DocumentNode = libyaml.DocumentNode
// SequenceNode represents a YAML sequence (list).
SequenceNode = libyaml.SequenceNode
// MappingNode represents a YAML mapping (dictionary).
MappingNode = libyaml.MappingNode
// ScalarNode represents a YAML scalar value.
ScalarNode = libyaml.ScalarNode
// AliasNode represents a reference to an anchored node.
AliasNode = libyaml.AliasNode
// StreamNode represents a container for multiple YAML documents.
StreamNode = libyaml.StreamNode
)
// Style constants define different formatting styles for YAML nodes.
const (
// TaggedStyle explicitly shows the tag on the node.
TaggedStyle = libyaml.TaggedStyle
// DoubleQuotedStyle uses double quotes for scalar values.
DoubleQuotedStyle = libyaml.DoubleQuotedStyle
// SingleQuotedStyle uses single quotes for scalar values.
SingleQuotedStyle = libyaml.SingleQuotedStyle
// LiteralStyle uses literal block scalar style (|).
LiteralStyle = libyaml.LiteralStyle
// FoldedStyle uses folded block scalar style (>).
FoldedStyle = libyaml.FoldedStyle
// FlowStyle uses flow style (inline) formatting.
FlowStyle = libyaml.FlowStyle
)