Compare commits

...

5 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire e9cb212194 Registry (unittests)
- Cleaned up
2024-04-26 22:58:18 +02:00
Tristan B. Velloza Kildaire 4771d5fafe Registry (unittests)
- Added unittest for `in` operator support
2024-04-26 22:58:01 +02:00
Tristan B. Velloza Kildaire fa80d17cd2 Registry
- Added `in` operator support
2024-04-26 22:53:03 +02:00
Tristan B. Velloza Kildaire c5c7a02ac0 Reg 2024-04-26 22:46:25 +02:00
Tristan B. Velloza Kildaire e8c510eeaa Registry
- Added `in` operator support
2024-04-26 22:45:59 +02:00
1 changed files with 15 additions and 0 deletions

View File

@ -266,6 +266,8 @@ public struct Registry
setAllowOverwrite(allowOverwritingOfEntries);
}
public bool hasEntry(string name)
{
return getEntry0(name) !is null;
@ -278,6 +280,12 @@ public struct Registry
}
public ConfigEntry* opBinaryRight(string op)(string name)
if(op == "in")
{
return getEntry0(name);
}
public bool getEntry_nothrow(string name, ref ConfigEntry entry)
{
ConfigEntry* potEntry = getEntry0(name);
@ -482,6 +490,13 @@ unittest
reg["age"] = 25;
assert(cast(int)reg["age"] == 25);
// Obtain a handle on the configuration
// entry, then update it and read it back
// to confirm
ConfigEntry* ageEntry = "age" in reg;
*ageEntry = ConfigEntry.ofNumeric(69_420);
assert(cast(int)reg["age"] == 69_420);
// Should not be able to set entry it not yet existent
try
{