mirror of
git://jb55.com/damus
synced 2024-09-30 00:40:45 +00:00
tags: add u64 decoding function
This will be used for decoding expiries.
This commit is contained in:
parent
71c9bd63fc
commit
3cce42eea1
@ -130,6 +130,22 @@ struct NdbTagElem: Sequence, Hashable, Equatable {
|
||||
return id.id
|
||||
}
|
||||
|
||||
func u64() -> UInt64? {
|
||||
switch self.data() {
|
||||
case .id:
|
||||
return nil
|
||||
case .str(let str):
|
||||
var end_ptr = UnsafeMutablePointer<CChar>(nil as OpaquePointer?)
|
||||
let res = strtoull(str.str, &end_ptr, 10)
|
||||
|
||||
if end_ptr?.pointee == 0 {
|
||||
return res
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func string() -> String {
|
||||
switch self.data() {
|
||||
case .id(let id):
|
||||
|
Loading…
Reference in New Issue
Block a user