|
SDL_ini 1.2.0
Single-header INI file library for SDL3
|
Macros | |
| #define | SDL_INI_MAJOR_VERSION 1 |
| The major version of SDL_ini. | |
| #define | SDL_INI_MINOR_VERSION 2 |
| The minor version of SDL_ini. | |
| #define | SDL_INI_MICRO_VERSION 0 |
| The micro/patch version of SDL_ini. | |
| #define | SDL_INI_VERSION SDL_VERSIONNUM(SDL_INI_MAJOR_VERSION, SDL_INI_MINOR_VERSION, SDL_INI_MICRO_VERSION) |
| Retrieves an integer representation of the of the SDL_ini version. | |
| #define | SDL_INI_VERSION_ATLEAST(X, Y, Z) (SDL_INI_VERSION >= SDL_VERSIONNUM(X, Y, Z)) |
| Checks if SDL_ini is at least the given version. | |
| #define | SDL_INI_IMPLEMENTATION |
In exactly one C source file, define SDL_INI_IMPLEMENTATION before including SDL_ini.h. | |
Typedefs | |
| typedef void(* | INI_EnumerateSectionsCallback) (void *userdata, const SDL_ini *ini, const char *section) |
| Callback invoked for each section name during enumeration. | |
| typedef void(* | INI_EnumerateKeysCallback) (void *userdata, const SDL_ini *ini, const char *section, const char *key, const char *value) |
| Callback invoked for each key/value pair during enumeration. | |
Functions | |
| int | INI_GetVersion (void) |
| Get the version of SDL_ini that is linked against. | |
| SDL_ini * | INI_Create (void) |
| Create an empty INI object. | |
| SDL_ini * | INI_Load_IO (SDL_IOStream *src, bool closeio) |
| Load an INI file from an SDL_IOStream. | |
| SDL_ini * | INI_Load (const char *file) |
| Load an INI file from a filesystem path. | |
| SDL_ini * | INI_LoadString (const char *text) |
| Load an INI from the given string. | |
| bool | INI_Save_IO (SDL_ini *ini, SDL_IOStream *dst, bool closeio) |
| Save an INI object to an SDL_IOStream. | |
| bool | INI_Save (SDL_ini *ini, const char *file) |
| Save an INI object to a filesystem path. | |
| char * | INI_SaveString (SDL_ini *ini) |
| Save an INI object to a newly allocated, NUL-terminated string. | |
| SDL_ini * | INI_Clone (const SDL_ini *ini) |
| Create an independent deep copy of an INI object. | |
| void | INI_Destroy (SDL_ini *ini) |
| Free an INI object and all associated memory. | |
| const char * | INI_GetString (const SDL_ini *ini, const char *section, const char *key, const char *default_value) |
| Get a string value from the INI. | |
| Sint64 | INI_GetInt (const SDL_ini *ini, const char *section, const char *key, Sint64 default_value) |
| Get a signed 64-bit integer value from the INI. | |
| float | INI_GetFloat (const SDL_ini *ini, const char *section, const char *key, float default_value) |
| Get a floating-point value from the INI. | |
| double | INI_GetDouble (const SDL_ini *ini, const char *section, const char *key, double default_value) |
| Get a double-precision floating-point value from the INI. | |
| bool | INI_GetBoolean (const SDL_ini *ini, const char *section, const char *key, bool default_value) |
| Get a boolean value from the INI. | |
| bool | INI_SetString (SDL_ini *ini, const char *section, const char *key, const char *value) |
| Set a string value in the INI. | |
| bool | INI_SetInt (SDL_ini *ini, const char *section, const char *key, Sint64 value) |
| Set a signed 64-bit integer value in the INI. | |
| bool | INI_SetFloat (SDL_ini *ini, const char *section, const char *key, float value) |
| Set a single-precision floating-point value in the INI. | |
| bool | INI_SetDouble (SDL_ini *ini, const char *section, const char *key, double value) |
| Set a double-precision floating-point value in the INI. | |
| bool | INI_SetBoolean (SDL_ini *ini, const char *section, const char *key, bool value) |
| Set a boolean value in the INI. | |
| bool | INI_IsDirty (const SDL_ini *ini) |
| Check whether the INI has been modified since creation or last load. | |
| void | INI_SetDirty (SDL_ini *ini, bool dirty) |
| Manually set or clear the dirty flag. | |
| bool | INI_HasSection (const SDL_ini *ini, const char *section) |
| Check whether a section exists and contains at least one key. | |
| bool | INI_HasKey (const SDL_ini *ini, const char *section, const char *key) |
| Check whether a key exists in a section. | |
| bool | INI_HasValue (const SDL_ini *ini, const char *section, const char *key) |
| Check whether a key exists and has a non-empty value. | |
| bool | INI_RemoveKey (SDL_ini *ini, const char *section, const char *key) |
| Delete a key from a section. | |
| bool | INI_RemoveSection (SDL_ini *ini, const char *section) |
| Delete an entire section and all its keys. | |
| void | INI_EnumerateSections (const SDL_ini *ini, INI_EnumerateSectionsCallback callback, void *userdata) |
| Enumerate all sections in the INI. | |
| void | INI_EnumerateKeys (const SDL_ini *ini, const char *section, INI_EnumerateKeysCallback callback, void *userdata) |
| Enumerate all key/value pairs in a section. | |
| bool | INI_Merge (SDL_ini *dest, const SDL_ini *src) |
| Merge all sections and keys from src into dest. | |
| bool | INI_Merge_IO (SDL_ini *dest, SDL_IOStream *src, bool closeio) |
| Load an INI from an SDL_IOStream and merge it into dest. | |
| bool | INI_MergeFile (SDL_ini *dest, const char *file) |
| Load an INI from a file and merge it into dest. | |
| SDL_ini * | INI_LoadMultiple (const char **files) |
| Load multiple INI files, merging them in order. | |
| int | INI_GetSectionCount (const SDL_ini *ini) |
| Return the number of sections in the INI. | |
| const char * | INI_GetSection (const SDL_ini *ini, int index) |
| Return the name of the section at the given index. | |
| int | INI_GetKeyCount (const SDL_ini *ini, const char *section) |
| Return the number of key/value entries in a section (comments and blank lines are not counted). | |
| const char * | INI_GetKey (const SDL_ini *ini, const char *section, int index) |
| Return the key name at the given index within a section. | |
| const char * | INI_GetKeyValue (const SDL_ini *ini, const char *section, int index) |
| Return the value at the given key index within a section. | |
| #define SDL_INI_MAJOR_VERSION 1 |
The major version of SDL_ini.
| #define SDL_INI_MINOR_VERSION 2 |
The minor version of SDL_ini.
| #define SDL_INI_MICRO_VERSION 0 |
The micro/patch version of SDL_ini.
| #define SDL_INI_VERSION SDL_VERSIONNUM(SDL_INI_MAJOR_VERSION, SDL_INI_MINOR_VERSION, SDL_INI_MICRO_VERSION) |
Retrieves an integer representation of the of the SDL_ini version.
| #define SDL_INI_VERSION_ATLEAST | ( | X, | |
| Y, | |||
| Z | |||
| ) | (SDL_INI_VERSION >= SDL_VERSIONNUM(X, Y, Z)) |
Checks if SDL_ini is at least the given version.
| #define SDL_INI_IMPLEMENTATION |
In exactly one C source file, define SDL_INI_IMPLEMENTATION before including SDL_ini.h.
In all other files, just include the header normally:
| typedef void(* INI_EnumerateSectionsCallback) (void *userdata, const SDL_ini *ini, const char *section) |
Callback invoked for each section name during enumeration.
| userdata | user-provided pointer. |
| section | the section name (empty string for the global section). |
| typedef void(* INI_EnumerateKeysCallback) (void *userdata, const SDL_ini *ini, const char *section, const char *key, const char *value) |
Callback invoked for each key/value pair during enumeration.
| userdata | user-provided pointer. |
| key | the key name. |
| value | the associated value. |
| int INI_GetVersion | ( | void | ) |
Get the version of SDL_ini that is linked against.
| SDL_ini * INI_Create | ( | void | ) |
Create an empty INI object.
| SDL_ini * INI_Load_IO | ( | SDL_IOStream * | src, |
| bool | closeio | ||
| ) |
Load an INI file from an SDL_IOStream.
| src | the SDL_IOStream to read from. |
| closeio | if true, the stream is closed after reading. |
| SDL_ini * INI_Load | ( | const char * | file | ) |
Load an INI file from a filesystem path.
| file | the path to the INI file. |
| SDL_ini * INI_LoadString | ( | const char * | text | ) |
Load an INI from the given string.
| text | the string containing the ini data. |
| bool INI_Save_IO | ( | SDL_ini * | ini, |
| SDL_IOStream * | dst, | ||
| bool | closeio | ||
| ) |
Save an INI object to an SDL_IOStream.
| ini | the SDL_ini to write. |
| dst | the SDL_IOStream to write to. |
| closeio | if true, the stream is closed after writing. |
| bool INI_Save | ( | SDL_ini * | ini, |
| const char * | file | ||
| ) |
Save an INI object to a filesystem path.
| ini | the SDL_ini to write. |
| file | the path to write to. |
| char * INI_SaveString | ( | SDL_ini * | ini | ) |
Save an INI object to a newly allocated, NUL-terminated string.
| ini | the SDL_ini to write. |
Create an independent deep copy of an INI object.
All sections, keys, values, comments, and blank lines are duplicated. The clone starts with a clean dirty flag.
| ini | the SDL_ini to clone. |
| void INI_Destroy | ( | SDL_ini * | ini | ) |
Free an INI object and all associated memory.
| ini | the SDL_ini to destroy. NULL is safely ignored. |
| const char * INI_GetString | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| const char * | default_value | ||
| ) |
Get a string value from the INI.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| default_value | returned when the key is not found. |
| Sint64 INI_GetInt | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| Sint64 | default_value | ||
| ) |
Get a signed 64-bit integer value from the INI.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| default_value | returned when the key is not found. |
| float INI_GetFloat | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| float | default_value | ||
| ) |
Get a floating-point value from the INI.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| default_value | returned when the key is not found. |
| double INI_GetDouble | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| double | default_value | ||
| ) |
Get a double-precision floating-point value from the INI.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| default_value | returned when the key is not found. |
| bool INI_GetBoolean | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| bool | default_value | ||
| ) |
Get a boolean value from the INI.
Recognises "1", "true", "yes", "on" as true and "0", "false", "no", "off" as false (case-insensitive).
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| default_value | returned when the key is not found or is unrecognised. |
| bool INI_SetString | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| const char * | value | ||
| ) |
Set a string value in the INI.
The section is created if it does not exist.
Names are validated so that the document can round-trip through INI_Save() and INI_Load(). The call fails, with SDL_GetError() set, when:
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to set. |
| value | the string value. Providing NULL will set an empty string. |
| bool INI_SetInt | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| Sint64 | value | ||
| ) |
Set a signed 64-bit integer value in the INI.
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to set. |
| value | the integer value. |
| bool INI_SetFloat | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| float | value | ||
| ) |
Set a single-precision floating-point value in the INI.
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to set. |
| value | the float value. |
| bool INI_SetDouble | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| double | value | ||
| ) |
Set a double-precision floating-point value in the INI.
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to set. |
| value | the double value. |
| bool INI_SetBoolean | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key, | ||
| bool | value | ||
| ) |
Set a boolean value in the INI.
Written as "true" or "false".
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to set. |
| value | the boolean value. |
| bool INI_IsDirty | ( | const SDL_ini * | ini | ) |
Check whether the INI has been modified since creation or last load.
| ini | the SDL_ini to query. |
| void INI_SetDirty | ( | SDL_ini * | ini, |
| bool | dirty | ||
| ) |
Manually set or clear the dirty flag.
| ini | the SDL_ini to modify. |
| dirty | the new dirty state. |
| bool INI_HasSection | ( | const SDL_ini * | ini, |
| const char * | section | ||
| ) |
Check whether a section exists and contains at least one key.
Sections that hold only comments or blank lines are not considered present.
| ini | the SDL_ini to query. |
| section | the section name to check for. |
| bool INI_HasKey | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key | ||
| ) |
Check whether a key exists in a section.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
A key with an empty value (for example key=) still counts as existing. Use INI_HasValue() to check for a key that also has a non-empty value.
| bool INI_HasValue | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key | ||
| ) |
Check whether a key exists and has a non-empty value.
Unlike INI_HasKey(), a key with an empty value (for example key=) is not considered to have a value.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| key | the key to look up. |
| bool INI_RemoveKey | ( | SDL_ini * | ini, |
| const char * | section, | ||
| const char * | key | ||
| ) |
Delete a key from a section.
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| key | the key to remove. |
| bool INI_RemoveSection | ( | SDL_ini * | ini, |
| const char * | section | ||
| ) |
Delete an entire section and all its keys.
| ini | the SDL_ini to modify. |
| section | section name (NULL or "" for the global section). |
| void INI_EnumerateSections | ( | const SDL_ini * | ini, |
| INI_EnumerateSectionsCallback | callback, | ||
| void * | userdata | ||
| ) |
Enumerate all sections in the INI.
| ini | the SDL_ini to enumerate. |
| callback | called once per section. |
| userdata | passed through to the callback. |
| void INI_EnumerateKeys | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| INI_EnumerateKeysCallback | callback, | ||
| void * | userdata | ||
| ) |
Enumerate all key/value pairs in a section.
| ini | the SDL_ini to enumerate. |
| section | section name (NULL or "" for the global section). |
| callback | called once per key. |
| userdata | passed through to the callback. |
Merge all sections and keys from src into dest.
Duplicate keys in dest are overwritten by the values from src. Sections that exist only in src are created in dest.
| bool INI_Merge_IO | ( | SDL_ini * | dest, |
| SDL_IOStream * | src, | ||
| bool | closeio | ||
| ) |
Load an INI from an SDL_IOStream and merge it into dest.
| dest | the destination SDL_ini. |
| src | the SDL_IOStream to read from. |
| closeio | if true, the stream is closed after reading. |
| bool INI_MergeFile | ( | SDL_ini * | dest, |
| const char * | file | ||
| ) |
Load an INI from a file and merge it into dest.
| dest | the destination SDL_ini. |
| file | the path to the INI file. |
| SDL_ini * INI_LoadMultiple | ( | const char ** | files | ) |
Load multiple INI files, merging them in order.
Later files overwrite keys from earlier files.
| files | NULL-terminated array of file paths. |
| int INI_GetSectionCount | ( | const SDL_ini * | ini | ) |
Return the number of sections in the INI.
| ini | the SDL_ini to query. |
| const char * INI_GetSection | ( | const SDL_ini * | ini, |
| int | index | ||
| ) |
Return the name of the section at the given index.
| ini | the SDL_ini to query. |
| index | zero-based section index. |
| int INI_GetKeyCount | ( | const SDL_ini * | ini, |
| const char * | section | ||
| ) |
Return the number of key/value entries in a section (comments and blank lines are not counted).
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| const char * INI_GetKey | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| int | index | ||
| ) |
Return the key name at the given index within a section.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| index | zero-based index among key/value entries only. |
| const char * INI_GetKeyValue | ( | const SDL_ini * | ini, |
| const char * | section, | ||
| int | index | ||
| ) |
Return the value at the given key index within a section.
| ini | the SDL_ini to query. |
| section | section name (NULL or "" for the global section). |
| index | zero-based index among key/value entries only. |