dispatch/server/index_data_easyjson.go
Ken-Håvard Lieng 09d57b7023 Use easyjson
2018-05-25 23:54:36 +02:00

480 lines
10 KiB
Go

// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package server
import (
json "encoding/json"
storage "github.com/khlieng/dispatch/storage"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjson7e607aefDecodeGithubComKhliengDispatchServer(in *jlexer.Lexer, out *indexData) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "defaults":
if data := in.Raw(); in.Ok() {
in.AddError((out.Defaults).UnmarshalJSON(data))
}
case "servers":
if in.IsNull() {
in.Skip()
out.Servers = nil
} else {
in.Delim('[')
if out.Servers == nil {
if !in.IsDelim(']') {
out.Servers = make([]Server, 0, 1)
} else {
out.Servers = []Server{}
}
} else {
out.Servers = (out.Servers)[:0]
}
for !in.IsDelim(']') {
var v1 Server
if data := in.Raw(); in.Ok() {
in.AddError((v1).UnmarshalJSON(data))
}
out.Servers = append(out.Servers, v1)
in.WantComma()
}
in.Delim(']')
}
case "channels":
if in.IsNull() {
in.Skip()
out.Channels = nil
} else {
in.Delim('[')
if out.Channels == nil {
if !in.IsDelim(']') {
out.Channels = make([]storage.Channel, 0, 1)
} else {
out.Channels = []storage.Channel{}
}
} else {
out.Channels = (out.Channels)[:0]
}
for !in.IsDelim(']') {
var v2 storage.Channel
easyjson7e607aefDecodeGithubComKhliengDispatchStorage(in, &v2)
out.Channels = append(out.Channels, v2)
in.WantComma()
}
in.Delim(']')
}
case "users":
if in.IsNull() {
in.Skip()
out.Users = nil
} else {
if out.Users == nil {
out.Users = new(Userlist)
}
if data := in.Raw(); in.Ok() {
in.AddError((*out.Users).UnmarshalJSON(data))
}
}
case "messages":
if in.IsNull() {
in.Skip()
out.Messages = nil
} else {
if out.Messages == nil {
out.Messages = new(Messages)
}
if data := in.Raw(); in.Ok() {
in.AddError((*out.Messages).UnmarshalJSON(data))
}
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchServer(out *jwriter.Writer, in indexData) {
out.RawByte('{')
first := true
_ = first
if true {
const prefix string = ",\"defaults\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Raw((in.Defaults).MarshalJSON())
}
if len(in.Servers) != 0 {
const prefix string = ",\"servers\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
{
out.RawByte('[')
for v3, v4 := range in.Servers {
if v3 > 0 {
out.RawByte(',')
}
out.Raw((v4).MarshalJSON())
}
out.RawByte(']')
}
}
if len(in.Channels) != 0 {
const prefix string = ",\"channels\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
{
out.RawByte('[')
for v5, v6 := range in.Channels {
if v5 > 0 {
out.RawByte(',')
}
easyjson7e607aefEncodeGithubComKhliengDispatchStorage(out, v6)
}
out.RawByte(']')
}
}
if in.Users != nil {
const prefix string = ",\"users\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Raw((*in.Users).MarshalJSON())
}
if in.Messages != nil {
const prefix string = ",\"messages\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Raw((*in.Messages).MarshalJSON())
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v indexData) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson7e607aefEncodeGithubComKhliengDispatchServer(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v indexData) MarshalEasyJSON(w *jwriter.Writer) {
easyjson7e607aefEncodeGithubComKhliengDispatchServer(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *indexData) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson7e607aefDecodeGithubComKhliengDispatchServer(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *indexData) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson7e607aefDecodeGithubComKhliengDispatchServer(l, v)
}
func easyjson7e607aefDecodeGithubComKhliengDispatchStorage(in *jlexer.Lexer, out *storage.Channel) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "server":
out.Server = string(in.String())
case "name":
out.Name = string(in.String())
case "topic":
out.Topic = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchStorage(out *jwriter.Writer, in storage.Channel) {
out.RawByte('{')
first := true
_ = first
if in.Server != "" {
const prefix string = ",\"server\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.String(string(in.Server))
}
if in.Name != "" {
const prefix string = ",\"name\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.String(string(in.Name))
}
if in.Topic != "" {
const prefix string = ",\"topic\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.String(string(in.Topic))
}
out.RawByte('}')
}
func easyjson7e607aefDecodeGithubComKhliengDispatchServer1(in *jlexer.Lexer, out *connectDefaults) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "name":
out.Name = string(in.String())
case "host":
out.Host = string(in.String())
case "port":
out.Port = int(in.Int())
case "channels":
if in.IsNull() {
in.Skip()
out.Channels = nil
} else {
in.Delim('[')
if out.Channels == nil {
if !in.IsDelim(']') {
out.Channels = make([]string, 0, 4)
} else {
out.Channels = []string{}
}
} else {
out.Channels = (out.Channels)[:0]
}
for !in.IsDelim(']') {
var v7 string
v7 = string(in.String())
out.Channels = append(out.Channels, v7)
in.WantComma()
}
in.Delim(']')
}
case "password":
out.Password = bool(in.Bool())
case "ssl":
out.SSL = bool(in.Bool())
case "readonly":
out.ReadOnly = bool(in.Bool())
case "showDetails":
out.ShowDetails = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchServer1(out *jwriter.Writer, in connectDefaults) {
out.RawByte('{')
first := true
_ = first
if in.Name != "" {
const prefix string = ",\"name\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.String(string(in.Name))
}
if in.Host != "" {
const prefix string = ",\"host\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.String(string(in.Host))
}
if in.Port != 0 {
const prefix string = ",\"port\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Int(int(in.Port))
}
if len(in.Channels) != 0 {
const prefix string = ",\"channels\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
{
out.RawByte('[')
for v8, v9 := range in.Channels {
if v8 > 0 {
out.RawByte(',')
}
out.String(string(v9))
}
out.RawByte(']')
}
}
if in.Password {
const prefix string = ",\"password\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Bool(bool(in.Password))
}
if in.SSL {
const prefix string = ",\"ssl\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Bool(bool(in.SSL))
}
if in.ReadOnly {
const prefix string = ",\"readonly\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Bool(bool(in.ReadOnly))
}
if in.ShowDetails {
const prefix string = ",\"showDetails\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Bool(bool(in.ShowDetails))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v connectDefaults) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjson7e607aefEncodeGithubComKhliengDispatchServer1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v connectDefaults) MarshalEasyJSON(w *jwriter.Writer) {
easyjson7e607aefEncodeGithubComKhliengDispatchServer1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *connectDefaults) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson7e607aefDecodeGithubComKhliengDispatchServer1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *connectDefaults) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson7e607aefDecodeGithubComKhliengDispatchServer1(l, v)
}