* Set the optional value (begin phase) * @this {!FieldModelOptional} * @param {boolean} hasValue Optional has value flag * @returns {!number} Optional begin offset
(hasValue)
| 2291 | * @returns {!number} Optional begin offset |
| 2292 | */ |
| 2293 | setBegin (hasValue) { |
| 2294 | console.assert(((this._buffer.offset + this.fbeOffset + this.fbeSize) <= this._buffer.size), 'Model is broken!') |
| 2295 | if ((this._buffer.offset + this.fbeOffset + this.fbeSize) > this._buffer.size) { |
| 2296 | return 0 |
| 2297 | } |
| 2298 | |
| 2299 | this.writeUInt8(this.fbeOffset, (hasValue ? 1 : 0)) |
| 2300 | if (!hasValue) { |
| 2301 | return 0 |
| 2302 | } |
| 2303 | |
| 2304 | let fbeOptionalSize = this.value.fbeSize |
| 2305 | let fbeOptionalOffset = this._buffer.allocate(fbeOptionalSize) - this._buffer.offset |
| 2306 | console.assert(((fbeOptionalOffset > 0) && ((this._buffer.offset + fbeOptionalOffset + fbeOptionalSize) <= this._buffer.size)), 'Model is broken!') |
| 2307 | if ((fbeOptionalOffset <= 0) || ((this._buffer.offset + fbeOptionalOffset + fbeOptionalSize) > this._buffer.size)) { |
| 2308 | return 0 |
| 2309 | } |
| 2310 | |
| 2311 | this.writeUInt32(this.fbeOffset + 1, fbeOptionalOffset) |
| 2312 | |
| 2313 | this._buffer.shift(fbeOptionalOffset) |
| 2314 | return fbeOptionalOffset |
| 2315 | } |
| 2316 | |
| 2317 | /** |
| 2318 | * Set the optional value (end phase) |
no test coverage detected