SFBInputSource


@interface SFBInputSource : NSObject

An input source

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

    Declaration

    Objective-C

    + (nullable instancetype)inputSourceForURL:(nonnull NSURL *)url
                                         flags:(SFBInputSourceFlags)flags
                                         error:(NSError *_Nullable *_Nullable)error;

    Parameters

    url

    The URL

    flags

    Optional flags affecting how \c url is handled

    error

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

    Return Value

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

  • Returns an initialized \c SFBInputSource for the given \c NSData object

    Declaration

    Objective-C

    + (nonnull instancetype)inputSourceWithData:(nonnull NSData *)data;

    Parameters

    data

    The desired data

    Return Value

    An initialized \c SFBInputSource object

  • Returns an initialized \c SFBInputSource for the given byte buffer or \c nil on failure

    Declaration

    Objective-C

    + (nullable instancetype)inputSourceWithBytes:(nonnull const void *)bytes
                                           length:(NSInteger)length;

    Parameters

    bytes

    A pointer to the desired byte buffer

    length

    The number of bytes in \c bytes

    Return Value

    An initialized \c SFBInputSource object or \c nil on faliure

  • Returns an initialized \c SFBInputSource for the given byte buffer or \c nil on failure

    Note

    If \c freeWhenDone is \c YES, \c bytes must point to a buffer allocated with \c malloc

    Declaration

    Objective-C

    + (nullable instancetype)inputSourceWithBytesNoCopy:(nonnull void *)bytes
                                                 length:(NSInteger)length
                                           freeWhenDone:(BOOL)freeWhenDone;

    Parameters

    bytes

    A pointer to the desired byte buffer

    length

    The number of bytes in \c bytes

    freeWhenDone

    If \c YES the returned object takes ownership of \c bytes and frees it on deallocation

    Return Value

    An initialized \c SFBInputSource object or \c nil on faliure

  • url

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

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSURL *url;
  • Opens the input source for reading

    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 input 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 input 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

  • 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 input, in bytes

    Declaration

    Objective-C

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

    Declaration

    Objective-C

    - (BOOL)getLength:(nonnull NSInteger *)length
                error:(NSError *_Nullable *_Nullable)error;
  • Returns \c YES if the input 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

SFBSignedIntegerReading

  • Reads an 8-bit signed integer from the input

    Declaration

    Objective-C

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

    Parameters

    i8

    A pointer to an \c int8_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads a 16-bit signed integer from the input

    Declaration

    Objective-C

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

    Parameters

    i16

    A pointer to an \c int16_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 32-bit signed integer from the input

    Declaration

    Objective-C

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

    Parameters

    i32

    A pointer to an \c int32_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 64-bit signed integer from the input

    Declaration

    Objective-C

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

    Parameters

    i64

    A pointer to an \c int64_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

SFBUnsignedIntegerReading

  • Reads an 8-bit unsigned integer from the input

    Declaration

    Objective-C

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

    Parameters

    ui8

    A pointer to an \c uint8_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads a 16-bit unsigned integer from the input

    Declaration

    Objective-C

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

    Parameters

    ui16

    A pointer to an \c uint16_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 32-bit unsigned integer from the input

    Declaration

    Objective-C

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

    Parameters

    ui32

    A pointer to an \c uint32_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 64-bit unsigned integer from the input

    Declaration

    Objective-C

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

    Parameters

    ui64

    A pointer to an \c uint64_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

SFBBigEndianReading

  • Reads a 16-bit unsigned integer from the input in big-endian format

    Declaration

    Objective-C

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

    Parameters

    ui16

    A pointer to an \c uint16_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 32-bit unsigned integer from the input in big-endian format

    Declaration

    Objective-C

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

    Parameters

    ui32

    A pointer to an \c uint32_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 64-bit unsigned integer from the input in big-endian format

    Declaration

    Objective-C

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

    Parameters

    ui64

    A pointer to an \c uint64_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

SFBLittleEndianReading

  • Reads a 16-bit unsigned integer from the input in little-endian format

    Declaration

    Objective-C

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

    Parameters

    ui16

    A pointer to an \c uint16_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 32-bit unsigned integer from the input in little-endian format

    Declaration

    Objective-C

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

    Parameters

    ui32

    A pointer to an \c uint32_t to receive the value

    error

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

    Return Value

    \c YES on success, \c NO otherwise

  • Reads an 64-bit unsigned integer from the input in little-endian format

    Declaration

    Objective-C

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

    Parameters

    ui64

    A pointer to an \c uint64_t to receive the value

    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

  • Returns the current offset in the input, in bytes

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

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

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func length() throws -> Int
  • Reads and returns a binary integer

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func read<T>() throws -> T where T : BinaryInteger

    Return Value

    The integer value read

  • Reads a 16-bit integer from the input in big-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readBigEndian() throws -> UInt16
  • Reads a 32-bit integer from the input in big-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readBigEndian() throws -> UInt32
  • Reads a 64-bit integer from the input in big-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readBigEndian() throws -> UInt64
  • Reads a 16-bit integer from the input in little-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readLittleEndian() throws -> UInt16
  • Reads a 32-bit integer from the input in little-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readLittleEndian() throws -> UInt32
  • Reads a 64-bit integer from the input in little-endian format and returns the value

    Throws

    An NSError object if an error occurs

    Declaration

    Swift

    public func readLittleEndian() throws -> UInt64