SDL_ini 1.2.0
Single-header INI file library for SDL3
Loading...
Searching...
No Matches
SDL_ini.h File Reference
#include <SDL3/SDL.h>
Include dependency graph for SDL_ini.h:

Data Structures

struct  SDL_ini_item
 A single SDL_ini item, held within a section. More...
 
struct  SDL_ini_section
 An SDL_ini section, holding any number of items. More...
 
struct  SDL_ini
 An SDL_ini instance to handle the data for an INI file. More...
 

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.
 
#define SDL_INI_IMPLEMENTATION_ONCE
 

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.
 

Enumerations

enum  SDL_ini_item_type { SDL_INI_ITEM_ENTRY , SDL_INI_ITEM_COMMENT , SDL_INI_ITEM_BLANK }
 The type of a given SDL_ini_item. More...
 

Functions

int INI_GetVersion (void)
 Get the version of SDL_ini that is linked against.
 
SDL_iniINI_Create (void)
 Create an empty INI object.
 
SDL_iniINI_Load_IO (SDL_IOStream *src, bool closeio)
 Load an INI file from an SDL_IOStream.
 
SDL_iniINI_Load (const char *file)
 Load an INI file from a filesystem path.
 
SDL_iniINI_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_iniINI_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_iniINI_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.
 

Macro Definition Documentation

◆ SDL_INI_IMPLEMENTATION_ONCE

#define SDL_INI_IMPLEMENTATION_ONCE

Enumeration Type Documentation

◆ SDL_ini_item_type

The type of a given SDL_ini_item.

See also
SDL_ini_item
Enumerator
SDL_INI_ITEM_ENTRY 
SDL_INI_ITEM_COMMENT 
SDL_INI_ITEM_BLANK