0001    //
0002    //  Operators.swift
0003    //  Himotoki
0004    //
0005    //  Created by Syo Ikeda on 5/2/15.
0006    //  Copyright (c) 2015 Syo Ikeda. All rights reserved.
0007    //
0008    
0009    infix operator <| { associativity left precedence 150 }
0010    infix operator <|? { associativity left precedence 150 }
0011    infix operator <|| { associativity left precedence 150 }
0012    infix operator <||? { associativity left precedence 150 }
0013    infix operator <|-| { associativity left precedence 150 }
0014    infix operator <|-|? { associativity left precedence 150 }
0015    
0016    /// - Throws: DecodeError
0017    public func <| <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> T {
0018        return try e.value(keyPath)
0019    }
0020    
0021    /// - Throws: DecodeError
0022    public func <|? <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> T? {
0023        return try e.valueOptional(keyPath)
0024    }
0025    
0026    /// - Throws: DecodeError
0027    public func <|| <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> [T] {
0028        return try e.array(keyPath)
0029    }
0030    
0031    /// - Throws: DecodeError
0032    public func <||? <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> [T]? {
0033        return try e.arrayOptional(keyPath)
0034    }
0035    
0036    /// - Throws: DecodeError
0037    public func <|-| <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> [String: T] {
0038        return try e.dictionary(keyPath)
0039    }
0040    
0041    /// - Throws: DecodeError
0042    public func <|-|? <T: Decodable where T.DecodedType == T>(e: Extractor, keyPath: KeyPath) throws -> [String: T]? {
0043        return try e.dictionaryOptional(keyPath)
0044    }
0045