Swiftpack.co -  ole/HexHexHex as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ole/HexHexHex
A parser for the Intel Hexadecimal Object File Format (.hex), written in Swift.
.package(url: "https://github.com/ole/HexHexHex.git", from: "0.1.0")

HexHexHex

A parser for the Intel Hexadecimal Object File Format (.hex), written in Swift.

Status

Very experimental and untested.

Usage

Add HexHexHex as a Swift Package Manager dependency

dependencies: [
  .package(url: "https://github.com/ole/HexHexHex.git", from: "0.1.0"),
],

Code

Creating a HEXFile value from the text of a .hex file:

import HexHexHex

let hexText = """
  :020000040000FA
  :1000000025001C0C0200080C06006306590AE306D2
  :0C00B000590A000C3000070C2600030069
  :00000001FF
  """
let hexFile = try HEXFile(text: hexText)

The HEXFile value contains an array of Record values that represent the records in the .hex file:

debugPrint(hexFile)
/*
HEXFile (4 records)
  04 extended linear address – 0000
  00 data – address: 0000, data: 25 00 1C 0C 02 00 08 0C 06 00 63 06 59 0A E3 06
  00 data – address: 00B0, data: 59 0A 00 0C 30 00 07 0C 26 00 03 00
  01 end of file
 */

// Get all data records in the file
let dataRecords = hexFile.records.filter { $0.kind == .data }
print(dataRecords)

// Print out the addresses of all data records in the file
for case .data(let address, _) in hexFile.records {
  print(address)
}

Author

Ole Begemann, oleb.net.

License

MIT. See LICENSE.txt.

GitHub

link
Stars: 12
Last commit: 6 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Initial Release
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API