From 357deeb5e41c8b7e4bfacb2b5a16d474e434ff75 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sat, 25 Mar 2023 13:01:02 +0200 Subject: [PATCH] ConnInfo - Added a `string[string]` key-value pair named `db` to hold the parameters learnt from `RPL_ISUPPORT`s - Added `updateDB(string, string)` to add an entry to the `db` - Added `getDB(string)` to fetch a value from the `db` (if it doesn't exist then an empty string `""` is returned) --- source/birchwood/config/conninfo.d | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/birchwood/config/conninfo.d b/source/birchwood/config/conninfo.d index c9d01f0..934fc98 100644 --- a/source/birchwood/config/conninfo.d +++ b/source/birchwood/config/conninfo.d @@ -40,6 +40,12 @@ public shared struct ConnectionInfo */ public const string quitMessage; + /** + * Key-value pairs learnt from the + * server + */ + private string[string] db; + /* TODO: before publishing change this bulk size */ /** @@ -116,6 +122,26 @@ public shared struct ConnectionInfo this.fakeLag = fakeLag; } + public void updateDB(string key, string value) + { + db[key] = value; + } + + public string getDB(string key) + { + // TODO: Do existence check + if(key in db) + { + return db[key]; + } + else + { + // TODO: Should throw an exception + return ""; + } + } + + /** * Creates a ConnectionInfo struct representing a client configuration which * can be provided to the Client class to create a new connection based on its