SwiftyBytes

0.4.3

A binary read/write library written in Swift.
Xenoxiluna/SwiftyBytes

What's New

v0.4.3

2020-07-31T22:40:28Z

SwiftyBytes

Swift 5.X GitHub license Docs Build Status

A binary file read/write library written in swift. It was created with the purpose of being able to somewhat easily read game data files.

NOTE: writeString prefixes the length of the given string as a generic Int. This could cause compatibility issues on 32/64-bit systems

Usage

Write: LittleEndian

var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeVariableLengthString("This is a test!", .ascii)
try writeTest.writeNullTerminatedString("This is my second test!", .ascii)
try writeTest.writeUInt64(866464616516564)

Write: BigEndian

var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeUInt64(866464616516564, bigEndian: true)

Read: LittleEndian

var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readVariableLengthString(.ascii))")
print("\(try reader.readNullTerminatedString(.ascii))")
print("\(try reader.readUInt64())")

Read: BigEndian

var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readUInt64(true))")

License

SwiftyBytes is licensed under the MIT License

Description

  • Swift Tools 5.0.0

Dependencies

  • None
Last updated: Sat Aug 15 2020 14:19:09 GMT-0500 (GMT-05:00)