BinaryWriter

public class BinaryWriter

This is a class created for writing data in a linear order

  • Undocumented

    Declaration

    Swift

    public var data: BinaryData
  • Undocumented

    Declaration

    Swift

    public init(data: [UInt8])
  • Undocumented

    Declaration

    Swift

    public init(data: Data)
  • Undocumented

    Declaration

    Swift

    public init()
  • Call this function to add the given UInt8 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeUInt8(65)
    

    Declaration

    Swift

    public func writeUInt8(_ uint: UInt8) throws -> Bool
  • Call this function to add the given UInt16 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeUInt8(65)
    

    Declaration

    Swift

    public func writeUInt16(_ uint: UInt16, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given UInt32 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeUInt32(65)
    

    Declaration

    Swift

    public func writeUInt32(_ uint: UInt32, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given UInt64 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeUInt64(65)
    

    Declaration

    Swift

    public func writeUInt64(_ uint: UInt64, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Int8 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeInt8(65)
    

    Declaration

    Swift

    public func writeInt8(_ int: Int8) throws -> Bool
  • Call this function to add the given Int16 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeInt16(65)
    

    Declaration

    Swift

    public func writeInt16(_ int: Int16, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Int32 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeInt32(65)
    

    Declaration

    Swift

    public func writeInt32(_ int: Int32, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Int64 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeInt64(65)
    

    Declaration

    Swift

    public func writeInt64(_ int: Int64, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Float32 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeFloat32(65)
    

    Declaration

    Swift

    public func writeFloat32(_ float32: Float32, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Float64 to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeFloat64(65)
    

    Declaration

    Swift

    public func writeFloat64(_ float64: Float64, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Double to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeDouble(65)
    

    Declaration

    Swift

    public func writeDouble(_ double: Double, bigEndian: Bool? = false) throws -> Bool
  • Call this function to add the given Bool to the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeBool(true)
    

    Declaration

    Swift

    public func writeBool(_ bool: Bool) throws -> Bool
  • Call this function for storing a Length prefixed String into the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeString("This is a test!", .ascii)
    

    Declaration

    Swift

    public func writeString(_ string: String, _ encoding: String.Encoding) throws -> Bool
  • Call this function for storing a string as Null Terminated UTF8 into the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeNullTerminatedUTF8String("This is a test!")
    

    Declaration

    Swift

    public func writeNullTerminatedUTF8String(_ string: String) throws -> Bool
  • Call this function for storing a 7 bit encoded String into the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.writeVariableLengthString("This is a test!", .ascii)
    

    Declaration

    Swift

    public func writeVariableLengthString(_ string: String, _ encoding: String.Encoding) throws -> Bool
  • Call this function for storing a 7 bit encoded String into the data array

    Usage Example:

    var writeTest: BinaryWriter = BinaryWriter()
    try writeTest.write([0, 1, 3, 4])
    

    Declaration

    Swift

    public func write(_ bytes: [UInt8]) throws -> Bool
  • Undocumented

    Declaration

    Swift

    public func writeBit(_ on: Bool, _ bitOffset: Int) throws -> Bool