This is a simple reader/writer of Valve Data Format (a.k.a. KeyValues) written in ANSI C.
This library was made as a sort of an exercise in C, since I mainly use C++.
Hopefully no memory leaks! But if there still are, feel free to submit an issue or a pull request.
See DOCUMENTATION.md
file for more information.
- Character buffers may be null-terminated or limited to a maximum size.
- The files are parsed using
fopen()
with"rb"
and reading the contents into a character buffer. - The ability to create versatile contexts for reading data in a specific way, as well as functions for quick one-line parsing.
- Character buffers are created and expanded by the specified step size on the fly, without having to do it manually.
- The files are written using
fopen()
with"w"
in order to insert platform-specific line breaks.
- Case-insensitive
#base
&#include
macro support that includes files from absolute paths or relative to the specified base directory. - Keys and string values of any length.
- Context flags for toggling specific features:
- Support for escape sequences in strings.
- Support for multiple values under the same key name.
- Value replacement in duplicate keys, if the aforementioned multi-key support is disabled.
- Conditional statements before the pairs, e.g.
[$WIN32] "key" "value"
. - Multiline/block comments.
- Non-ASCII encodings.
- Include
keyvalues.c
in your project or link the library in your CMake project usingCMakeLists.txt
. - Include
keyvalues.h
in your C/C++ code.
Sample code with usage examples can be found here.
This library is in the public domain. That means you can do absolutely anything you want with it, although I appreciate attribution.
It's also licensed under the MIT license, in case public domain doesn't work for you. Every source file includes an explicit dual-license for you to choose from.