All Projects → Flight-School → Codable Diy Kit

Flight-School / Codable Diy Kit

Licence: mit
A template for creating your own Swift Codable encoders and decoders

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Codable Diy Kit

Codablecsv
Read and write CSV files row-by-row or through Swift's Codable interface.
Stars: ✭ 214 (+3.38%)
Mutual labels:  codable, decoder, encoder
IkigaJSON
A high performance JSON library in Swift
Stars: ✭ 316 (+52.66%)
Mutual labels:  encoder, decoder, codable
Xmlcoder
Easy XML parsing using Codable protocols in Swift
Stars: ✭ 460 (+122.22%)
Mutual labels:  codable, decoder, encoder
Fuif
Free Universal Image Format
Stars: ✭ 115 (-44.44%)
Mutual labels:  decoder, encoder
Alfalfa
Purely functional video codec, used for ExCamera and Salsify
Stars: ✭ 1,164 (+462.32%)
Mutual labels:  decoder, encoder
Wx Voice
Convert audio files between Tencent apps (Weixin / Wechat, QQ) and Silk codec with other general formats such as MP3 and M4A
Stars: ✭ 93 (-55.07%)
Mutual labels:  decoder, encoder
Reed Solomon
Reed Solomon BCH encoder and decoder
Stars: ✭ 57 (-72.46%)
Mutual labels:  decoder, encoder
Salsanext
Uncertainty-aware Semantic Segmentation of LiDAR Point Clouds for Autonomous Driving
Stars: ✭ 153 (-26.09%)
Mutual labels:  decoder, encoder
Bbwebimage
A high performance Swift library for downloading, caching and editing web images asynchronously.
Stars: ✭ 128 (-38.16%)
Mutual labels:  decoder, encoder
Silk V3 Decoder
kn007's blog
Stars: ✭ 1,832 (+785.02%)
Mutual labels:  decoder, encoder
Cityengine Sdk
CityEngine is a 3D city modeling software for urban design, visual effects, and VR/AR production. With its C++ SDK you can create plugins and standalone apps capable to execute CityEngine CGA procedural modeling rules.
Stars: ✭ 137 (-33.82%)
Mutual labels:  decoder, encoder
Polar 3gpp Matlab
Matlab simulations of the encoder and SCL decoder for the New Radio polar code from 3GPP Release 15
Stars: ✭ 67 (-67.63%)
Mutual labels:  decoder, encoder
Iced
Blazing fast and correct x86/x64 disassembler, assembler, decoder, encoder for .NET, Rust, Python, JavaScript
Stars: ✭ 1,102 (+432.37%)
Mutual labels:  decoder, encoder
Ffmediatoolkit
FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
Stars: ✭ 156 (-24.64%)
Mutual labels:  decoder, encoder
Ffjpeg
a simple jpeg codec.
Stars: ✭ 58 (-71.98%)
Mutual labels:  decoder, encoder
Swift Html Entities
HTML5 spec-compliant character encoder/decoder for Swift
Stars: ✭ 130 (-37.2%)
Mutual labels:  decoder, encoder
Wav
Battle tested Wav decoder/encoder
Stars: ✭ 139 (-32.85%)
Mutual labels:  decoder, encoder
Ks265codec
ks cloud hevc(h265) encoder decoder test and description
Stars: ✭ 192 (-7.25%)
Mutual labels:  decoder, encoder
Xmlschema
XML Schema validator and data conversion library for Python
Stars: ✭ 201 (-2.9%)
Mutual labels:  decoder, encoder
Encore
Synonym of angkor
Stars: ✭ 19 (-90.82%)
Mutual labels:  decoder, encoder

DIY Codable Encoder / Decoder Kit

In Swift 4, a type that conforms to the Codable protocol can be encoded to or decoded from representations for any format that implements a corresponding Encoder or Decoder type.

At the time of its release, the only reference implementations for these types were the Foundation framework's JSONEncoder / JSONDecoder and PropertyListEncoder and PropertyListDecoder. The implementation details of these types, however, are obfuscated by translation logic from JSONSerialization and PropertyListSerialization.

This repository provides a template that makes it easier for developers to create encoders and decoders for custom formats. The template includes stubbed placeholders for the required types and methods as well as simple tests for encoding and decoding Codable types.

This general structure was used to implement a Codable-compatible encoder and decoder for the MessagePack format.

For more information about the design and implementation of custom encoder and decoder types, see Chapter 7 of Flight School Guide to Swift Codable.

Usage

  • Clone this repository
  • Find all instances of the "<#Format#>" placeholder and replace with the name of your own format
  • Replace the leading underscores in the ___Decoder.swift and ___Encoder.swift files, as well as the source files in the Tests directory
  • Run the command swift package generate-xcodeproj in the root project directory
  • Fill in the missing implementation accordingly

Encoder Structure

public class <#Format#>Encoder {
    public func encode<T>(_ value: T) throws -> Data
                        where T : Encodable
}

final class _<#Format#>Encoder: Encoder {
    final class SingleValueContainer: SingleValueEncodingContainer
    final class UnkeyedContainer: UnkeyedEncodingContainer
    final class KeyedContainer<Key>: KeyedEncodingContainerProtocol
            where Key: CodingKey
}

protocol <#Format#>EncodingContainer: class {}

Decoder Structure

public class <#Format#>Decoder {
    public func decode<T>(_ type: T.Type,
                          from data: Data) throws -> T
                        where T : Decodable
}

final class _<#Format#>Decoder: Decoder {
    final class SingleValueContainer: SingleValueDecodingContainer
    final class UnkeyedContainer: UnkeyedDecodingContainer
    final class KeyedContainer<Key>: KeyedContainer
            where Key: CodingKey
}

protocol <#Format#>DecodingContainer: class {}

License

MIT

Contact

Mattt (@mattt)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].