https://github.com/perfectlysoft/perfect-iniparser
A lightweight INI file parser in Server Side Swift
https://github.com/perfectlysoft/perfect-iniparser
ini ini-parser perfect swift
Last synced: 28 days ago
JSON representation
A lightweight INI file parser in Server Side Swift
- Host: GitHub
- URL: https://github.com/perfectlysoft/perfect-iniparser
- Owner: PerfectlySoft
- License: apache-2.0
- Created: 2017-04-28T18:38:42.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-07T13:01:53.000Z (almost 5 years ago)
- Last Synced: 2025-04-16T02:02:10.125Z (about 2 months ago)
- Topics: ini, ini-parser, perfect, swift
- Language: Swift
- Size: 20.5 KB
- Stars: 15
- Watchers: 4
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Perfect INI File Parser [简体中文](README.zh_CN.md)
This project provides an express parser for [INI](https://en.wikipedia.org/wiki/INI_file) files.
This package builds with Swift Package Manager of Swift 4 Tool Chain and is part of the [Perfect](https://github.com/PerfectlySoft/Perfect) project but can be used as an independent module.
## Quick Start
Configure Package.swift:
``` swift
.package(url: "https://github.com/PerfectlySoft/Perfect-INIParser.git", from: "3.0.0")...
.target( name: "YourProjectName",
dependencies: ["INIParser"]),
```Import library into your code:
``` swift
import INIParser
```Load the objective INI file by initializing a `INIParser` object:
``` swift
let ini = try INIParser("/path/to/somefile.ini")
```Then it should be possible to access variables inside the file.
### Variables with Specific Section
For most regular lines under a certain section, use `sections` attribute of `INIParser`. Take example:
```
[GroupA]
myVariable = myValue
```Then `let v = ini.sections["GroupA"]?["myVariable"]` will get the value as `"myValue"`.
### Variables without Section
However, some ini files may not have any available sections but directly put all variables together:
```
freeVar1 = 1
```In this case, call `anonymousSection` to load the corresponding value:
```
let v = ini.anonymousSection["freeVar1"]
```## Further Information
For more information on the Perfect project, please visit [perfect.org](http://perfect.org).## Now WeChat Subscription is Available 🇨🇳