Swiftpack.co - PerfectlySoft/Perfect-INIParser as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by PerfectlySoft.
PerfectlySoft/Perfect-INIParser 4.0.0
A lightweight INI file parser in Server Side Swift
⭐ī¸ 15
🕓 3 years ago
.package(url: "https://github.com/PerfectlySoft/Perfect-INIParser.git", from: "4.0.0")

Perfect INI File Parser įŽ€äŊ“中文

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 express parser 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

Configure Package.swift:

.package(url: "https://github.com/PerfectlySoft/Perfect-INIParser.git", from: "3.0.0")

...

.target( name: "YourProjectName",
	dependencies: ["INIParser"]),
	

Import library into your code:

import INIParser

Load the objective INI file by initializing a INIParser object:

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.

Now WeChat Subscription is Available 🇨đŸ‡ŗ

GitHub

link
Stars: 15
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swift version upgrade & more constructors
3 years ago

Thanks NocturnalSolutions and swift-aws for these great contributions.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics