Merge pull request #478 from analogjupiter/ini

Add `arsd.ini` module
This commit is contained in:
Adam D. Ruppe 2025-02-16 20:44:55 -05:00 committed by GitHub
commit 31fa714504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3221 additions and 0 deletions

View File

@ -42,6 +42,8 @@ Go to the file+line number from the error message and change `Event` to `FocusIn
arsd.pixmappresenter, arsd.pixmappaint and arsd.pixmaprecorder were added. arsd.pixmappresenter, arsd.pixmappaint and arsd.pixmaprecorder were added.
arsd.ini was added.
## 11.0 ## 11.0
Released: Planned for May 2023, actually out August 2023. Released: Planned for May 2023, actually out August 2023.

49
core.d
View File

@ -281,6 +281,55 @@ ref T reinterpretCast(T, V)(return ref V value) @system {
return *cast(T*)& value; return *cast(T*)& value;
} }
/++
Determines whether `needle` is a slice of `haystack`.
History:
Added on February 11, 2025.
+/
bool isSliceOf(T1, T2)(scope const(T1)[] needle, scope const(T2)[] haystack) @trusted pure nothrow @nogc {
return (
needle.ptr >= haystack.ptr
&& ((needle.ptr + needle.length) <= (haystack.ptr + haystack.length))
);
}
///
@safe unittest {
string s0 = "01234";
const(char)[] s1 = s0[1 .. $];
const(void)[] s2 = s1.castTo!(const(void)[]);
string s3 = s1.idup;
assert( s0.isSliceOf(s0));
assert( s1.isSliceOf(s0));
assert( s2.isSliceOf(s0));
assert(!s3.isSliceOf(s0));
assert(!s0.isSliceOf(s1));
assert( s1.isSliceOf(s1));
assert( s2.isSliceOf(s1));
assert(!s3.isSliceOf(s1));
assert(!s0.isSliceOf(s2));
assert( s1.isSliceOf(s2));
assert( s2.isSliceOf(s2));
assert(!s3.isSliceOf(s2));
assert(!s0.isSliceOf(s3));
assert(!s1.isSliceOf(s3));
assert(!s2.isSliceOf(s3));
assert( s3.isSliceOf(s3));
assert(s1.length == 4);
assert(s1[0 .. 0].isSliceOf(s1));
assert(s1[0 .. 1].isSliceOf(s1));
assert(s1[1 .. 2].isSliceOf(s1));
assert(s1[1 .. 3].isSliceOf(s1));
assert(s1[1 .. $].isSliceOf(s1));
assert(s1[$ .. $].isSliceOf(s1));
}
/++ /++
Does math as a 64 bit number, but saturates at int.min and int.max when converting back to a 32 bit int. Does math as a 64 bit number, but saturates at int.min and int.max when converting back to a 32 bit int.

View File

@ -787,6 +787,18 @@
"dflags-dmd": ["-mv=arsd.archive=$PACKAGE_DIR/archive.d"], "dflags-dmd": ["-mv=arsd.archive=$PACKAGE_DIR/archive.d"],
"dflags-ldc": ["--mv=arsd.archive=$PACKAGE_DIR/archive.d"], "dflags-ldc": ["--mv=arsd.archive=$PACKAGE_DIR/archive.d"],
"dflags-gdc": ["-fmodule-file=arsd.archive=$PACKAGE_DIR/archive.d"] "dflags-gdc": ["-fmodule-file=arsd.archive=$PACKAGE_DIR/archive.d"]
},
{
"name": "ini",
"description": "INI configuration file support - configurable INI parser and serializer with support for various dialects.",
"targetType": "library",
"sourceFiles": ["ini.d"],
"dependencies": {
"arsd-official:core":"*"
},
"dflags-dmd": ["-mv=arsd.ini=$PACKAGE_DIR/ini.d"],
"dflags-ldc": ["--mv=arsd.ini=$PACKAGE_DIR/ini.d"],
"dflags-gdc": ["-fmodule-file=arsd.ini=$PACKAGE_DIR/ini.d"]
} }
] ]
} }

3158
ini.d Normal file

File diff suppressed because it is too large Load Diff