edit

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

24
Home.md

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