[Swift] Optional Scalars Preparation (#6028)

* Perpares swift to take optional scalars + adds optional string helper method + disables linters in generated code

* Small fix for generated code

* Update grpc support to alpha 17 for swift
This commit is contained in:
mustiikhalil
2020-07-20 20:38:50 +03:00
committed by GitHub
parent 2e48c8dd31
commit ff1b73128d
12 changed files with 75 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FlatBuffers'
s.version = '0.6.0'
s.version = '0.7.0'
s.summary = 'FlatBuffers: Memory Efficient Serialization Library'
s.description = "FlatBuffers is a cross platform serialization library architected for

View File

@@ -395,6 +395,14 @@ public struct FlatBufferBuilder {
return Offset(offset: _bb.size)
}
/// Insets a string into the buffer using UTF8
/// - Parameter str: String to be serialized
/// - returns: The strings offset in the buffer
mutating public func create(string str: String?) -> Offset<String> {
guard let str = str else { return Offset() }
return create(string: str)
}
/// Inserts a shared string to the buffer
///
/// The function checks the stringOffsetmap if it's seen a similar string before
@@ -441,6 +449,15 @@ public struct FlatBufferBuilder {
track(offset: push(element: element), at: position)
}
/// Adds a value into the buffer of type optional Scalar
/// - Parameters:
/// - element: Optional element of type scalar
/// - position: The predefined position of the element
mutating public func add<T: Scalar>(element: T?, at position: VOffset) {
guard let element = element else { return }
track(offset: push(element: element), at: position)
}
/// Pushes the values into the buffer
/// - Parameter element: Element to insert
/// - returns: Postion of the Element