blob: a2c39403392ccc328b9c523147befef67a7dccba [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: demodb
package demodb
import (
"fmt"
"time"
"v.io/v23/vdl"
vdltime "v.io/v23/vdlroot/time"
"v.io/v23/vom"
)
var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
//////////////////////////////////////////////////
// Type definitions
type AddressInfo struct {
Street string
City string
State string
Zip string
}
func (AddressInfo) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AddressInfo"`
}) {
}
func (x AddressInfo) VDLIsZero() bool {
return x == AddressInfo{}
}
func (x AddressInfo) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_1); err != nil {
return err
}
if x.Street != "" {
if err := enc.NextFieldValueString("Street", vdl.StringType, x.Street); err != nil {
return err
}
}
if x.City != "" {
if err := enc.NextFieldValueString("City", vdl.StringType, x.City); err != nil {
return err
}
}
if x.State != "" {
if err := enc.NextFieldValueString("State", vdl.StringType, x.State); err != nil {
return err
}
}
if x.Zip != "" {
if err := enc.NextFieldValueString("Zip", vdl.StringType, x.Zip); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *AddressInfo) VDLRead(dec vdl.Decoder) error {
*x = AddressInfo{}
if err := dec.StartValue(__VDLType_struct_1); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Street":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Street = value
}
case "City":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.City = value
}
case "State":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.State = value
}
case "Zip":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Zip = value
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type CreditAgency int
const (
CreditAgencyEquifax CreditAgency = iota
CreditAgencyExperian
CreditAgencyTransUnion
)
// CreditAgencyAll holds all labels for CreditAgency.
var CreditAgencyAll = [...]CreditAgency{CreditAgencyEquifax, CreditAgencyExperian, CreditAgencyTransUnion}
// CreditAgencyFromString creates a CreditAgency from a string label.
func CreditAgencyFromString(label string) (x CreditAgency, err error) {
err = x.Set(label)
return
}
// Set assigns label to x.
func (x *CreditAgency) Set(label string) error {
switch label {
case "Equifax", "equifax":
*x = CreditAgencyEquifax
return nil
case "Experian", "experian":
*x = CreditAgencyExperian
return nil
case "TransUnion", "transunion":
*x = CreditAgencyTransUnion
return nil
}
*x = -1
return fmt.Errorf("unknown label %q in demodb.CreditAgency", label)
}
// String returns the string label of x.
func (x CreditAgency) String() string {
switch x {
case CreditAgencyEquifax:
return "Equifax"
case CreditAgencyExperian:
return "Experian"
case CreditAgencyTransUnion:
return "TransUnion"
}
return ""
}
func (CreditAgency) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.CreditAgency"`
Enum struct{ Equifax, Experian, TransUnion string }
}) {
}
func (x CreditAgency) VDLIsZero() bool {
return x == CreditAgencyEquifax
}
func (x CreditAgency) VDLWrite(enc vdl.Encoder) error {
if err := enc.WriteValueString(__VDLType_enum_2, x.String()); err != nil {
return err
}
return nil
}
func (x *CreditAgency) VDLRead(dec vdl.Decoder) error {
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
if err := x.Set(value); err != nil {
return err
}
}
return nil
}
type ExperianRating int
const (
ExperianRatingGood ExperianRating = iota
ExperianRatingBad
)
// ExperianRatingAll holds all labels for ExperianRating.
var ExperianRatingAll = [...]ExperianRating{ExperianRatingGood, ExperianRatingBad}
// ExperianRatingFromString creates a ExperianRating from a string label.
func ExperianRatingFromString(label string) (x ExperianRating, err error) {
err = x.Set(label)
return
}
// Set assigns label to x.
func (x *ExperianRating) Set(label string) error {
switch label {
case "Good", "good":
*x = ExperianRatingGood
return nil
case "Bad", "bad":
*x = ExperianRatingBad
return nil
}
*x = -1
return fmt.Errorf("unknown label %q in demodb.ExperianRating", label)
}
// String returns the string label of x.
func (x ExperianRating) String() string {
switch x {
case ExperianRatingGood:
return "Good"
case ExperianRatingBad:
return "Bad"
}
return ""
}
func (ExperianRating) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ExperianRating"`
Enum struct{ Good, Bad string }
}) {
}
func (x ExperianRating) VDLIsZero() bool {
return x == ExperianRatingGood
}
func (x ExperianRating) VDLWrite(enc vdl.Encoder) error {
if err := enc.WriteValueString(__VDLType_enum_3, x.String()); err != nil {
return err
}
return nil
}
func (x *ExperianRating) VDLRead(dec vdl.Decoder) error {
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
if err := x.Set(value); err != nil {
return err
}
}
return nil
}
type EquifaxCreditReport struct {
Rating byte
}
func (EquifaxCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.EquifaxCreditReport"`
}) {
}
func (x EquifaxCreditReport) VDLIsZero() bool {
return x == EquifaxCreditReport{}
}
func (x EquifaxCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_4); err != nil {
return err
}
if x.Rating != 0 {
if err := enc.NextFieldValueUint("Rating", vdl.ByteType, uint64(x.Rating)); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *EquifaxCreditReport) VDLRead(dec vdl.Decoder) error {
*x = EquifaxCreditReport{}
if err := dec.StartValue(__VDLType_struct_4); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
switch value, err := dec.ReadValueUint(8); {
case err != nil:
return err
default:
x.Rating = byte(value)
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type ExperianCreditReport struct {
Rating ExperianRating
}
func (ExperianCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ExperianCreditReport"`
}) {
}
func (x ExperianCreditReport) VDLIsZero() bool {
return x == ExperianCreditReport{}
}
func (x ExperianCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_5); err != nil {
return err
}
if x.Rating != ExperianRatingGood {
if err := enc.NextFieldValueString("Rating", __VDLType_enum_3, x.Rating.String()); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *ExperianCreditReport) VDLRead(dec vdl.Decoder) error {
*x = ExperianCreditReport{}
if err := dec.StartValue(__VDLType_struct_5); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
if err := x.Rating.Set(value); err != nil {
return err
}
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type TransUnionCreditReport struct {
Rating int16
}
func (TransUnionCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.TransUnionCreditReport"`
}) {
}
func (x TransUnionCreditReport) VDLIsZero() bool {
return x == TransUnionCreditReport{}
}
func (x TransUnionCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_6); err != nil {
return err
}
if x.Rating != 0 {
if err := enc.NextFieldValueInt("Rating", vdl.Int16Type, int64(x.Rating)); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *TransUnionCreditReport) VDLRead(dec vdl.Decoder) error {
*x = TransUnionCreditReport{}
if err := dec.StartValue(__VDLType_struct_6); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
switch value, err := dec.ReadValueInt(16); {
case err != nil:
return err
default:
x.Rating = int16(value)
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type (
// AgencyReport represents any single field of the AgencyReport union type.
AgencyReport interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the AgencyReport union type.
__VDLReflect(__AgencyReportReflect)
VDLIsZero() bool
VDLWrite(vdl.Encoder) error
}
// AgencyReportEquifaxReport represents field EquifaxReport of the AgencyReport union type.
AgencyReportEquifaxReport struct{ Value EquifaxCreditReport }
// AgencyReportExperianReport represents field ExperianReport of the AgencyReport union type.
AgencyReportExperianReport struct{ Value ExperianCreditReport }
// AgencyReportTransUnionReport represents field TransUnionReport of the AgencyReport union type.
AgencyReportTransUnionReport struct{ Value TransUnionCreditReport }
// __AgencyReportReflect describes the AgencyReport union type.
__AgencyReportReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AgencyReport"`
Type AgencyReport
Union struct {
EquifaxReport AgencyReportEquifaxReport
ExperianReport AgencyReportExperianReport
TransUnionReport AgencyReportTransUnionReport
}
}
)
func (x AgencyReportEquifaxReport) Index() int { return 0 }
func (x AgencyReportEquifaxReport) Interface() interface{} { return x.Value }
func (x AgencyReportEquifaxReport) Name() string { return "EquifaxReport" }
func (x AgencyReportEquifaxReport) __VDLReflect(__AgencyReportReflect) {}
func (x AgencyReportExperianReport) Index() int { return 1 }
func (x AgencyReportExperianReport) Interface() interface{} { return x.Value }
func (x AgencyReportExperianReport) Name() string { return "ExperianReport" }
func (x AgencyReportExperianReport) __VDLReflect(__AgencyReportReflect) {}
func (x AgencyReportTransUnionReport) Index() int { return 2 }
func (x AgencyReportTransUnionReport) Interface() interface{} { return x.Value }
func (x AgencyReportTransUnionReport) Name() string { return "TransUnionReport" }
func (x AgencyReportTransUnionReport) __VDLReflect(__AgencyReportReflect) {}
func (x AgencyReportEquifaxReport) VDLIsZero() bool {
return x.Value == EquifaxCreditReport{}
}
func (x AgencyReportExperianReport) VDLIsZero() bool {
return false
}
func (x AgencyReportTransUnionReport) VDLIsZero() bool {
return false
}
func (x AgencyReportEquifaxReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_7); err != nil {
return err
}
if err := enc.NextField("EquifaxReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x AgencyReportExperianReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_7); err != nil {
return err
}
if err := enc.NextField("ExperianReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x AgencyReportTransUnionReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_7); err != nil {
return err
}
if err := enc.NextField("TransUnionReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadAgencyReport(dec vdl.Decoder, x *AgencyReport) error {
if err := dec.StartValue(__VDLType_union_7); err != nil {
return err
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "EquifaxReport":
var field AgencyReportEquifaxReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "ExperianReport":
var field AgencyReportExperianReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "TransUnionReport":
var field AgencyReportTransUnionReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type CreditReport struct {
Agency CreditAgency
Report AgencyReport
}
func (CreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.CreditReport"`
}) {
}
func (x CreditReport) VDLIsZero() bool {
if x.Agency != CreditAgencyEquifax {
return false
}
if x.Report != nil && !x.Report.VDLIsZero() {
return false
}
return true
}
func (x CreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_8); err != nil {
return err
}
if x.Agency != CreditAgencyEquifax {
if err := enc.NextFieldValueString("Agency", __VDLType_enum_2, x.Agency.String()); err != nil {
return err
}
}
if x.Report != nil && !x.Report.VDLIsZero() {
if err := enc.NextField("Report"); err != nil {
return err
}
if err := x.Report.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *CreditReport) VDLRead(dec vdl.Decoder) error {
*x = CreditReport{
Report: AgencyReportEquifaxReport{},
}
if err := dec.StartValue(__VDLType_struct_8); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Agency":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
if err := x.Agency.Set(value); err != nil {
return err
}
}
case "Report":
if err := VDLReadAgencyReport(dec, &x.Report); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Customer struct {
Name string
Id int64
Active bool
Address AddressInfo
Credit CreditReport
}
func (Customer) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Customer"`
}) {
}
func (x Customer) VDLIsZero() bool {
if x.Name != "" {
return false
}
if x.Id != 0 {
return false
}
if x.Active {
return false
}
if x.Address != (AddressInfo{}) {
return false
}
if !x.Credit.VDLIsZero() {
return false
}
return true
}
func (x Customer) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_9); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextFieldValueString("Name", vdl.StringType, x.Name); err != nil {
return err
}
}
if x.Id != 0 {
if err := enc.NextFieldValueInt("Id", vdl.Int64Type, x.Id); err != nil {
return err
}
}
if x.Active {
if err := enc.NextFieldValueBool("Active", vdl.BoolType, x.Active); err != nil {
return err
}
}
if x.Address != (AddressInfo{}) {
if err := enc.NextField("Address"); err != nil {
return err
}
if err := x.Address.VDLWrite(enc); err != nil {
return err
}
}
if !x.Credit.VDLIsZero() {
if err := enc.NextField("Credit"); err != nil {
return err
}
if err := x.Credit.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Customer) VDLRead(dec vdl.Decoder) error {
*x = Customer{
Credit: CreditReport{
Report: AgencyReportEquifaxReport{},
},
}
if err := dec.StartValue(__VDLType_struct_9); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Name = value
}
case "Id":
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
x.Id = value
}
case "Active":
switch value, err := dec.ReadValueBool(); {
case err != nil:
return err
default:
x.Active = value
}
case "Address":
if err := x.Address.VDLRead(dec); err != nil {
return err
}
case "Credit":
if err := x.Credit.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Invoice struct {
CustId int64
InvoiceNum int64
Amount int64
ShipTo AddressInfo
}
func (Invoice) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Invoice"`
}) {
}
func (x Invoice) VDLIsZero() bool {
return x == Invoice{}
}
func (x Invoice) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_10); err != nil {
return err
}
if x.CustId != 0 {
if err := enc.NextFieldValueInt("CustId", vdl.Int64Type, x.CustId); err != nil {
return err
}
}
if x.InvoiceNum != 0 {
if err := enc.NextFieldValueInt("InvoiceNum", vdl.Int64Type, x.InvoiceNum); err != nil {
return err
}
}
if x.Amount != 0 {
if err := enc.NextFieldValueInt("Amount", vdl.Int64Type, x.Amount); err != nil {
return err
}
}
if x.ShipTo != (AddressInfo{}) {
if err := enc.NextField("ShipTo"); err != nil {
return err
}
if err := x.ShipTo.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Invoice) VDLRead(dec vdl.Decoder) error {
*x = Invoice{}
if err := dec.StartValue(__VDLType_struct_10); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "CustId":
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
x.CustId = value
}
case "InvoiceNum":
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
x.InvoiceNum = value
}
case "Amount":
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
x.Amount = value
}
case "ShipTo":
if err := x.ShipTo.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Numbers struct {
B byte
Ui16 uint16
Ui32 uint32
Ui64 uint64
I16 int16
I32 int32
I64 int64
F32 float32
F64 float64
}
func (Numbers) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Numbers"`
}) {
}
func (x Numbers) VDLIsZero() bool {
return x == Numbers{}
}
func (x Numbers) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_11); err != nil {
return err
}
if x.B != 0 {
if err := enc.NextFieldValueUint("B", vdl.ByteType, uint64(x.B)); err != nil {
return err
}
}
if x.Ui16 != 0 {
if err := enc.NextFieldValueUint("Ui16", vdl.Uint16Type, uint64(x.Ui16)); err != nil {
return err
}
}
if x.Ui32 != 0 {
if err := enc.NextFieldValueUint("Ui32", vdl.Uint32Type, uint64(x.Ui32)); err != nil {
return err
}
}
if x.Ui64 != 0 {
if err := enc.NextFieldValueUint("Ui64", vdl.Uint64Type, x.Ui64); err != nil {
return err
}
}
if x.I16 != 0 {
if err := enc.NextFieldValueInt("I16", vdl.Int16Type, int64(x.I16)); err != nil {
return err
}
}
if x.I32 != 0 {
if err := enc.NextFieldValueInt("I32", vdl.Int32Type, int64(x.I32)); err != nil {
return err
}
}
if x.I64 != 0 {
if err := enc.NextFieldValueInt("I64", vdl.Int64Type, x.I64); err != nil {
return err
}
}
if x.F32 != 0 {
if err := enc.NextFieldValueFloat("F32", vdl.Float32Type, float64(x.F32)); err != nil {
return err
}
}
if x.F64 != 0 {
if err := enc.NextFieldValueFloat("F64", vdl.Float64Type, x.F64); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Numbers) VDLRead(dec vdl.Decoder) error {
*x = Numbers{}
if err := dec.StartValue(__VDLType_struct_11); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "B":
switch value, err := dec.ReadValueUint(8); {
case err != nil:
return err
default:
x.B = byte(value)
}
case "Ui16":
switch value, err := dec.ReadValueUint(16); {
case err != nil:
return err
default:
x.Ui16 = uint16(value)
}
case "Ui32":
switch value, err := dec.ReadValueUint(32); {
case err != nil:
return err
default:
x.Ui32 = uint32(value)
}
case "Ui64":
switch value, err := dec.ReadValueUint(64); {
case err != nil:
return err
default:
x.Ui64 = value
}
case "I16":
switch value, err := dec.ReadValueInt(16); {
case err != nil:
return err
default:
x.I16 = int16(value)
}
case "I32":
switch value, err := dec.ReadValueInt(32); {
case err != nil:
return err
default:
x.I32 = int32(value)
}
case "I64":
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
x.I64 = value
}
case "F32":
switch value, err := dec.ReadValueFloat(32); {
case err != nil:
return err
default:
x.F32 = float32(value)
}
case "F64":
switch value, err := dec.ReadValueFloat(64); {
case err != nil:
return err
default:
x.F64 = value
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type (
// TitleOrValueType represents any single field of the TitleOrValueType union type.
TitleOrValueType interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the TitleOrValueType union type.
__VDLReflect(__TitleOrValueTypeReflect)
VDLIsZero() bool
VDLWrite(vdl.Encoder) error
}
// TitleOrValueTypeTitle represents field Title of the TitleOrValueType union type.
TitleOrValueTypeTitle struct{ Value string }
// TitleOrValueTypeValue represents field Value of the TitleOrValueType union type.
TitleOrValueTypeValue struct{ Value int64 }
// __TitleOrValueTypeReflect describes the TitleOrValueType union type.
__TitleOrValueTypeReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.TitleOrValueType"`
Type TitleOrValueType
Union struct {
Title TitleOrValueTypeTitle
Value TitleOrValueTypeValue
}
}
)
func (x TitleOrValueTypeTitle) Index() int { return 0 }
func (x TitleOrValueTypeTitle) Interface() interface{} { return x.Value }
func (x TitleOrValueTypeTitle) Name() string { return "Title" }
func (x TitleOrValueTypeTitle) __VDLReflect(__TitleOrValueTypeReflect) {}
func (x TitleOrValueTypeValue) Index() int { return 1 }
func (x TitleOrValueTypeValue) Interface() interface{} { return x.Value }
func (x TitleOrValueTypeValue) Name() string { return "Value" }
func (x TitleOrValueTypeValue) __VDLReflect(__TitleOrValueTypeReflect) {}
func (x TitleOrValueTypeTitle) VDLIsZero() bool {
return x.Value == ""
}
func (x TitleOrValueTypeValue) VDLIsZero() bool {
return false
}
func (x TitleOrValueTypeTitle) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_12); err != nil {
return err
}
if err := enc.NextFieldValueString("Title", vdl.StringType, x.Value); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x TitleOrValueTypeValue) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_12); err != nil {
return err
}
if err := enc.NextFieldValueInt("Value", vdl.Int64Type, x.Value); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadTitleOrValueType(dec vdl.Decoder, x *TitleOrValueType) error {
if err := dec.StartValue(__VDLType_union_12); err != nil {
return err
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "Title":
var field TitleOrValueTypeTitle
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
field.Value = value
}
*x = field
case "Value":
var field TitleOrValueTypeValue
switch value, err := dec.ReadValueInt(64); {
case err != nil:
return err
default:
field.Value = value
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type BazType struct {
Name string
TitleOrValue TitleOrValueType
}
func (BazType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.BazType"`
}) {
}
func (x BazType) VDLIsZero() bool {
if x.Name != "" {
return false
}
if x.TitleOrValue != nil && !x.TitleOrValue.VDLIsZero() {
return false
}
return true
}
func (x BazType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_13); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextFieldValueString("Name", vdl.StringType, x.Name); err != nil {
return err
}
}
if x.TitleOrValue != nil && !x.TitleOrValue.VDLIsZero() {
if err := enc.NextField("TitleOrValue"); err != nil {
return err
}
if err := x.TitleOrValue.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *BazType) VDLRead(dec vdl.Decoder) error {
*x = BazType{
TitleOrValue: TitleOrValueTypeTitle{},
}
if err := dec.StartValue(__VDLType_struct_13); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Name = value
}
case "TitleOrValue":
if err := VDLReadTitleOrValueType(dec, &x.TitleOrValue); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type BarType struct {
Baz BazType
}
func (BarType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.BarType"`
}) {
}
func (x BarType) VDLIsZero() bool {
if !x.Baz.VDLIsZero() {
return false
}
return true
}
func (x BarType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_14); err != nil {
return err
}
if !x.Baz.VDLIsZero() {
if err := enc.NextField("Baz"); err != nil {
return err
}
if err := x.Baz.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *BarType) VDLRead(dec vdl.Decoder) error {
*x = BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
}
if err := dec.StartValue(__VDLType_struct_14); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Baz":
if err := x.Baz.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type FooType struct {
Bar BarType
}
func (FooType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.FooType"`
}) {
}
func (x FooType) VDLIsZero() bool {
if !x.Bar.VDLIsZero() {
return false
}
return true
}
func (x FooType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_15); err != nil {
return err
}
if !x.Bar.VDLIsZero() {
if err := enc.NextField("Bar"); err != nil {
return err
}
if err := x.Bar.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *FooType) VDLRead(dec vdl.Decoder) error {
*x = FooType{
Bar: BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
},
}
if err := dec.StartValue(__VDLType_struct_15); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Bar":
if err := x.Bar.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Array2String [2]string
func (Array2String) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Array2String"`
}) {
}
func (x Array2String) VDLIsZero() bool {
return x == Array2String{}
}
func (x Array2String) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_array_16); err != nil {
return err
}
for _, elem := range x {
if err := enc.NextEntryValueString(vdl.StringType, elem); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Array2String) VDLRead(dec vdl.Decoder) error {
if err := dec.StartValue(__VDLType_array_16); err != nil {
return err
}
for index := 0; index < 2; index++ {
switch done, elem, err := dec.NextEntryValueString(); {
case err != nil:
return err
case done:
return fmt.Errorf("short array, got len %d < 2 %T)", index, *x)
default:
x[index] = elem
}
}
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case !done:
return fmt.Errorf("long array, got len > 2 %T", *x)
}
return dec.FinishValue()
}
type Composite struct {
Arr Array2String
ListInt []int32
MySet map[int32]struct{}
Map map[string]int32
}
func (Composite) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Composite"`
}) {
}
func (x Composite) VDLIsZero() bool {
if x.Arr != (Array2String{}) {
return false
}
if len(x.ListInt) != 0 {
return false
}
if len(x.MySet) != 0 {
return false
}
if len(x.Map) != 0 {
return false
}
return true
}
func (x Composite) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_17); err != nil {
return err
}
if x.Arr != (Array2String{}) {
if err := enc.NextField("Arr"); err != nil {
return err
}
if err := x.Arr.VDLWrite(enc); err != nil {
return err
}
}
if len(x.ListInt) != 0 {
if err := enc.NextField("ListInt"); err != nil {
return err
}
if err := __VDLWriteAnon_list_1(enc, x.ListInt); err != nil {
return err
}
}
if len(x.MySet) != 0 {
if err := enc.NextField("MySet"); err != nil {
return err
}
if err := __VDLWriteAnon_set_2(enc, x.MySet); err != nil {
return err
}
}
if len(x.Map) != 0 {
if err := enc.NextField("Map"); err != nil {
return err
}
if err := __VDLWriteAnon_map_3(enc, x.Map); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_list_1(enc vdl.Encoder, x []int32) error {
if err := enc.StartValue(__VDLType_list_18); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for _, elem := range x {
if err := enc.NextEntryValueInt(vdl.Int32Type, int64(elem)); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_set_2(enc vdl.Encoder, x map[int32]struct{}) error {
if err := enc.StartValue(__VDLType_set_19); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key := range x {
if err := enc.NextEntryValueInt(vdl.Int32Type, int64(key)); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_map_3(enc vdl.Encoder, x map[string]int32) error {
if err := enc.StartValue(__VDLType_map_20); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key, elem := range x {
if err := enc.NextEntryValueString(vdl.StringType, key); err != nil {
return err
}
if err := enc.WriteValueInt(vdl.Int32Type, int64(elem)); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Composite) VDLRead(dec vdl.Decoder) error {
*x = Composite{}
if err := dec.StartValue(__VDLType_struct_17); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Arr":
if err := x.Arr.VDLRead(dec); err != nil {
return err
}
case "ListInt":
if err := __VDLReadAnon_list_1(dec, &x.ListInt); err != nil {
return err
}
case "MySet":
if err := __VDLReadAnon_set_2(dec, &x.MySet); err != nil {
return err
}
case "Map":
if err := __VDLReadAnon_map_3(dec, &x.Map); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
func __VDLReadAnon_list_1(dec vdl.Decoder, x *[]int32) error {
if err := dec.StartValue(__VDLType_list_18); err != nil {
return err
}
if len := dec.LenHint(); len > 0 {
*x = make([]int32, 0, len)
} else {
*x = nil
}
for {
switch done, elem, err := dec.NextEntryValueInt(32); {
case err != nil:
return err
case done:
return dec.FinishValue()
default:
*x = append(*x, int32(elem))
}
}
}
func __VDLReadAnon_set_2(dec vdl.Decoder, x *map[int32]struct{}) error {
if err := dec.StartValue(__VDLType_set_19); err != nil {
return err
}
var tmpMap map[int32]struct{}
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[int32]struct{}, len)
}
for {
switch done, key, err := dec.NextEntryValueInt(32); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
default:
if tmpMap == nil {
tmpMap = make(map[int32]struct{})
}
tmpMap[int32(key)] = struct{}{}
}
}
}
func __VDLReadAnon_map_3(dec vdl.Decoder, x *map[string]int32) error {
if err := dec.StartValue(__VDLType_map_20); err != nil {
return err
}
var tmpMap map[string]int32
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[string]int32, len)
}
for {
switch done, key, err := dec.NextEntryValueString(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
default:
var elem int32
switch value, err := dec.ReadValueInt(32); {
case err != nil:
return err
default:
elem = int32(value)
}
if tmpMap == nil {
tmpMap = make(map[string]int32)
}
tmpMap[key] = elem
}
}
}
type Times struct {
Stamp time.Time
Interval time.Duration
}
func (Times) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Times"`
}) {
}
func (x Times) VDLIsZero() bool {
if !x.Stamp.IsZero() {
return false
}
if x.Interval != 0 {
return false
}
return true
}
func (x Times) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_21); err != nil {
return err
}
if !x.Stamp.IsZero() {
if err := enc.NextField("Stamp"); err != nil {
return err
}
var wire vdltime.Time
if err := vdltime.TimeFromNative(&wire, x.Stamp); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if x.Interval != 0 {
if err := enc.NextField("Interval"); err != nil {
return err
}
var wire vdltime.Duration
if err := vdltime.DurationFromNative(&wire, x.Interval); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Times) VDLRead(dec vdl.Decoder) error {
*x = Times{}
if err := dec.StartValue(__VDLType_struct_21); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Stamp":
var wire vdltime.Time
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := vdltime.TimeToNative(wire, &x.Stamp); err != nil {
return err
}
case "Interval":
var wire vdltime.Duration
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := vdltime.DurationToNative(wire, &x.Interval); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Recursive struct {
Any *vom.RawBytes
Maybe *Times
Rec map[Array2String]Recursive
}
func (Recursive) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Recursive"`
}) {
}
func (x Recursive) VDLIsZero() bool {
if x.Any != nil && !x.Any.VDLIsZero() {
return false
}
if x.Maybe != nil {
return false
}
if len(x.Rec) != 0 {
return false
}
return true
}
func (x Recursive) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_24); err != nil {
return err
}
if x.Any != nil && !x.Any.VDLIsZero() {
if err := enc.NextField("Any"); err != nil {
return err
}
if err := x.Any.VDLWrite(enc); err != nil {
return err
}
}
if x.Maybe != nil {
if err := enc.NextField("Maybe"); err != nil {
return err
}
enc.SetNextStartValueIsOptional()
if err := x.Maybe.VDLWrite(enc); err != nil {
return err
}
}
if len(x.Rec) != 0 {
if err := enc.NextField("Rec"); err != nil {
return err
}
if err := __VDLWriteAnon_map_4(enc, x.Rec); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_map_4(enc vdl.Encoder, x map[Array2String]Recursive) error {
if err := enc.StartValue(__VDLType_map_26); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key, elem := range x {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := key.VDLWrite(enc); err != nil {
return err
}
if err := elem.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Recursive) VDLRead(dec vdl.Decoder) error {
*x = Recursive{
Any: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
}
if err := dec.StartValue(__VDLType_struct_24); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Any":
x.Any = new(vom.RawBytes)
if err := x.Any.VDLRead(dec); err != nil {
return err
}
case "Maybe":
if err := dec.StartValue(__VDLType_optional_25); err != nil {
return err
}
if dec.IsNil() {
x.Maybe = nil
if err := dec.FinishValue(); err != nil {
return err
}
} else {
x.Maybe = new(Times)
dec.IgnoreNextStartValue()
if err := x.Maybe.VDLRead(dec); err != nil {
return err
}
}
case "Rec":
if err := __VDLReadAnon_map_4(dec, &x.Rec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
func __VDLReadAnon_map_4(dec vdl.Decoder, x *map[Array2String]Recursive) error {
if err := dec.StartValue(__VDLType_map_26); err != nil {
return err
}
var tmpMap map[Array2String]Recursive
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[Array2String]Recursive, len)
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
default:
var key Array2String
if err := key.VDLRead(dec); err != nil {
return err
}
var elem Recursive
if err := elem.VDLRead(dec); err != nil {
return err
}
if tmpMap == nil {
tmpMap = make(map[Array2String]Recursive)
}
tmpMap[key] = elem
}
}
}
type (
// ActOrSatScore represents any single field of the ActOrSatScore union type.
ActOrSatScore interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the ActOrSatScore union type.
__VDLReflect(__ActOrSatScoreReflect)
VDLIsZero() bool
VDLWrite(vdl.Encoder) error
}
// ActOrSatScoreActScore represents field ActScore of the ActOrSatScore union type.
ActOrSatScoreActScore struct{ Value uint16 }
// ActOrSatScoreSatScore represents field SatScore of the ActOrSatScore union type.
ActOrSatScoreSatScore struct{ Value uint16 }
// __ActOrSatScoreReflect describes the ActOrSatScore union type.
__ActOrSatScoreReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ActOrSatScore"`
Type ActOrSatScore
Union struct {
ActScore ActOrSatScoreActScore
SatScore ActOrSatScoreSatScore
}
}
)
func (x ActOrSatScoreActScore) Index() int { return 0 }
func (x ActOrSatScoreActScore) Interface() interface{} { return x.Value }
func (x ActOrSatScoreActScore) Name() string { return "ActScore" }
func (x ActOrSatScoreActScore) __VDLReflect(__ActOrSatScoreReflect) {}
func (x ActOrSatScoreSatScore) Index() int { return 1 }
func (x ActOrSatScoreSatScore) Interface() interface{} { return x.Value }
func (x ActOrSatScoreSatScore) Name() string { return "SatScore" }
func (x ActOrSatScoreSatScore) __VDLReflect(__ActOrSatScoreReflect) {}
func (x ActOrSatScoreActScore) VDLIsZero() bool {
return x.Value == 0
}
func (x ActOrSatScoreSatScore) VDLIsZero() bool {
return false
}
func (x ActOrSatScoreActScore) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_27); err != nil {
return err
}
if err := enc.NextFieldValueUint("ActScore", vdl.Uint16Type, uint64(x.Value)); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x ActOrSatScoreSatScore) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_27); err != nil {
return err
}
if err := enc.NextFieldValueUint("SatScore", vdl.Uint16Type, uint64(x.Value)); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadActOrSatScore(dec vdl.Decoder, x *ActOrSatScore) error {
if err := dec.StartValue(__VDLType_union_27); err != nil {
return err
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "ActScore":
var field ActOrSatScoreActScore
switch value, err := dec.ReadValueUint(16); {
case err != nil:
return err
default:
field.Value = uint16(value)
}
*x = field
case "SatScore":
var field ActOrSatScoreSatScore
switch value, err := dec.ReadValueUint(16); {
case err != nil:
return err
default:
field.Value = uint16(value)
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type Student struct {
Name string
TestTime time.Time
Score ActOrSatScore
}
func (Student) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Student"`
}) {
}
func (x Student) VDLIsZero() bool {
if x.Name != "" {
return false
}
if !x.TestTime.IsZero() {
return false
}
if x.Score != nil && !x.Score.VDLIsZero() {
return false
}
return true
}
func (x Student) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_28); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextFieldValueString("Name", vdl.StringType, x.Name); err != nil {
return err
}
}
if !x.TestTime.IsZero() {
if err := enc.NextField("TestTime"); err != nil {
return err
}
var wire vdltime.Time
if err := vdltime.TimeFromNative(&wire, x.TestTime); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if x.Score != nil && !x.Score.VDLIsZero() {
if err := enc.NextField("Score"); err != nil {
return err
}
if err := x.Score.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Student) VDLRead(dec vdl.Decoder) error {
*x = Student{
Score: ActOrSatScoreActScore{},
}
if err := dec.StartValue(__VDLType_struct_28); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Name = value
}
case "TestTime":
var wire vdltime.Time
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := vdltime.TimeToNative(wire, &x.TestTime); err != nil {
return err
}
case "Score":
if err := VDLReadActOrSatScore(dec, &x.Score); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type AnythingGoes struct {
NameOfType string
Anything *vom.RawBytes
}
func (AnythingGoes) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AnythingGoes"`
}) {
}
func (x AnythingGoes) VDLIsZero() bool {
if x.NameOfType != "" {
return false
}
if x.Anything != nil && !x.Anything.VDLIsZero() {
return false
}
return true
}
func (x AnythingGoes) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_29); err != nil {
return err
}
if x.NameOfType != "" {
if err := enc.NextFieldValueString("NameOfType", vdl.StringType, x.NameOfType); err != nil {
return err
}
}
if x.Anything != nil && !x.Anything.VDLIsZero() {
if err := enc.NextField("Anything"); err != nil {
return err
}
if err := x.Anything.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *AnythingGoes) VDLRead(dec vdl.Decoder) error {
*x = AnythingGoes{
Anything: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
}
if err := dec.StartValue(__VDLType_struct_29); err != nil {
return err
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "NameOfType":
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.NameOfType = value
}
case "Anything":
x.Anything = new(vom.RawBytes)
if err := x.Anything.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
// Hold type definitions in package-level variables, for better performance.
var (
__VDLType_struct_1 *vdl.Type
__VDLType_enum_2 *vdl.Type
__VDLType_enum_3 *vdl.Type
__VDLType_struct_4 *vdl.Type
__VDLType_struct_5 *vdl.Type
__VDLType_struct_6 *vdl.Type
__VDLType_union_7 *vdl.Type
__VDLType_struct_8 *vdl.Type
__VDLType_struct_9 *vdl.Type
__VDLType_struct_10 *vdl.Type
__VDLType_struct_11 *vdl.Type
__VDLType_union_12 *vdl.Type
__VDLType_struct_13 *vdl.Type
__VDLType_struct_14 *vdl.Type
__VDLType_struct_15 *vdl.Type
__VDLType_array_16 *vdl.Type
__VDLType_struct_17 *vdl.Type
__VDLType_list_18 *vdl.Type
__VDLType_set_19 *vdl.Type
__VDLType_map_20 *vdl.Type
__VDLType_struct_21 *vdl.Type
__VDLType_struct_22 *vdl.Type
__VDLType_struct_23 *vdl.Type
__VDLType_struct_24 *vdl.Type
__VDLType_optional_25 *vdl.Type
__VDLType_map_26 *vdl.Type
__VDLType_union_27 *vdl.Type
__VDLType_struct_28 *vdl.Type
__VDLType_struct_29 *vdl.Type
)
var __VDLInitCalled bool
// __VDLInit performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = __VDLInit()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func __VDLInit() struct{} {
if __VDLInitCalled {
return struct{}{}
}
__VDLInitCalled = true
// Register types.
vdl.Register((*AddressInfo)(nil))
vdl.Register((*CreditAgency)(nil))
vdl.Register((*ExperianRating)(nil))
vdl.Register((*EquifaxCreditReport)(nil))
vdl.Register((*ExperianCreditReport)(nil))
vdl.Register((*TransUnionCreditReport)(nil))
vdl.Register((*AgencyReport)(nil))
vdl.Register((*CreditReport)(nil))
vdl.Register((*Customer)(nil))
vdl.Register((*Invoice)(nil))
vdl.Register((*Numbers)(nil))
vdl.Register((*TitleOrValueType)(nil))
vdl.Register((*BazType)(nil))
vdl.Register((*BarType)(nil))
vdl.Register((*FooType)(nil))
vdl.Register((*Array2String)(nil))
vdl.Register((*Composite)(nil))
vdl.Register((*Times)(nil))
vdl.Register((*Recursive)(nil))
vdl.Register((*ActOrSatScore)(nil))
vdl.Register((*Student)(nil))
vdl.Register((*AnythingGoes)(nil))
// Initialize type definitions.
__VDLType_struct_1 = vdl.TypeOf((*AddressInfo)(nil)).Elem()
__VDLType_enum_2 = vdl.TypeOf((*CreditAgency)(nil))
__VDLType_enum_3 = vdl.TypeOf((*ExperianRating)(nil))
__VDLType_struct_4 = vdl.TypeOf((*EquifaxCreditReport)(nil)).Elem()
__VDLType_struct_5 = vdl.TypeOf((*ExperianCreditReport)(nil)).Elem()
__VDLType_struct_6 = vdl.TypeOf((*TransUnionCreditReport)(nil)).Elem()
__VDLType_union_7 = vdl.TypeOf((*AgencyReport)(nil))
__VDLType_struct_8 = vdl.TypeOf((*CreditReport)(nil)).Elem()
__VDLType_struct_9 = vdl.TypeOf((*Customer)(nil)).Elem()
__VDLType_struct_10 = vdl.TypeOf((*Invoice)(nil)).Elem()
__VDLType_struct_11 = vdl.TypeOf((*Numbers)(nil)).Elem()
__VDLType_union_12 = vdl.TypeOf((*TitleOrValueType)(nil))
__VDLType_struct_13 = vdl.TypeOf((*BazType)(nil)).Elem()
__VDLType_struct_14 = vdl.TypeOf((*BarType)(nil)).Elem()
__VDLType_struct_15 = vdl.TypeOf((*FooType)(nil)).Elem()
__VDLType_array_16 = vdl.TypeOf((*Array2String)(nil))
__VDLType_struct_17 = vdl.TypeOf((*Composite)(nil)).Elem()
__VDLType_list_18 = vdl.TypeOf((*[]int32)(nil))
__VDLType_set_19 = vdl.TypeOf((*map[int32]struct{})(nil))
__VDLType_map_20 = vdl.TypeOf((*map[string]int32)(nil))
__VDLType_struct_21 = vdl.TypeOf((*Times)(nil)).Elem()
__VDLType_struct_22 = vdl.TypeOf((*vdltime.Time)(nil)).Elem()
__VDLType_struct_23 = vdl.TypeOf((*vdltime.Duration)(nil)).Elem()
__VDLType_struct_24 = vdl.TypeOf((*Recursive)(nil)).Elem()
__VDLType_optional_25 = vdl.TypeOf((*Times)(nil))
__VDLType_map_26 = vdl.TypeOf((*map[Array2String]Recursive)(nil))
__VDLType_union_27 = vdl.TypeOf((*ActOrSatScore)(nil))
__VDLType_struct_28 = vdl.TypeOf((*Student)(nil)).Elem()
__VDLType_struct_29 = vdl.TypeOf((*AnythingGoes)(nil)).Elem()
return struct{}{}
}