@@ -9,95 +9,15 @@ import HTMLKitUtilities
99
1010// MARK: StaticString equality
1111public extension StaticString {
12- static func == ( left: Self , right: String ) -> Bool { left. string == right }
13-
14- static func == ( left: Self , right: Self ) -> Bool { left. string == right. string }
15- static func != ( left: Self , right: Self ) -> Bool { left. string != right. string }
16- var string : String {
17- withUTF8Buffer {
18- String ( decoding: $0, as: UTF8 . self)
19- }
20- }
21- /*func string(with replacements: [String]) -> String {
22- return withUTF8Buffer { p in
23- let values = p.split(separator: 96)
24- let last:Int = values.count-1
25- var amount:Int = p.count - last
26- for i in 0..<values.count-1 {
27- amount += replacements[i].count
28- }
29- let buffer:UnsafeMutableBufferPointer<UInt8> = .allocate(capacity: amount)
30- var new_index:Int = 0
31- for index in 0..<values.count {
32- let value:UnsafeBufferPointer<UInt8>.SubSequence = values[index]
33- for i in 0..<value.count {
34- buffer[new_index] = value[value.index(value.startIndex, offsetBy: i)]
35- new_index += 1
36- }
37- if index != last {
38- for char in replacements[index] {
39- buffer[new_index] = char.asciiValue!
40- new_index += 1
41- }
42- }
43- }
44- return String(decoding: buffer, as: UTF8.self)
45- }
46- }*/
12+ static func == ( left: Self , right: String ) -> Bool { left. description == right }
13+
14+ static func == ( left: Self , right: Self ) -> Bool { left. description == right. description }
15+ static func != ( left: Self , right: Self ) -> Bool { left. description != right. description }
4716}
4817public extension String {
49- static func == ( left: Self , right: StaticString ) -> Bool { left == right. string }
18+ static func == ( left: Self , right: StaticString ) -> Bool { left == right. description }
5019}
5120
52- /*
53- // MARK: DynamicString
54- public struct DynamicString {
55- public let string:StaticString
56- public let values:[String]
57-
58- public init(string: StaticString, values: [String]) {
59- self.string = string
60- self.values = values
61- }
62-
63- public var test : String {
64- return string.string
65- }
66- }*/
67-
68- /*
69- package struct NonCopyableString : ~Copyable {
70- private let storage:UnsafeMutableBufferPointer<UInt8>
71-
72- package init(capacity: Int) {
73- storage = .allocate(capacity: capacity)
74- }
75- package init(_ string: String) {
76- storage = .allocate(capacity: string.count)
77- for i in 0..<string.count {
78- storage[i] = string[string.index(string.startIndex, offsetBy: i)].asciiValue!
79- }
80- }
81-
82- package subscript(_ index: Int) -> UInt8 {
83- get {
84- storage[index]
85- }
86- set {
87- storage[index] = newValue
88- }
89- }
90-
91- package var count : Int { storage.count }
92- package var isEmpty : Bool { storage.isEmpty }
93- package var string : String { String(decoding: storage, as: UTF8.self) }
94-
95- deinit {
96- storage.deinitialize()
97- storage.deallocate()
98- }
99- }*/
100-
10121@freestanding ( expression)
10222public macro escapeHTML< T: ExpressibleByStringLiteral > ( _ innerHTML: T ... ) -> T = #externalMacro( module: " HTMLKitMacros " , type: " HTMLElement " )
10323
0 commit comments