PerfectINI

0.1.2

Swift encoder and decoder for INI files.
RockfordWei/Perfect-INI

What's New

Improving blanks & trimmings.

2018-01-16T18:51:19Z

Perfect INI Codable

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 4.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

This project provides an encoder / decorder for INI files.

This package builds with Swift Package Manager of Swift 4 Tool Chain and is part of the Perfect project but can be used as an independent module.

Quick Start

This library provides a pair of INIEncoder and INIDecoder for INI files.

Encodable to INI

import PerfectINI
struct Person: Codable {
  public var name = ""
  public var age = 0
}

struct Place: Codable {
  public var location = ""
  public var history = 0
}

struct Configuration: Codable {
  public var id = 0
  public var tag = ""
  public var person = Person()
  public var place = Place()
}

let rocky = Person(name: "rocky", age: 21)
let hongkong = Place(location: "china", history: 1000)

let conf = Configuration(id: 101, tag: "my notes", person: rocky, place: hongkong)
let encoder = INIEncoder()
let data = try encoder.encode(conf)

The outcome of encoder is a standard Swift Data object, and the content should be like this:

id = 101
tag = my notes

[person]
name = rocky
age = 21

[place]
history = 1000
location = china

INI to Decodable

Assuming Configuration and data are ready:

let decoder = INIDecoder()
let config = try decoder.decode(Configuration.self, from: data)
// configuration loaded.

Issues

We are transitioning to using JIRA for all bugs and support related issues, therefore the GitHub issues has been disabled.

If you find a mistake, bug, or any other helpful suggestion you'd like to make on the docs please head over to http://jira.perfect.org:8080/servicedesk/customer/portal/1 and raise it.

A comprehensive list of open issues can be found at http://jira.perfect.org:8080/projects/ISS/issues

Further Information

For more information on the Perfect project, please visit perfect.org.

Now WeChat Subscription is Available 🇨🇳

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Oct 20 2024 15:04:13 GMT-0900 (Hawaii-Aleutian Daylight Time)