MCPcopy Create free account
hub / github.com/DHowett/go-plist / Encode

Method Encode

encode.go:25–52  ·  view source on GitHub ↗

Encode writes the property list encoding of v to the stream.

(v interface{})

Source from the content-addressed store, hash-verified

23
24// Encode writes the property list encoding of v to the stream.
25func (p *Encoder) Encode(v interface{}) (err error) {
26 defer func() {
27 if r := recover(); r != nil {
28 if _, ok := r.(runtime.Error); ok {
29 panic(r)
30 }
31 err = r.(error)
32 }
33 }()
34
35 pval := p.marshal(reflect.ValueOf(v))
36 if pval == nil {
37 panic(errors.New("plist: no root element to encode"))
38 }
39
40 var g generator
41 switch p.format {
42 case XMLFormat:
43 g = newXMLPlistGenerator(p.writer)
44 case BinaryFormat, AutomaticFormat:
45 g = newBplistGenerator(p.writer)
46 case OpenStepFormat, GNUStepFormat:
47 g = newTextPlistGenerator(p.writer, p.format)
48 }
49 g.Indent(p.indent)
50 g.generateDocument(pval)
51 return
52}
53
54// Indent turns on pretty-printing for the XML and Text property list formats.
55// Each element begins on a new line and is preceded by one or more copies of indent according to its nesting depth.

Callers 12

ExampleEncoder_EncodeFunction · 0.95
oneshotGobFunction · 0.95
BenchmarkXMLEncodeFunction · 0.80
BenchmarkBplistEncodeFunction · 0.80
BenchmarkOpenStepEncodeFunction · 0.80
TestBplistLatin1ToUTF16Function · 0.80
writeStringTagMethod · 0.80
MarshalIndentFunction · 0.80
writePlistValueMethod · 0.80
printValueFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 6

marshalMethod · 0.95
IndentMethod · 0.95
generateDocumentMethod · 0.95
newXMLPlistGeneratorFunction · 0.85
newBplistGeneratorFunction · 0.85
newTextPlistGeneratorFunction · 0.85

Tested by 6

ExampleEncoder_EncodeFunction · 0.76
oneshotGobFunction · 0.76
BenchmarkXMLEncodeFunction · 0.64
BenchmarkBplistEncodeFunction · 0.64
BenchmarkOpenStepEncodeFunction · 0.64
TestBplistLatin1ToUTF16Function · 0.64