1 /* 2 * Copyright 2024 Google Inc. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import Foundation 18 19 /// `VerifierOptions` is a set of options to verify a flatbuffer 20 public struct VerifierOptions { 21 22 /// Maximum `Apparent` size if the buffer can be expanded into a DAG tree 23 internal var _maxApparentSize: UOffset 24 25 /// Maximum table count allowed in a buffer 26 internal var _maxTableCount: UOffset 27 28 /// Maximum depth allowed in a buffer 29 internal var _maxDepth: UOffset 30 31 /// Ignoring missing null terminals in strings 32 internal var _ignoreMissingNullTerminators: Bool 33 34 /// initializes the set of options for the verifier 35 /// - Parameters: 36 /// - maxDepth: Maximum depth allowed in a buffer 37 /// - maxTableCount: Maximum table count allowed in a buffer 38 /// - maxApparentSize: Maximum `Apparent` size if the buffer can be expanded into a DAG tree 39 /// - ignoreMissingNullTerminators: Ignoring missing null terminals in strings *Currently not supported in swift* 40 public init( 41 maxDepth: UOffset = 64, 42 maxTableCount: UOffset = 1000000, 43 maxApparentSize: UOffset = 1 << 31, 44 ignoreMissingNullTerminators: Bool = false) 45 { 46 _maxDepth = maxDepth 47 _maxTableCount = maxTableCount 48 _maxApparentSize = maxApparentSize 49 _ignoreMissingNullTerminators = ignoreMissingNullTerminators 50 } 51 52 } 53