From 3f96d049e57013fdd2ab7862fb002eb2521b59d6 Mon Sep 17 00:00:00 2001 From: "Marian W." Date: Sun, 2 Feb 2025 05:40:57 +0100 Subject: [PATCH 1/4] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 26c92f2..eebcff4 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ int main() MiniPPFile::Section* gameSection = nullptr; result = root.GetSubSection("game", &gameSection); + // "Easy" API + int64_t test = gameSection.GetValueOrDefault("year", 1999); + + // Verbose API MiniPPFile::Values::StringValue* nameValue = nullptr; result = gameSection->GetValue("name", &nameValue); MiniPPFile::Values::IntValue* yearValue = nullptr; From 04dcc77db61ae24d3be79e584fcc55d0853d962a Mon Sep 17 00:00:00 2001 From: "Marian W." Date: Sun, 2 Feb 2025 20:51:45 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index eebcff4..5595e77 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ int main() MiniPPFile::Values::IntValue* yearValue = nullptr; result = gameSection->GetValue("year", &yearValue); - // Get a sub-section (section of a section (stated in the MINI file with "[game.window]") + // Get a sub-section (section of a section, stated in the MINI file with "[game.window]") MiniPPFile::Section* windowSection = nullptr; result = gameSection->GetSubSection("window", &windowSection); @@ -92,9 +92,12 @@ int main() // Access values MiniPPFile::Values::StringValue* nameValue = nullptr; result = gameSection->GetValue("name", &nameValue); + + // .. OR .. + + std::string nameValue = gameSection->GetValueOrDefault("name", "Unknown"); // Navigate nested sections - MiniPPFile::Section* windowSection = nullptr; result = gameSection->GetSubSection("window", &windowSection); @@ -110,11 +113,11 @@ int main() ```cpp // Handle arrays - MiniPPFile::Values::ArrayValue* pointsValue = nullptr; - result = root.GetValue("game.window.platform.points", &pointsValue); + MiniPPFile::Values::ArrayValue* platformsValue = nullptr; + result = root.GetValue("game.window.platform.points", &platformsValue); // Modify the array values (or read them) - pointsValue->GetValues().push_back(std::make_unique("haiku")); + platformsValue->GetValue().push_back(std::make_unique("haiku")); ``` 5. **Write new files**: @@ -125,7 +128,7 @@ int main() ## Example -An example mini file is contained in this [repository](minipp/test.mini). The full mini file format specilization can be found [here](https://github.com/ToyB-Chan/mini-file-format). +An example mini file is contained in this [repository](minipp/test.mini). The full mini file format specification can be found [here](https://github.com/ToyB-Chan/mini-file-format). ## Installation From d7bc969b700ec461d4983d1c388e5a874d7953e9 Mon Sep 17 00:00:00 2001 From: "Marian W." Date: Sun, 2 Feb 2025 20:54:38 +0100 Subject: [PATCH 3/4] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5595e77..3060baf 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,12 @@ int main() // Get a sub-section by using the dot operator result = gameSection->GetSubSection("window.platform", &windowPlatformSection); - MiniPPFile::Values::ArrayValue* pointsValue = nullptr; + MiniPPFile::Values::ArrayValue* platformTargetsValue = nullptr; // Retrieve an array by using the relative value path (the game section is a child of the root section) - result = root.GetValue("game.window.platform.targets", &pointsValue); + result = root.GetValue("game.window.platform.targets", &platformTargetsValue); // Modify the "targets" array by adding a new value - pointsValue->GetValues().push_back(std::make_unique("haiku")); + platformTargetsValue->GetValues().push_back(std::make_unique("haiku")); // Serialize the config result = file.Write("test_out.mini"); @@ -113,11 +113,11 @@ int main() ```cpp // Handle arrays - MiniPPFile::Values::ArrayValue* platformsValue = nullptr; - result = root.GetValue("game.window.platform.points", &platformsValue); + MiniPPFile::Values::ArrayValue* pointsValue = nullptr; + result = root.GetValue("game.window.platform.points", &pointsValue); // Modify the array values (or read them) - platformsValue->GetValue().push_back(std::make_unique("haiku")); + pointsValue->GetValue().push_back(std::make_unique("haiku")); ``` 5. **Write new files**: From 538c977f14284dc32499332b24eeff66c8515b5e Mon Sep 17 00:00:00 2001 From: "Marian W." Date: Sun, 2 Feb 2025 20:55:11 +0100 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3060baf..ce1aa70 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ int main() result = root.GetValue("game.window.platform.targets", &platformTargetsValue); // Modify the "targets" array by adding a new value - platformTargetsValue->GetValues().push_back(std::make_unique("haiku")); + platformTargetsValue->GetValue().push_back(std::make_unique("haiku")); // Serialize the config result = file.Write("test_out.mini");