-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
#include <cracon/cracon.hpp> | ||
|
||
int main() { | ||
cracon::File config; | ||
bool success = config.init("config.json", "defaults.json"); | ||
if (!success) { | ||
fprintf(stderr, "We failed to open, read or write the configuration files."); | ||
exit(EXIT_FAILURE); | ||
} | ||
cracon::File config = cracon::File("config.json", "defaults.json"); | ||
|
||
int int_value = config.get("/int", 1); | ||
auto some_string = config.get<std::string>("/oh/hi", "mark"); | ||
auto a_vector = config.get<std::vector<float>>("/vector", {1., 2., 3.}); | ||
|
||
int_value = config.set("/int", 42); | ||
if(config.should_write()) { // Only write it if there is a change | ||
if (config.should_write()) { // Only write it if there is a change | ||
config.write(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters