Creates a new Registry and sets the overwriting policy
Obtain a configuration entry at the given key
Checks if an entry is present
Creates a new entry and adds it
Obtains a pointer to the configuration entry at the given key. Allowing you to swap out its contents directly if you want to.
Obtain a configuration entry at the given key
Assigns the provided configuration entry to the provided name
Returns all the entries in the registry as a mapping of their name to their configuration entry
Set whether or not the overwriting of an entry should be allowed
Sets the entry at the given name to the provided entry
Tests out the working with the registry in order to manage a set of named configuration entries
Registry reg = Registry(false); // Add an entry reg.newEntry("name", "Tristan"); // Check it exists assert(reg.hasEntry("name")); // Adding it again should fail try { reg.newEntry("name", "Tristan2"); assert(false); } catch(RegistryException e) { } // Check that the entry still has the right value assert(cast(string)reg["name"] == "Tristan"); // // Add a new entry and test its prescence reg["age"] = 24; assert(cast(int)reg["age"]); // // Update it 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 { reg.setEntry("male", ConfigEntry.ofFlag(true)); assert(false); } catch(RegistryException e) { } // All entries RegistryEntry[] all = reg[]; assert(all.length == 2); writeln(all);
A registry for managing multiple mappings of string-based names to configuration entries