...

Text file src/github.com/google/flatbuffers/tests/ts/reflection/key-value.ts

Documentation: github.com/google/flatbuffers/tests/ts/reflection

     1// automatically generated by the FlatBuffers compiler, do not modify
     2
     3import * as flatbuffers from 'flatbuffers';
     4
     5
     6
     7export class KeyValue implements flatbuffers.IUnpackableObject<KeyValueT> {
     8  bb: flatbuffers.ByteBuffer|null = null;
     9  bb_pos = 0;
    10  __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue {
    11  this.bb_pos = i;
    12  this.bb = bb;
    13  return this;
    14}
    15
    16static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
    17  return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    18}
    19
    20static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue {
    21  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
    22  return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
    23}
    24
    25key():string|null
    26key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
    27key(optionalEncoding?:any):string|Uint8Array|null {
    28  const offset = this.bb!.__offset(this.bb_pos, 4);
    29  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
    30}
    31
    32value():string|null
    33value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
    34value(optionalEncoding?:any):string|Uint8Array|null {
    35  const offset = this.bb!.__offset(this.bb_pos, 6);
    36  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
    37}
    38
    39static getFullyQualifiedName():string {
    40  return 'reflection.KeyValue';
    41}
    42
    43static startKeyValue(builder:flatbuffers.Builder) {
    44  builder.startObject(2);
    45}
    46
    47static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) {
    48  builder.addFieldOffset(0, keyOffset, 0);
    49}
    50
    51static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
    52  builder.addFieldOffset(1, valueOffset, 0);
    53}
    54
    55static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset {
    56  const offset = builder.endObject();
    57  builder.requiredField(offset, 4) // key
    58  return offset;
    59}
    60
    61static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset {
    62  KeyValue.startKeyValue(builder);
    63  KeyValue.addKey(builder, keyOffset);
    64  KeyValue.addValue(builder, valueOffset);
    65  return KeyValue.endKeyValue(builder);
    66}
    67
    68unpack(): KeyValueT {
    69  return new KeyValueT(
    70    this.key(),
    71    this.value()
    72  );
    73}
    74
    75
    76unpackTo(_o: KeyValueT): void {
    77  _o.key = this.key();
    78  _o.value = this.value();
    79}
    80}
    81
    82export class KeyValueT implements flatbuffers.IGeneratedObject {
    83constructor(
    84  public key: string|Uint8Array|null = null,
    85  public value: string|Uint8Array|null = null
    86){}
    87
    88
    89pack(builder:flatbuffers.Builder): flatbuffers.Offset {
    90  const key = (this.key !== null ? builder.createString(this.key!) : 0);
    91  const value = (this.value !== null ? builder.createString(this.value!) : 0);
    92
    93  return KeyValue.createKeyValue(builder,
    94    key,
    95    value
    96  );
    97}
    98}

View as plain text