func NewBinaryEncoder(w io.Writer) *Encoder {
	return NewEncoderForFormat(w, BinaryFormat)
}
NewBinaryEncoder returns an Encoder that writes a binary property list to w.
package plist
import (
	"bytes"
	"errors"
	"io"
	"reflect"
	"runtime"
)
type generator interface {
	generateDocument(cfValue)
	Indent(string)
}
type Encoder struct {
	writer io.Writer
	format int
	indent string
}
func (p *Encoder) Encode(v interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			if _, ok := r.(runtime.Error); ok {
				panic(r)
			}
			err = r.(error)
		}
	}()
	pval := p.marshal(reflect.ValueOf(v))
	if pval == nil {
		panic(errors.New("plist: no root element to encode"))
	}
	var g generator
	switch p.format {
	case XMLFormat:
		g = newXMLPlistGenerator(p.writer)
	case BinaryFormat, AutomaticFormat:
		g = newBplistGenerator(p.writer)
	case OpenStepFormat, GNUStepFormat:
		g = newTextPlistGenerator(p.writer, p.format)
	}
	g.Indent(p.indent)
	g.generateDocument(pval)
	return
}
func (p *Encoder) Indent(indent string) {
	p.indent = indent
}
func NewEncoder(w io.Writer) *Encoder {
	return NewEncoderForFormat(w, XMLFormat)
}
func NewEncoderForFormat(w io.Writer, format int) *Encoder {
	return &Encoder{
		writer: w,
		format: format,
	}
}