| FlatBuffers An open source project by FPL.

Public Member Functions | Public Attributes | List of all members
Google\FlatBuffers\FlatbufferBuilder Class Reference
Flatbuffers_php_api

## Public Member Functions
| __construct ($initial_size)
| Create a FlatBufferBuilder with a given initial size. More...
| addBool ($x)
| Add a `bool` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addByte ($x)
| Add a `byte` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addDouble ($x)
| Add a `double` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addFloat ($x)
| Add a `float` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addInt ($x)
| Add an `int` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addLong ($x)
| Add a `long` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addOffset ($off)
| Adds on offset, relative to where it will be written. More...
| addSbyte ($x)
| Add a `signed byte` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addShort ($x)
| Add a `short` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addUint ($x)
| Add an `unsigned int` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addUlong ($x)
| Add an `unsigned long` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| addUshort ($x)
| Add an `unsigned short` to the buffer, properly aligned, and grows the buffer (if necessary). More...
| createString ($s)
| Encode the string `$s` in the buffer using UTF-8. More...
| dataBuffer ()
| Get the ByteBuffer representing the FlatBuffer. More...
| finish ($root_table, $identifier=null)
| Finalize a buffer, pointing to the given `$root_table`. More...
| forceDefaults ($forceDefaults)
| In order to save space, fields that are set to their default value don't get serialized into the buffer. More...
| sizedByteArray ()
| Utility function to copy and return the FlatBuffer data from the underlying ByteBuffer. More...

## Public Attributes
| $bb
| Internal ByteBuffer for the FlatBuffer data.

## Constructor & Destructor Documentation

## ◆ __construct()

Google\FlatBuffers\FlatbufferBuilder::__construct | ( |  | $initial_size | ) |

Create a FlatBufferBuilder with a given initial size.

Parameters

  $initial_size | initial byte buffer size.

## Member Function Documentation

## ◆ addBool()

Google\FlatBuffers\FlatbufferBuilder::addBool | ( |  | $x | ) |

Add a `bool` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `bool` to add to the buffer.

## ◆ addByte()

Google\FlatBuffers\FlatbufferBuilder::addByte | ( |  | $x | ) |

Add a `byte` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `byte` to add to the buffer.

## ◆ addDouble()

Google\FlatBuffers\FlatbufferBuilder::addDouble | ( |  | $x | ) |

Add a `double` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `double` to add to the buffer.

## ◆ addFloat()

Google\FlatBuffers\FlatbufferBuilder::addFloat | ( |  | $x | ) |

Add a `float` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `float` to add to the buffer.

## ◆ addInt()

Google\FlatBuffers\FlatbufferBuilder::addInt | ( |  | $x | ) |

Add an `int` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `int` to add to the buffer.

## ◆ addLong()

Google\FlatBuffers\FlatbufferBuilder::addLong | ( |  | $x | ) |

Add a `long` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `long` to add to the buffer.

## ◆ addOffset()

Google\FlatBuffers\FlatbufferBuilder::addOffset | ( |  | $off | ) |

Adds on offset, relative to where it will be written.

Parameters

  $off | The offset to add to the buffer.

Exceptions

Exception Throws an exception if `$off` is greater than the underlying ByteBuffer's offest.

## ◆ addSbyte()

Google\FlatBuffers\FlatbufferBuilder::addSbyte | ( |  | $x | ) |

Add a `signed byte` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `signed byte` to add to the buffer.

## ◆ addShort()

Google\FlatBuffers\FlatbufferBuilder::addShort | ( |  | $x | ) |

Add a `short` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `short` to add to the buffer.

## ◆ addUint()

Google\FlatBuffers\FlatbufferBuilder::addUint | ( |  | $x | ) |

Add an `unsigned int` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `unsigned int` to add to the buffer.

## ◆ addUlong()

Google\FlatBuffers\FlatbufferBuilder::addUlong | ( |  | $x | ) |

Add an `unsigned long` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `unsigned long` to add to the buffer.

## ◆ addUshort()

Google\FlatBuffers\FlatbufferBuilder::addUshort | ( |  | $x | ) |

Add an `unsigned short` to the buffer, properly aligned, and grows the buffer (if necessary).

Parameters

  $x | The `unsigned short` to add to the buffer.

## ◆ createString()

Google\FlatBuffers\FlatbufferBuilder::createString | ( |  | $s | ) |

Encode the string `$s` in the buffer using UTF-8.

Parameters

  string | $s | The string to encode.

Returns
  int The offset in the buffer where the encoded string starts.

Exceptions

  InvalidArgumentException | Thrown if the input string `$s` is not UTF-8.

## ◆ dataBuffer()

Google\FlatBuffers\FlatbufferBuilder::dataBuffer | ( |  | ) |

Get the ByteBuffer representing the FlatBuffer.

Returns
  ByteBuffer The ByteBuffer containing the FlatBuffer data.

## ◆ finish()

Google\FlatBuffers\FlatbufferBuilder::finish | ( |  | $root_table,
|  |  | $identifier = `null`
| ) |  |

Finalize a buffer, pointing to the given `$root_table`.

Parameters

  $root_table | An offest to be added to the buffer.
  $file_identifier | A FlatBuffer file identifier to be added to the buffer before `$root_table`. This defaults to `null`.

Exceptions

  InvalidArgumentException | Thrown if an invalid `$identifier` is given, where its length is not equal to `Constants::FILE_IDENTIFIER_LENGTH`.

## ◆ forceDefaults()

Google\FlatBuffers\FlatbufferBuilder::forceDefaults | ( |  | $forceDefaults | ) |

In order to save space, fields that are set to their default value don't get serialized into the buffer.

Parameters

  bool | $forceDefaults | When set to `true`, always serializes default values.

## ◆ sizedByteArray()

Google\FlatBuffers\FlatbufferBuilder::sizedByteArray | ( |  | ) |

Utility function to copy and return the FlatBuffer data from the underlying ByteBuffer.

Returns
  string A string (representing a byte[]) that contains a copy of the FlatBuffer data.

The documentation for this class was generated from the following file:

- FlatbufferBuilder.php