ソースを参照

Add C++ name mangling

Support for C++.
master
コミット
b5007a86c4
1個のファイルの変更38行の追加30行の削除
  1. +38
    -30
      ini-config.h

+ 38
- 30
ini-config.h ファイルの表示

@@ -7,6 +7,10 @@
#include <stdbool.h>
#include <minIni.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* Struct for transformer functions used for properly loading and saving the config item's value.
*/
@@ -14,11 +18,11 @@ typedef struct {
/**
* Function that formats the value from memory to a value that is write-friendly to the config file.
*/
void* serialize;
void *serialize;
/**
* Function that formats the value from file to a value that is read-friendly to memory.
*/
void* deserialize;
void *deserialize;
} INI_ConfigTransformer; // TODO: should we unify this with INI_ConfigType?

struct INI_ConfigItem;
@@ -26,7 +30,7 @@ struct INI_ConfigItem;
/**
* Function for loading a config item value from file to memory.
*/
typedef void INI_ConfigTypeLoad(struct INI_ConfigItem*, const char*);
typedef void INI_ConfigTypeLoad(struct INI_ConfigItem *, const char *);

/**
* Result enum for saving config items.
@@ -46,12 +50,12 @@ typedef enum {
/**
* Function for saving a config item value from memory to file.
*/
typedef INI_ConfigSaveItemResult INI_ConfigTypeSave(struct INI_ConfigItem*, const char*);
typedef INI_ConfigSaveItemResult INI_ConfigTypeSave(struct INI_ConfigItem *, const char *);

/**
* Function for retrieving a config item value from the command-line to memory.
*/
typedef void INI_ConfigTypeOverride(struct INI_ConfigItem*, uint8_t, const char*[]);
typedef void INI_ConfigTypeOverride(struct INI_ConfigItem *, uint8_t, const char *[]);

/**
* Struct for the config item type.
@@ -65,17 +69,17 @@ typedef struct {
* Load function.
* @see INI_ConfigTypeLoad
*/
INI_ConfigTypeLoad* load;
INI_ConfigTypeLoad *load;
/**
* Save function.
* @see INI_ConfigTypeSave
*/
INI_ConfigTypeSave* save;
INI_ConfigTypeSave *save;
/**
* Override function.
* @see INI_ConfigTypeOverride
*/
INI_ConfigTypeOverride* override;
INI_ConfigTypeOverride *override;
} INI_ConfigType;

/**
@@ -89,23 +93,23 @@ typedef struct INI_ConfigItem {
/**
* Section where this config item can be found.
*/
const char* section;
const char *section;
/**
* Key where this config item value is serialized and stored.
*/
const char* key;
const char *key;
/**
* Command-line option for overriding this config item's value.
*/
const char* cmdline_option; // TODO: should we extract commandline parsing logic?
const char *cmdline_option; // TODO: should we extract commandline parsing logic?
/**
* Default value of the config item, when the value could not be read from the config file.
*/
const void* default_value;
const void *default_value;
/**
* Validator function for the config item's value.
*/
void* validator;
void *validator;
/**
* Transformer functions.
* @see INI_ConfigTransformer
@@ -115,14 +119,14 @@ typedef struct INI_ConfigItem {
* The memory address where the config item value will reside. This property should allow storing the amount of butes
* specified under `type.size`.
*/
void* dest;
void *dest;
} INI_ConfigItem;

/**
* Retrieves the value from a command-line option.
* @return The string value from the command-line option.
*/
const char* INI_ConfigGetCommandlineOption(uint8_t, const char*[], const char*);
const char *INI_ConfigGetCommandlineOption(uint8_t, const char *[], const char *);

/**
* Result enum for initializing config items.
@@ -142,11 +146,15 @@ typedef enum {
INI_CONFIG_INITIALIZE_RESULT_WARNING
} INI_ConfigInitializeResult;

INI_ConfigInitializeResult INI_ConfigInitialize(INI_ConfigItem[], const char*, uint8_t, const char*[]);
INI_ConfigInitializeResult INI_ConfigInitialize(INI_ConfigItem[], const char *, uint8_t, const char *[]);

typedef int32_t INI_ConfigSaveResult;

INI_ConfigSaveResult INI_ConfigSave(INI_ConfigItem[], const char*);
INI_ConfigSaveResult INI_ConfigSave(INI_ConfigItem[], const char *);

#ifdef __cplusplus
};
#endif

#define INI_CONFIG_DECLARE_TYPE(ID) \
INI_ConfigTypeLoad INI_ConfigLoad##ID; \
@@ -154,24 +162,24 @@ INI_ConfigTypeSave INI_ConfigSave##ID; \
INI_ConfigTypeOverride INI_ConfigOverride##ID

#define INI_CONFIG_TRANSFORMER_NONE (INI_ConfigTransformer) { \
.serialize = NULL, \
.deserialize = NULL, \
.serialize = NULL, \
.deserialize = NULL, \
}

#define INI_CONFIG_ITEM_NULL (INI_ConfigItem) { \
(INI_ConfigType) { \
.size = 0, \
.load = NULL, \
.save = NULL, \
.override = NULL, \
.size = 0, \
.load = NULL, \
.save = NULL, \
.override = NULL, \
}, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
INI_CONFIG_TRANSFORMER_NONE, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
INI_CONFIG_TRANSFORMER_NONE, \
NULL, \
}

#endif

読み込み中…
キャンセル
保存