Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class BoolEncoder: SingleValueEncodingContainer {
- var codingPath: [CodingKey]
- private(set) var value: Bool?
- init() {
- codingPath = []
- }
- func encodeNil() throws {
- value = nil
- }
- func encode(_ value: Bool) throws {
- self.value = value
- }
- func encode(_ value: String) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Double) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Float) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Int) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Int8) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Int16) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Int32) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: Int64) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: UInt) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: UInt8) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: UInt16) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: UInt32) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode(_ value: UInt64) throws {
- fatalError("\(type(of: self)) only supports bools.")
- }
- func encode<T>(_ value: T) throws where T : Encodable {
- fatalError("\(type(of: self)) only supports bools.")
- }
- }
Add Comment
Please, Sign In to add comment