UNPKG

ducjs

Version:

The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.

93 lines (92 loc) 3.84 kB
// automatically generated by the FlatBuffers compiler, do not modify /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ import * as flatbuffers from 'flatbuffers'; export class DucExternalFileData { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsDucExternalFileData(bb, obj) { return (obj || new DucExternalFileData()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsDucExternalFileData(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new DucExternalFileData()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } mimeType(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } id(optionalEncoding) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; } data(index) { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; } dataLength() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } dataArray() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; } created() { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); } lastRetrieved() { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.readInt64(this.bb_pos + offset) : null; } static startDucExternalFileData(builder) { builder.startObject(5); } static addMimeType(builder, mimeTypeOffset) { builder.addFieldOffset(0, mimeTypeOffset, 0); } static addId(builder, idOffset) { builder.addFieldOffset(1, idOffset, 0); } static addData(builder, dataOffset) { builder.addFieldOffset(2, dataOffset, 0); } static createDataVector(builder, data) { builder.startVector(1, data.length, 1); for (let i = data.length - 1; i >= 0; i--) { builder.addInt8(data[i]); } return builder.endVector(); } static startDataVector(builder, numElems) { builder.startVector(1, numElems, 1); } static addCreated(builder, created) { builder.addFieldInt64(3, created, BigInt('0')); } static addLastRetrieved(builder, lastRetrieved) { builder.addFieldInt64(4, lastRetrieved, null); } static endDucExternalFileData(builder) { const offset = builder.endObject(); builder.requiredField(offset, 6); // id return offset; } static createDucExternalFileData(builder, mimeTypeOffset, idOffset, dataOffset, created, lastRetrieved) { DucExternalFileData.startDucExternalFileData(builder); DucExternalFileData.addMimeType(builder, mimeTypeOffset); DucExternalFileData.addId(builder, idOffset); DucExternalFileData.addData(builder, dataOffset); DucExternalFileData.addCreated(builder, created); if (lastRetrieved !== null) DucExternalFileData.addLastRetrieved(builder, lastRetrieved); return DucExternalFileData.endDucExternalFileData(builder); } }