From dcdbbff878d58bbdd690afd58d35774a0f750256 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 5 Jun 2024 12:33:14 +1200 Subject: [PATCH 01/10] add copying notice --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d6f31c0..150d369 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ and `INISection`s back into an INI document. Handy for if your program has some sort of GUI configuration interface or if you're passing around INI through a network connection. +initial.d is licensed under the Boost Software License, version 1.0. See +COPYING for the full licence text. + ## Demo ```d From fb85533933de80fbec274487945bed45b2056ecc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 5 Jun 2024 12:39:51 +1200 Subject: [PATCH 02/10] update dub.json --- dub.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dub.json b/dub.json index fb52964..9b22875 100644 --- a/dub.json +++ b/dub.json @@ -1,9 +1,9 @@ { "name": "initial", - "description": "INI parsing library for the D programming language", + "description": "INI parser", - "authors": ["Jeremy Baxter"], - "copyright": "Copyright © 2024, Jeremy Baxter", + "authors": ["Jeremy Baxter "], + "copyright": "Copyright © 2024 Jeremy Baxter", "license": "BSL-1.0", "targetType": "library", From baafe10b1723b4907128170b26c27943abf12d01 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 18 Jun 2024 17:42:26 +1200 Subject: [PATCH 03/10] fix doc comment --- initial.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initial.d b/initial.d index 7f4a585..1181b9f 100644 --- a/initial.d +++ b/initial.d @@ -218,7 +218,7 @@ struct INISection keys = new string[string]; } - /+ + /++ + Returns the value of `k` in this section or + `defaultValue` if the key is not present. +/ From c00e0fa7e62444a04dbb7362eeba4f906e94b99a Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 18 Jun 2024 17:42:36 +1200 Subject: [PATCH 04/10] avoid converting objects twice If I have an object of type T and want to set it as the default value for a call to .keyAs(), I have to convert it to a string first. This string would then get converted again in case the key doesn't exist in the section. --- initial.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/initial.d b/initial.d index 1181b9f..289c33c 100644 --- a/initial.d +++ b/initial.d @@ -234,10 +234,10 @@ struct INISection + with a message containing location information. +/ T - keyAs(T)(string k, string defaultValue = null) + keyAs(T)(string k, T defaultValue) { try - return key(k, defaultValue).to!T(); + return k in keys ? keys[k].to!T() : defaultValue; catch (ConvException) throw new INITypeException( format!"unable to convert [%s].%s to %s"(name, k, T.stringof)); From 0b0a30673676c80dece57c380444833115f537d6 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 8 Aug 2024 17:43:32 +1200 Subject: [PATCH 05/10] .build.yml: init --- .build.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .build.yml diff --git a/.build.yml b/.build.yml new file mode 100644 index 0000000..3cd10aa --- /dev/null +++ b/.build.yml @@ -0,0 +1,15 @@ +--- +image: nixos/unstable +packages: + - nixos.ldc +environment: + CFLAGS: "-Oz -de -unittest -main -run" + NIX_CONFIG: "experimental-features = nix-command flakes" +sources: + - "https://git.sr.ht/~jeremy/initial" +tasks: + - ldc: | + ldc2 $CFLAGS initial/initial.d + - ldc-1_30_0: | + nix build -o ldc-1.30.0 --accept-flake-config github:PetarKirov/dlang.nix#ldc-1_30_0 + ldc-1.30.0/bin/ldc2 $CFLAGS initial/initial.d From c728f0f0e61ae9949618131faf4b67c44d60ef9b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 8 Aug 2024 17:47:55 +1200 Subject: [PATCH 06/10] README.md: add build status --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 150d369..321494d 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,8 @@ can do this automatically). [1]: https://lists.sr.ht/~jeremy/public-inbox [2]: https://git-send-email.io + +## Build status + +Status on building with LDC latest and 1.30.0: + [![builds.sr.ht status](https://builds.sr.ht/~jeremy/initial.svg)](https://builds.sr.ht/~jeremy/initial) From f115e015864c2b3a3658fcf0fd7c887f6966c9fe Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 8 Aug 2024 17:52:20 +1200 Subject: [PATCH 07/10] wrap lines --- initial.d | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/initial.d b/initial.d index 289c33c..8c2611d 100644 --- a/initial.d +++ b/initial.d @@ -3,27 +3,29 @@ * * Boost Software License - Version 1.0 - August 17th, 2003 * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: + * Permission is hereby granted, free of charge, to any person or + * organization obtaining a copy of the software and accompanying + * documentation covered by this license (the "Software") to use, + * reproduce, display, distribute, execute, and transmit the Software, + * and to prepare derivative works of the Software, and to permit + * third-parties to whom the Software is furnished to do so, all + * subject to the following: * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. + * The copyright notices in the Software and this entire statement, + * including the above license grant, this restriction and the following + * disclaimer, must be included in all copies of the Software, in whole or + * in part, and all derivative works of the Software, unless such copies or + * derivative works are solely in the form of machine-executable object + * code generated by a source language processor. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE + * DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, + * WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /++ From a3d17fdc6c1aea6dea288f0819bebecd3afc917b Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Thu, 8 Aug 2024 17:53:01 +1200 Subject: [PATCH 08/10] fix error with LDC 1.30.0: cannot create a `string[string]` with `new` --- initial.d | 1 - 1 file changed, 1 deletion(-) diff --git a/initial.d b/initial.d index 8c2611d..1843cec 100644 --- a/initial.d +++ b/initial.d @@ -217,7 +217,6 @@ struct INISection this(string name) nothrow { this.name = name; - keys = new string[string]; } /++ From daef20ac592366ea38beae93dfbb5d9b2436344d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 30 Apr 2025 20:25:01 +1200 Subject: [PATCH 09/10] .build.yml: drop --- .build.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .build.yml diff --git a/.build.yml b/.build.yml deleted file mode 100644 index 3cd10aa..0000000 --- a/.build.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -image: nixos/unstable -packages: - - nixos.ldc -environment: - CFLAGS: "-Oz -de -unittest -main -run" - NIX_CONFIG: "experimental-features = nix-command flakes" -sources: - - "https://git.sr.ht/~jeremy/initial" -tasks: - - ldc: | - ldc2 $CFLAGS initial/initial.d - - ldc-1_30_0: | - nix build -o ldc-1.30.0 --accept-flake-config github:PetarKirov/dlang.nix#ldc-1_30_0 - ldc-1.30.0/bin/ldc2 $CFLAGS initial/initial.d From db7be633a22b44add8865408bb14beceb1474acc Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 30 Apr 2025 21:35:02 +1200 Subject: [PATCH 10/10] add minimal readme --- README | 4 +++ README.md | 84 ------------------------------------------------------- 2 files changed, 4 insertions(+), 84 deletions(-) create mode 100644 README delete mode 100644 README.md diff --git a/README b/README new file mode 100644 index 0000000..bf355a1 --- /dev/null +++ b/README @@ -0,0 +1,4 @@ +This is initial, an INI parsing library for the D programming language. + +Reference documentation can be found in the source code as Ddoc comments. +A quick start guide can be found at . diff --git a/README.md b/README.md deleted file mode 100644 index 321494d..0000000 --- a/README.md +++ /dev/null @@ -1,84 +0,0 @@ -## initial - INI parser for the D programming language - -My attempt at making a sane and high-quality INI parsing library for D. - -```ini -[section] -key = value -``` - -The contents of an INI file is stored in an `INIUnit` structure. This -contains an associative array of `INISection`s that you can read or set -yourself. - -initial also provides serialisation facilities that can turn `INIUnit`s -and `INISection`s back into an INI document. Handy for if your program -has some sort of GUI configuration interface or if you're passing around -INI through a network connection. - -initial.d is licensed under the Boost Software License, version 1.0. See -COPYING for the full licence text. - -## Demo - -```d -INIUnit ini; - -/* write INI data to an INIUnit */ -ini["section"]["key"] = "value"; -ini["section"]["num"] = "4.8"; - -/* read INI data */ -readINI(ini, ` - [section] - num = 5.3 -`); - -assert(ini["section"]["key"] == "value"); -assert(ini["section"]["num"] == "5.3"); - -/* read INI from file */ -readINIFile(ini, "config.ini"); - -/* write INI to file */ -import std.file : write; -write("config.ini", ini.serialise()); -``` - -## Usage - -Copy initial.d to somewhere in your import path, then compile it alongside -your program and link it in. Or you can do it all at once by using -i. - - dmd program.d initial.d - dmd -i program.d - -Documentation can be found by reading the documentation comments in the code. - -## Progress - -### Finished - -- Keys -- Sections -- Default section -- Comments - -### Unimplemented - -- Key referencing - -Currently initial.d does all I need it to, and I consider it complete. -However if you have any questions, feel free to send an email to [my -public inbox][1] or directly to my address (jeremy@baxters.nz). Patches -are also welcome which you can generate with `git format-patch` and attach -to an email or just copy into the body of an email ([`git send-email`][2] -can do this automatically). - -[1]: https://lists.sr.ht/~jeremy/public-inbox -[2]: https://git-send-email.io - -## Build status - -Status on building with LDC latest and 1.30.0: - [![builds.sr.ht status](https://builds.sr.ht/~jeremy/initial.svg)](https://builds.sr.ht/~jeremy/initial)