From 961c04cae992eadb42d286d2f85f8a675bdc68c8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 29 Jan 2018 14:17:40 -0800 Subject: Upgrading server dependancies (#8154) --- .../mailru/easyjson/opt/gotemplate_Bool.go | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 vendor/github.com/mailru/easyjson/opt/gotemplate_Bool.go (limited to 'vendor/github.com/mailru/easyjson/opt/gotemplate_Bool.go') diff --git a/vendor/github.com/mailru/easyjson/opt/gotemplate_Bool.go b/vendor/github.com/mailru/easyjson/opt/gotemplate_Bool.go new file mode 100644 index 000000000..6978ee971 --- /dev/null +++ b/vendor/github.com/mailru/easyjson/opt/gotemplate_Bool.go @@ -0,0 +1,79 @@ +// generated by gotemplate + +package opt + +import ( + "fmt" + + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +// template type Optional(A) + +// A 'gotemplate'-based type for providing optional semantics without using pointers. +type Bool struct { + V bool + Defined bool +} + +// Creates an optional type with a given value. +func OBool(v bool) Bool { + return Bool{V: v, Defined: true} +} + +// Get returns the value or given default in the case the value is undefined. +func (v Bool) Get(deflt bool) bool { + if !v.Defined { + return deflt + } + return v.V +} + +// MarshalEasyJSON does JSON marshaling using easyjson interface. +func (v Bool) MarshalEasyJSON(w *jwriter.Writer) { + if v.Defined { + w.Bool(v.V) + } else { + w.RawString("null") + } +} + +// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface. +func (v *Bool) UnmarshalEasyJSON(l *jlexer.Lexer) { + if l.IsNull() { + l.Skip() + *v = Bool{} + } else { + v.V = l.Bool() + v.Defined = true + } +} + +// MarshalJSON implements a standard json marshaler interface. +func (v Bool) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + v.MarshalEasyJSON(&w) + return w.Buffer.BuildBytes(), w.Error +} + +// UnmarshalJSON implements a standard json unmarshaler interface. +func (v *Bool) UnmarshalJSON(data []byte) error { + l := jlexer.Lexer{Data: data} + v.UnmarshalEasyJSON(&l) + return l.Error() +} + +// IsDefined returns whether the value is defined, a function is required so that it can +// be used in an interface. +func (v Bool) IsDefined() bool { + return v.Defined +} + +// String implements a stringer interface using fmt.Sprint for the value. +func (v Bool) String() string { + if !v.Defined { + return "" + } + return fmt.Sprint(v.V) +} -- cgit v1.2.3-1-g7c22