A library providing API for configuration file reading and writing.
See the documentation.
- Simple configuration syntax (similar to YAML)
- Automatic variable parsing (int, float, bool, string)
- Built-in configuration syntax validation
- C and C++ implementations
void confReaderExampleCPP()
{
conf::Reader confReader("settings.txt");
int64_t someValue = 0;
if (confReader.get("someValue", someValue))
{
// use value...
}
}
void confWriterExampleCPP()
{
conf::Writer confWriter("settings.txt");
confWriter.writeComment("Settings file (v1.0.0)");
confWriter.writeNewLine();
confWriter.write("someValue", 1337);
}
void confReaderExampleC()
{
ConfReader confReader = NULL;
ConfResult confResult = createFileConfReader("settings.txt", &confReader, NULL);
if (confResult != SUCCESS_CONF_RESULT) abort();
int64_t someValue = 0;
if (getConfReaderInt(confReader, "someValue", &someValue))
{
// use value...
}
destroyConfReader(confReader);
}
void confWriterExampleC()
{
ConfWriter confWriter = NULL;
ConfResult confResult = createFileConfWriter("settings.txt", &confWriter);
if (confResult != SUCCESS_CONF_RESULT) abort();
bool writeResult = writeConfComment(confWriter, "Settings file (v1.0.0)");
writeResult |= writeConfNewLine(confWriter);
writeResult |= writeConfInt(confWriter, "someValue", 1337);
if (!writeResult) abort();
destroyConfWriter(confReader);
}
# Conf comment syntax example
integerValue: 123
NegativeOne: -1
# Supported floating values
FloatingPI: 3.141
minus Infinity: -INF
Oh nooo: NaN
# Also some booleans
is.planet.round: true
caseSensitive: False
# And everything else is strings
hackingExploit: Hello world!
Not recommended key example? : Yes :)
- Windows
- macOS
- Ubuntu (Linux)
- C99 compiler
- C++17 compiler (optional)
- Git 2.30+
- CMake 3.16+
Use building instructions to install all required tools and libraries.
Name | Description | Default value |
---|---|---|
CONF_BUILD_SHARED | Build Conf shared library | ON |
CONF_BUILD_TESTS | Build Conf library tests | ON |
Name | Description | Windows | macOS | Linux |
---|---|---|---|---|
conf-static | Static Conf library | .lib |
.a |
.a |
conf-shared | Dynamic Conf library | .dll |
.dylib |
.so |
git clone --recursive https://github.com/cfnptr/conf
- Windows:
./scripts/build-release.bat
- macOS / Ubuntu:
./scripts/build-release.sh
- mpio (Apache-2.0 License)