added iOS source code
[wl-app.git] / iOS / Pods / OAuthSwift / Sources / Data+OAuthSwift.swift
1 //
2 //  Data+OAuthSwift.swift
3 //  OAuthSwift
4 //
5 //  Created by Dongri Jin on 1/28/15.
6 //  Copyright (c) 2015 Dongri Jin. All rights reserved.
7 //
8
9 import Foundation
10
11 extension Data {
12
13     internal init(data: Data) {
14         self.init()
15         self.append(data)
16     }
17
18     internal mutating func append(_ bytes: [UInt8]) {
19         self.append(bytes, count: bytes.count)
20     }
21     internal mutating func append(_ byte: UInt8) {
22         append([byte])
23     }
24     internal mutating func append(_ byte: UInt16) {
25         append(UInt8(byte >> 0 & 0xFF))
26         append(UInt8(byte >> 8 & 0xFF))
27     }
28     internal  mutating func append(_ byte: UInt32) {
29         append(UInt16(byte >>  0 & 0xFFFF))
30         append(UInt16(byte >> 16 & 0xFFFF))
31     }
32     internal mutating func append(_  byte: UInt64) {
33         append(UInt32(byte >>  0 & 0xFFFFFFFF))
34         append(UInt32(byte >> 32 & 0xFFFFFFFF))
35     }
36
37     var bytes: [UInt8] {
38         return Array(self)
39         /* let count = self.count / MemoryLayout<UInt8>.size
40          var bytesArray = [UInt8](repeating: 0, count: count)
41         self.copyBytes(to:&bytesArray, count: count * MemoryLayout<UInt8>.size)
42         return bytesArray*/
43     }
44
45 }