mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user