edit

Alexander Zhirov 2023-03-30 09:46:05 +03:00
parent f70d479b2f
commit 975956f8c9
1 changed files with 20 additions and 4 deletions

16
Home.md

@ -91,7 +91,9 @@ A simple example of reading a single configuration file and getting parameter **
```d ```d
{ {
...
rc.read("./examples/simple.conf"); rc.read("./examples/simple.conf");
...
} }
``` ```
@ -99,7 +101,9 @@ Since a single file is being read, by default, it is accessed. `cf` is used as a
```d ```d
{ {
...
auto configFile = rc.cf; auto configFile = rc.cf;
...
} }
``` ```
@ -107,7 +111,9 @@ To read the **parameters**, you need to refer to the appropriate **section**. By
```d ```d
{ {
...
auto mainSection = configFile.sc; auto mainSection = configFile.sc;
...
} }
``` ```
@ -115,8 +121,10 @@ Getting parameter **values** from the selected **section** is done via the key f
```d ```d
{ {
...
string val1 = mainSection.key("parameter1"); string val1 = mainSection.key("parameter1");
string val2 = mainSection["parameter2"]; string val2 = mainSection["parameter2"];
...
} }
``` ```
@ -126,6 +134,7 @@ Reading a configuration file with different **sections**. The [section.conf]() f
```d ```d
{ {
...
rc.read("./examples/sections.conf"); rc.read("./examples/sections.conf");
auto configFile = rc.cf; auto configFile = rc.cf;
@ -139,6 +148,7 @@ Reading a configuration file with different **sections**. The [section.conf]() f
string val4 = firstSection["parameter_2"]; string val4 = firstSection["parameter_2"];
string val5 = secondSection["parameter1"]; string val5 = secondSection["parameter1"];
string val6 = secondSection["parameter_2"]; string val6 = secondSection["parameter_2"];
...
} }
``` ```
@ -148,9 +158,11 @@ To read multiple configuration files, you need to associate the file with its al
```d ```d
{ {
...
rc.read("./examples/simple.conf", "simple"); rc.read("./examples/simple.conf", "simple");
rc.read("./examples/sections.conf"); rc.read("./examples/sections.conf");
rc.read("./examples/comments.conf", "comments"); rc.read("./examples/comments.conf", "comments");
...
} }
``` ```
@ -158,9 +170,11 @@ A specific configuration file is accessed via its alias:
```d ```d
{ {
...
auto simpleConfig = rc.cf("simple"); auto simpleConfig = rc.cf("simple");
auto sectionsConfig = rc["sections.conf"]; auto sectionsConfig = rc["sections.conf"];
auto commentsConfig = rc["comments"]; auto commentsConfig = rc["comments"];
...
} }
``` ```
@ -168,6 +182,7 @@ Next, reading the **section** and getting the **values**:
```d ```d
{ {
...
auto simConMaiSec = simpleConfig.sn; auto simConMaiSec = simpleConfig.sn;
string val1 = simConMaiSec.key("parameter1"); string val1 = simConMaiSec.key("parameter1");
string val2 = simConMaiSec["parameter2"]; string val2 = simConMaiSec["parameter2"];
@ -179,5 +194,6 @@ Next, reading the **section** and getting the **values**:
auto comConMaiSec = commentsConfig.sn; auto comConMaiSec = commentsConfig.sn;
string val5 = comConMaiSec["parameter5"]; string val5 = comConMaiSec["parameter5"];
...
} }
``` ```