diff options
author | clyne <clyne@bitgloo.com> | 2021-01-05 18:53:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 18:53:16 -0500 |
commit | 2aa4d516c3f1a624c801da1aab4feb1add8cf522 (patch) | |
tree | e48369f08bc2f335c6b893a9cbce85e06d65e0da /README.md | |
parent | 7b3c3796217f92c257c92d535d2864af57c48ce2 (diff) |
Improve documentation, add godbolt example
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -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. |