1// Licensed to the Apache Software Foundation (ASF) under one 2// or more contributor license agreements. See the NOTICE file 3// distributed with this work for additional information 4// regarding copyright ownership. The ASF licenses this file 5// to you under the Apache License, Version 2.0 (the 6// "License"); you may not use this file except in compliance 7// with the License. You may obtain a copy of the License at 8// 9// http://www.apache.org/licenses/LICENSE-2.0 10// 11// Unless required by applicable law or agreed to in writing, software 12// distributed under the License is distributed on an "AS IS" BASIS, 13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14// See the License for the specific language governing permissions and 15// limitations under the License. 16 17// Code generated by the FlatBuffers compiler. DO NOT EDIT. 18 19package flatbuf 20 21import ( 22 flatbuffers "github.com/google/flatbuffers/go" 23) 24 25/// Exact decimal value represented as an integer value in two's 26/// complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers 27/// are used. The representation uses the endianness indicated 28/// in the Schema. 29type Decimal struct { 30 _tab flatbuffers.Table 31} 32 33func GetRootAsDecimal(buf []byte, offset flatbuffers.UOffsetT) *Decimal { 34 n := flatbuffers.GetUOffsetT(buf[offset:]) 35 x := &Decimal{} 36 x.Init(buf, n+offset) 37 return x 38} 39 40func (rcv *Decimal) Init(buf []byte, i flatbuffers.UOffsetT) { 41 rcv._tab.Bytes = buf 42 rcv._tab.Pos = i 43} 44 45func (rcv *Decimal) Table() flatbuffers.Table { 46 return rcv._tab 47} 48 49/// Total number of decimal digits 50func (rcv *Decimal) Precision() int32 { 51 o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) 52 if o != 0 { 53 return rcv._tab.GetInt32(o + rcv._tab.Pos) 54 } 55 return 0 56} 57 58/// Total number of decimal digits 59func (rcv *Decimal) MutatePrecision(n int32) bool { 60 return rcv._tab.MutateInt32Slot(4, n) 61} 62 63/// Number of digits after the decimal point "." 64func (rcv *Decimal) Scale() int32 { 65 o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) 66 if o != 0 { 67 return rcv._tab.GetInt32(o + rcv._tab.Pos) 68 } 69 return 0 70} 71 72/// Number of digits after the decimal point "." 73func (rcv *Decimal) MutateScale(n int32) bool { 74 return rcv._tab.MutateInt32Slot(6, n) 75} 76 77/// Number of bits per value. The only accepted widths are 128 and 256. 78/// We use bitWidth for consistency with Int::bitWidth. 79func (rcv *Decimal) BitWidth() int32 { 80 o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) 81 if o != 0 { 82 return rcv._tab.GetInt32(o + rcv._tab.Pos) 83 } 84 return 128 85} 86 87/// Number of bits per value. The only accepted widths are 128 and 256. 88/// We use bitWidth for consistency with Int::bitWidth. 89func (rcv *Decimal) MutateBitWidth(n int32) bool { 90 return rcv._tab.MutateInt32Slot(8, n) 91} 92 93func DecimalStart(builder *flatbuffers.Builder) { 94 builder.StartObject(3) 95} 96func DecimalAddPrecision(builder *flatbuffers.Builder, precision int32) { 97 builder.PrependInt32Slot(0, precision, 0) 98} 99func DecimalAddScale(builder *flatbuffers.Builder, scale int32) { 100 builder.PrependInt32Slot(1, scale, 0) 101} 102func DecimalAddBitWidth(builder *flatbuffers.Builder, bitWidth int32) { 103 builder.PrependInt32Slot(2, bitWidth, 128) 104} 105func DecimalEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { 106 return builder.EndObject() 107} 108