SFBOutputSource


@interface SFBOutputSource : NSObject

An output source

  • Returns an initialized \c SFBOutputSource object for the given URL or \c nil on failure

    Declaration

    Objective-C

    + (nullable instancetype)outputSourceForURL:(nonnull NSURL *)url
                                          error:
                                              (NSError *_Nullable *_Nullable)error;

    Parameters

    url

    The URL

    error

    An optional pointer to a \c NSError to receive error information

    Return Value

    An initialized \c SFBOutputSource object for the specified URL, or \c nil on failure

  • Returns an initialized \c SFBOutputSource writing to an internal data object

    Declaration

    Objective-C

    + (nonnull instancetype)dataOutputSource;
  • Returns an initialized \c SFBOutputSource for the given buffer

    Declaration

    Objective-C

    + (nonnull instancetype)outputSourceWithBuffer:(nonnull void *)buffer
                                          capacity:(NSInteger)capacity;

    Parameters

    buffer

    A buffer to receive output

    capacity

    The capacity of \c buffer in bytes

    Return Value

    An initialized \c SFBOutputSource object

  • url

    Returns the URL corresponding to this output source or \c nil if none

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSURL *url;
  • Returns the underlying data object for this output source or \c nil if none

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSData *data;
  • Opens the output source for writing

    Declaration

    Objective-C

    - (BOOL)openReturningError:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Closes the output source

    Declaration

    Objective-C

    - (BOOL)closeReturningError:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Returns \c YES if the output source is open

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isOpen;
  • Reads bytes from the input

    Declaration

    Objective-C

    - (BOOL)readBytes:(nonnull void *)buffer
               length:(NSInteger)length
            bytesRead:(nonnull NSInteger *)bytesRead
                error:(NSError *_Nullable *_Nullable)error;

    Parameters

    buffer

    A buffer to receive data

    length

    The maximum number of bytes to read

    bytesRead

    The number of bytes actually read

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES if any bytes were read, \c NO otherwise

  • Writes bytes to the output

    Declaration

    Objective-C

    - (BOOL)writeBytes:(nonnull const void *)buffer
                length:(NSInteger)length
          bytesWritten:(nonnull NSInteger *)bytesWritten
                 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    buffer

    A buffer of data to write

    length

    The maximum number of bytes to write

    bytesWritten

    The number of bytes actually written

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES if any bytes were written, \c NO otherwise

  • Returns \c YES if the end of input has been reached

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL atEOF;
  • Returns the current offset in the output, in bytes

    Declaration

    Objective-C

    - (BOOL)getOffset:(nonnull NSInteger *)offset
                error:(NSError *_Nullable *_Nullable)error;
  • Returns the length of the output, in bytes

    Declaration

    Objective-C

    - (BOOL)getLength:(nonnull NSInteger *)length
                error:(NSError *_Nullable *_Nullable)error;
  • Returns \c YES if the output is seekable

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL supportsSeeking;
  • Seeks to the specified byte offset

    Declaration

    Objective-C

    - (BOOL)seekToOffset:(NSInteger)offset
                   error:(NSError *_Nullable *_Nullable)error;

    Parameters

    offset

    The desired offset, in bytes

    Return Value

    \c YES on success, \c NO otherwise

SFBDataWriting

  • Writes data to the output

    Declaration

    Objective-C

    - (BOOL)writeData:(nonnull NSData *)data
                error:(NSError *_Nullable *_Nullable)error;

    Parameters

    data

    The data to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

SFBSignedIntegerWriting

  • Writes an 8-bit signed integer to the output

    Declaration

    Objective-C

    - (BOOL)writeInt8:(int8_t)i8 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    i8

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 16-bit signed integer to the output

    Declaration

    Objective-C

    - (BOOL)writeInt16:(int16_t)i16 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    i16

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 32-bit signed integer to the output

    Declaration

    Objective-C

    - (BOOL)writeInt32:(int32_t)i32 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    i32

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 64-bit signed integer to the output

    Declaration

    Objective-C

    - (BOOL)writeInt64:(int64_t)i64 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    i64

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

SFBUnsignedIntegerWriting

  • Writes an 8-bit unsigned integer to the output

    Declaration

    Objective-C

    - (BOOL)writeUInt8:(uint8_t)ui8 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui8

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 16-bit unsigned integer to the output

    Declaration

    Objective-C

    - (BOOL)writeUInt16:(uint16_t)ui16 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui16

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 32-bit unsigned integer to the output

    Declaration

    Objective-C

    - (BOOL)writeUInt32:(uint32_t)ui32 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui32

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 64-bit unsigned integer to the output

    Declaration

    Objective-C

    - (BOOL)writeUInt64:(uint64_t)ui64 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui64

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

SFBBigEndianWriting

  • Writes an 16-bit unsigned integer to the output in big-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt16BigEndian:(uint16_t)ui16
                           error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui16

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 32-bit unsigned integer to the output in big-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt32BigEndian:(uint32_t)ui32
                           error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui32

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 64-bit unsigned integer to the output in big-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt64BigEndian:(uint64_t)ui64
                           error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui64

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

SFBLittleEndianWriting

  • Writes an 16-bit unsigned integer to the output in little-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt16LittleEndian:(uint16_t)ui16
                              error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui16

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 32-bit unsigned integer to the output in little-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt32LittleEndian:(uint32_t)ui32
                              error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui32

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Writes an 64-bit unsigned integer to the output in little-endian format

    Declaration

    Objective-C

    - (BOOL)writeUInt64LittleEndian:(uint64_t)ui64
                              error:(NSError *_Nullable *_Nullable)error;

    Parameters

    ui64

    The value to write

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Reads bytes from the input

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func read(_ buffer: UnsafeMutableRawPointer, length: Int) throws -> Int

    Parameters

    buffer

    A buffer to receive data

    length

    The maximum number of bytes to read

    Return Value

    The number of bytes actually read

  • Writes bytes to the output

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func write(_ buffer: UnsafeRawPointer, length: Int) throws -> Int

    Parameters

    buffer

    A buffer of data to write

    length

    The maximum number of bytes to write

    Return Value

    The number of bytes actually written

  • Returns the current offset in the output, in bytes

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func offset() throws -> Int
  • Returns the length of the output, in bytes

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func length() throws -> Int
  • Writes bytes to the output

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func write(_ data: Data) throws

    Parameters

    data

    The data to write

  • Writes a binary integer to the output

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func write<T>(_ i: T) throws where T : BinaryInteger

    Parameters

    i

    The value to write

  • Writes a 16-bit integer to the output in big-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeBigEndian(_ ui16: UInt16) throws

    Parameters

    ui16

    The value to write

  • Writes a 32-bit integer to the output in big-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeBigEndian(_ ui32: UInt32) throws

    Parameters

    ui32

    The value to write

  • Writes a 64-bit integer to the output in little-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeBigEndian(_ ui64: UInt64) throws

    Parameters

    ui64

    The value to write

  • Writes a 16-bit integer to the output in big-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeLittleEndian(_ ui16: UInt16) throws

    Parameters

    ui16

    The value to write

  • Writes a 32-bit integer to the output in little-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeLittleEndian(_ ui32: UInt32) throws

    Parameters

    ui32

    The value to write

  • Writes a 64-bit integer to the output in little-endian format

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func writeLittleEndian(_ ui64: UInt64) throws

    Parameters

    ui64

    The value to write