// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// PageTableCell represents TL type `pageTableCell#34566b6a`.
// Table cell
//
// See https://core.telegram.org/constructor/pageTableCell for reference.
type PageTableCell struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this element part of the column header
	Header bool
	// Horizontally centered block
	AlignCenter bool
	// Right-aligned block
	AlignRight bool
	// Vertically centered block
	ValignMiddle bool
	// Block vertically-aligned to the bottom
	ValignBottom bool
	// Content
	//
	// Use SetText and GetText helpers.
	Text RichTextClass
	// For how many columns should this cell extend
	//
	// Use SetColspan and GetColspan helpers.
	Colspan int
	// For how many rows should this cell extend
	//
	// Use SetRowspan and GetRowspan helpers.
	Rowspan int
}

// PageTableCellTypeID is TL type id of PageTableCell.
const PageTableCellTypeID = 0x34566b6a

// Ensuring interfaces in compile-time for PageTableCell.
var (
	_ bin.Encoder     = &PageTableCell{}
	_ bin.Decoder     = &PageTableCell{}
	_ bin.BareEncoder = &PageTableCell{}
	_ bin.BareDecoder = &PageTableCell{}
)

func ( *PageTableCell) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Header == false) {
		return false
	}
	if !(.AlignCenter == false) {
		return false
	}
	if !(.AlignRight == false) {
		return false
	}
	if !(.ValignMiddle == false) {
		return false
	}
	if !(.ValignBottom == false) {
		return false
	}
	if !(.Text == nil) {
		return false
	}
	if !(.Colspan == 0) {
		return false
	}
	if !(.Rowspan == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *PageTableCell) () string {
	if  == nil {
		return "PageTableCell(nil)"
	}
	type  PageTableCell
	return fmt.Sprintf("PageTableCell%+v", (*))
}

// FillFrom fills PageTableCell from given interface.
func ( *PageTableCell) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( RichTextClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.Header = .()
	.AlignCenter = .()
	.AlignRight = .()
	.ValignMiddle = .()
	.ValignBottom = .()
	if ,  := .();  {
		.Text = 
	}

	if ,  := .();  {
		.Colspan = 
	}

	if ,  := .();  {
		.Rowspan = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PageTableCell) () uint32 {
	return PageTableCellTypeID
}

// TypeName returns name of type in TL schema.
func (*PageTableCell) () string {
	return "pageTableCell"
}

// TypeInfo returns info about TL type.
func ( *PageTableCell) () tdp.Type {
	 := tdp.Type{
		Name: "pageTableCell",
		ID:   PageTableCellTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Header",
			SchemaName: "header",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "AlignCenter",
			SchemaName: "align_center",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "AlignRight",
			SchemaName: "align_right",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ValignMiddle",
			SchemaName: "valign_middle",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "ValignBottom",
			SchemaName: "valign_bottom",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Text",
			SchemaName: "text",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Colspan",
			SchemaName: "colspan",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Rowspan",
			SchemaName: "rowspan",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PageTableCell) () {
	if !(.Header == false) {
		.Flags.Set(0)
	}
	if !(.AlignCenter == false) {
		.Flags.Set(3)
	}
	if !(.AlignRight == false) {
		.Flags.Set(4)
	}
	if !(.ValignMiddle == false) {
		.Flags.Set(5)
	}
	if !(.ValignBottom == false) {
		.Flags.Set(6)
	}
	if !(.Text == nil) {
		.Flags.Set(7)
	}
	if !(.Colspan == 0) {
		.Flags.Set(1)
	}
	if !(.Rowspan == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PageTableCell) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageTableCell#34566b6a as nil")
	}
	.PutID(PageTableCellTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PageTableCell) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageTableCell#34566b6a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode pageTableCell#34566b6a: field flags: %w", )
	}
	if .Flags.Has(7) {
		if .Text == nil {
			return fmt.Errorf("unable to encode pageTableCell#34566b6a: field text is nil")
		}
		if  := .Text.Encode();  != nil {
			return fmt.Errorf("unable to encode pageTableCell#34566b6a: field text: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutInt(.Colspan)
	}
	if .Flags.Has(2) {
		.PutInt(.Rowspan)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PageTableCell) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageTableCell#34566b6a to nil")
	}
	if  := .ConsumeID(PageTableCellTypeID);  != nil {
		return fmt.Errorf("unable to decode pageTableCell#34566b6a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PageTableCell) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageTableCell#34566b6a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode pageTableCell#34566b6a: field flags: %w", )
		}
	}
	.Header = .Flags.Has(0)
	.AlignCenter = .Flags.Has(3)
	.AlignRight = .Flags.Has(4)
	.ValignMiddle = .Flags.Has(5)
	.ValignBottom = .Flags.Has(6)
	if .Flags.Has(7) {
		,  := DecodeRichText()
		if  != nil {
			return fmt.Errorf("unable to decode pageTableCell#34566b6a: field text: %w", )
		}
		.Text = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode pageTableCell#34566b6a: field colspan: %w", )
		}
		.Colspan = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode pageTableCell#34566b6a: field rowspan: %w", )
		}
		.Rowspan = 
	}
	return nil
}

// SetHeader sets value of Header conditional field.
func ( *PageTableCell) ( bool) {
	if  {
		.Flags.Set(0)
		.Header = true
	} else {
		.Flags.Unset(0)
		.Header = false
	}
}

// GetHeader returns value of Header conditional field.
func ( *PageTableCell) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetAlignCenter sets value of AlignCenter conditional field.
func ( *PageTableCell) ( bool) {
	if  {
		.Flags.Set(3)
		.AlignCenter = true
	} else {
		.Flags.Unset(3)
		.AlignCenter = false
	}
}

// GetAlignCenter returns value of AlignCenter conditional field.
func ( *PageTableCell) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetAlignRight sets value of AlignRight conditional field.
func ( *PageTableCell) ( bool) {
	if  {
		.Flags.Set(4)
		.AlignRight = true
	} else {
		.Flags.Unset(4)
		.AlignRight = false
	}
}

// GetAlignRight returns value of AlignRight conditional field.
func ( *PageTableCell) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetValignMiddle sets value of ValignMiddle conditional field.
func ( *PageTableCell) ( bool) {
	if  {
		.Flags.Set(5)
		.ValignMiddle = true
	} else {
		.Flags.Unset(5)
		.ValignMiddle = false
	}
}

// GetValignMiddle returns value of ValignMiddle conditional field.
func ( *PageTableCell) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetValignBottom sets value of ValignBottom conditional field.
func ( *PageTableCell) ( bool) {
	if  {
		.Flags.Set(6)
		.ValignBottom = true
	} else {
		.Flags.Unset(6)
		.ValignBottom = false
	}
}

// GetValignBottom returns value of ValignBottom conditional field.
func ( *PageTableCell) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// SetText sets value of Text conditional field.
func ( *PageTableCell) ( RichTextClass) {
	.Flags.Set(7)
	.Text = 
}

// GetText returns value of Text conditional field and
// boolean which is true if field was set.
func ( *PageTableCell) () ( RichTextClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .Text, true
}

// SetColspan sets value of Colspan conditional field.
func ( *PageTableCell) ( int) {
	.Flags.Set(1)
	.Colspan = 
}

// GetColspan returns value of Colspan conditional field and
// boolean which is true if field was set.
func ( *PageTableCell) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Colspan, true
}

// SetRowspan sets value of Rowspan conditional field.
func ( *PageTableCell) ( int) {
	.Flags.Set(2)
	.Rowspan = 
}

// GetRowspan returns value of Rowspan conditional field and
// boolean which is true if field was set.
func ( *PageTableCell) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Rowspan, true
}