package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type PageTableCell struct {
Flags bin .Fields
Header bool
AlignCenter bool
AlignRight bool
ValignMiddle bool
ValignBottom bool
Text RichTextClass
Colspan int
Rowspan int
}
const PageTableCellTypeID = 0x34566b6a
var (
_ bin .Encoder = &PageTableCell {}
_ bin .Decoder = &PageTableCell {}
_ bin .BareEncoder = &PageTableCell {}
_ bin .BareDecoder = &PageTableCell {}
)
func (p *PageTableCell ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Header == false ) {
return false
}
if !(p .AlignCenter == false ) {
return false
}
if !(p .AlignRight == false ) {
return false
}
if !(p .ValignMiddle == false ) {
return false
}
if !(p .ValignBottom == false ) {
return false
}
if !(p .Text == nil ) {
return false
}
if !(p .Colspan == 0 ) {
return false
}
if !(p .Rowspan == 0 ) {
return false
}
return true
}
func (p *PageTableCell ) String () string {
if p == nil {
return "PageTableCell(nil)"
}
type Alias PageTableCell
return fmt .Sprintf ("PageTableCell%+v" , Alias (*p ))
}
func (p *PageTableCell ) FillFrom (from interface {
GetHeader () (value bool )
GetAlignCenter () (value bool )
GetAlignRight () (value bool )
GetValignMiddle () (value bool )
GetValignBottom () (value bool )
GetText () (value RichTextClass , ok bool )
GetColspan () (value int , ok bool )
GetRowspan () (value int , ok bool )
}) {
p .Header = from .GetHeader ()
p .AlignCenter = from .GetAlignCenter ()
p .AlignRight = from .GetAlignRight ()
p .ValignMiddle = from .GetValignMiddle ()
p .ValignBottom = from .GetValignBottom ()
if val , ok := from .GetText (); ok {
p .Text = val
}
if val , ok := from .GetColspan (); ok {
p .Colspan = val
}
if val , ok := from .GetRowspan (); ok {
p .Rowspan = val
}
}
func (*PageTableCell ) TypeID () uint32 {
return PageTableCellTypeID
}
func (*PageTableCell ) TypeName () string {
return "pageTableCell"
}
func (p *PageTableCell ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "pageTableCell" ,
ID : PageTableCellTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Header" ,
SchemaName : "header" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "AlignCenter" ,
SchemaName : "align_center" ,
Null : !p .Flags .Has (3 ),
},
{
Name : "AlignRight" ,
SchemaName : "align_right" ,
Null : !p .Flags .Has (4 ),
},
{
Name : "ValignMiddle" ,
SchemaName : "valign_middle" ,
Null : !p .Flags .Has (5 ),
},
{
Name : "ValignBottom" ,
SchemaName : "valign_bottom" ,
Null : !p .Flags .Has (6 ),
},
{
Name : "Text" ,
SchemaName : "text" ,
Null : !p .Flags .Has (7 ),
},
{
Name : "Colspan" ,
SchemaName : "colspan" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "Rowspan" ,
SchemaName : "rowspan" ,
Null : !p .Flags .Has (2 ),
},
}
return typ
}
func (p *PageTableCell ) SetFlags () {
if !(p .Header == false ) {
p .Flags .Set (0 )
}
if !(p .AlignCenter == false ) {
p .Flags .Set (3 )
}
if !(p .AlignRight == false ) {
p .Flags .Set (4 )
}
if !(p .ValignMiddle == false ) {
p .Flags .Set (5 )
}
if !(p .ValignBottom == false ) {
p .Flags .Set (6 )
}
if !(p .Text == nil ) {
p .Flags .Set (7 )
}
if !(p .Colspan == 0 ) {
p .Flags .Set (1 )
}
if !(p .Rowspan == 0 ) {
p .Flags .Set (2 )
}
}
func (p *PageTableCell ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageTableCell#34566b6a as nil" )
}
b .PutID (PageTableCellTypeID )
return p .EncodeBare (b )
}
func (p *PageTableCell ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode pageTableCell#34566b6a as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageTableCell#34566b6a: field flags: %w" , err )
}
if p .Flags .Has (7 ) {
if p .Text == nil {
return fmt .Errorf ("unable to encode pageTableCell#34566b6a: field text is nil" )
}
if err := p .Text .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode pageTableCell#34566b6a: field text: %w" , err )
}
}
if p .Flags .Has (1 ) {
b .PutInt (p .Colspan )
}
if p .Flags .Has (2 ) {
b .PutInt (p .Rowspan )
}
return nil
}
func (p *PageTableCell ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageTableCell#34566b6a to nil" )
}
if err := b .ConsumeID (PageTableCellTypeID ); err != nil {
return fmt .Errorf ("unable to decode pageTableCell#34566b6a: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PageTableCell ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode pageTableCell#34566b6a to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode pageTableCell#34566b6a: field flags: %w" , err )
}
}
p .Header = p .Flags .Has (0 )
p .AlignCenter = p .Flags .Has (3 )
p .AlignRight = p .Flags .Has (4 )
p .ValignMiddle = p .Flags .Has (5 )
p .ValignBottom = p .Flags .Has (6 )
if p .Flags .Has (7 ) {
value , err := DecodeRichText (b )
if err != nil {
return fmt .Errorf ("unable to decode pageTableCell#34566b6a: field text: %w" , err )
}
p .Text = value
}
if p .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode pageTableCell#34566b6a: field colspan: %w" , err )
}
p .Colspan = value
}
if p .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode pageTableCell#34566b6a: field rowspan: %w" , err )
}
p .Rowspan = value
}
return nil
}
func (p *PageTableCell ) SetHeader (value bool ) {
if value {
p .Flags .Set (0 )
p .Header = true
} else {
p .Flags .Unset (0 )
p .Header = false
}
}
func (p *PageTableCell ) GetHeader () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PageTableCell ) SetAlignCenter (value bool ) {
if value {
p .Flags .Set (3 )
p .AlignCenter = true
} else {
p .Flags .Unset (3 )
p .AlignCenter = false
}
}
func (p *PageTableCell ) GetAlignCenter () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (3 )
}
func (p *PageTableCell ) SetAlignRight (value bool ) {
if value {
p .Flags .Set (4 )
p .AlignRight = true
} else {
p .Flags .Unset (4 )
p .AlignRight = false
}
}
func (p *PageTableCell ) GetAlignRight () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (4 )
}
func (p *PageTableCell ) SetValignMiddle (value bool ) {
if value {
p .Flags .Set (5 )
p .ValignMiddle = true
} else {
p .Flags .Unset (5 )
p .ValignMiddle = false
}
}
func (p *PageTableCell ) GetValignMiddle () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (5 )
}
func (p *PageTableCell ) SetValignBottom (value bool ) {
if value {
p .Flags .Set (6 )
p .ValignBottom = true
} else {
p .Flags .Unset (6 )
p .ValignBottom = false
}
}
func (p *PageTableCell ) GetValignBottom () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (6 )
}
func (p *PageTableCell ) SetText (value RichTextClass ) {
p .Flags .Set (7 )
p .Text = value
}
func (p *PageTableCell ) GetText () (value RichTextClass , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (7 ) {
return value , false
}
return p .Text , true
}
func (p *PageTableCell ) SetColspan (value int ) {
p .Flags .Set (1 )
p .Colspan = value
}
func (p *PageTableCell ) GetColspan () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .Colspan , true
}
func (p *PageTableCell ) SetRowspan (value int ) {
p .Flags .Set (2 )
p .Rowspan = value
}
func (p *PageTableCell ) GetRowspan () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (2 ) {
return value , false
}
return p .Rowspan , true
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .