]> code.bitgloo.com Git - clyne/ini-config.git/commitdiff
Improve documentation, add godbolt example
authorclyne <clyne@bitgloo.com>
Tue, 5 Jan 2021 23:53:16 +0000 (18:53 -0500)
committerGitHub <noreply@github.com>
Tue, 5 Jan 2021 23:53:16 +0000 (18:53 -0500)
README.md

index c1e82e6be685cd957ee69d04748d952be0f35d8b..3566603431e1917c2b2b749c4307e2525690ef81 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,6 +4,8 @@ A single-header library that converts INI-formatted string literals to a key-val
 
 Requires C++20. Tested to work on gcc 10.1 and clang trunk. Passes `-Wall -Wextra -pedantic`.
 
+[Try it on Godbolt.](https://godbolt.org/z/K8GGov)
+
 ## Features
  * Comments and whitespace removed during compilation
  * Handles single-line `key=value` pairs with very basic syntax error reporting
@@ -13,27 +15,28 @@ Requires C++20. Tested to work on gcc 10.1 and clang trunk. Passes `-Wall -Wextr
 
 ## How to use
 ```cpp
-// 1. Include
 #include "ini_config.hpp"
 
-// 2. Use _ini suffix
-auto config = R"ini(
+auto config = R"(
 someflag = true
 
 [Cat]
-color = grey
+color = gray
 lives = 9
-
-)ini"_ini;
-
-// ...
+)"_ini;
 
 // Returns count of key-value pairs (KVPs), 3 in this case
-config.size()
-// Iterate through all KVPs using config.begin() and config.end()
+config.size();
+// Iterate through all KVPs
 for (auto kvp : config) {}
 // Iterate through all KVPs under [Cat] section
 for (auto kvp : config.section("Cat")) {}
+// Access specific values
+config.get("someflag");     // Returns "true"
+config.get("lives");        // Searches all KVPs, returns "9"
+config["lives"];            // Same as above
+config.get("Cat", "color"); // Only searches [Cat] section, Returns "gray"
+config.get("Dog", "color"); // No match, returns ""
 ```
 See the header file for further documentation.