Conf file writer. More...
Typedefs | |
typedef struct ConfWriter_T | ConfWriter_T |
Conf writer structure. | |
typedef ConfWriter_T * | ConfWriter |
Conf writer instance. | |
Functions | |
ConfResult | createFileConfWriter (const char *filePath, ConfWriter *confWriter) |
Creates a new Conf file writer instance. | |
void | destroyConfWriter (ConfWriter confWriter) |
Destroys Conf writer instance. | |
bool | writeConfComment (ConfWriter confWriter, const char *comment) |
Writes a comment to the config. | |
bool | writeConfNewLine (ConfWriter confWriter) |
Writes a new line to the config. ('\n') | |
bool | writeConfInt (ConfWriter confWriter, const char *key, int64_t value) |
Writes an integer value to the config. | |
bool | writeConfFloat (ConfWriter confWriter, const char *key, double value, uint8_t precision) |
Writes a floating value to the config. | |
bool | writeConfBool (ConfWriter confWriter, const char *key, bool value) |
Writes a boolean value to the config. | |
bool | writeConfString (ConfWriter confWriter, const char *key, const char *value, size_t length) |
Writes a string value to the config. | |
Conf file writer.
Used to write Conf files. It opens a new file stream and writes the key / value pairs to it. After destroying the Conf writer instance, it closes the file stream.
ConfResult createFileConfWriter | ( | const char * | filePath, |
ConfWriter * | confWriter ) |
Creates a new Conf file writer instance.
The main function for writing Conf files.
[in] | filePath | target file path string |
[out] | confWriter | pointer to the Conf writer instance |
SUCCESS_CONF_RESULT | on success |
FAILED_TO_ALLOCATE_CONF_RESULT | if out of memory |
FAILED_TO_OPEN_FILE_CONF_RESULT | if failed to create a new file |
void destroyConfWriter | ( | ConfWriter | confWriter | ) |
Destroys Conf writer instance.
confWriter | conf writer instance or NULL |
bool writeConfComment | ( | ConfWriter | confWriter, |
const char * | comment ) |
Writes a comment to the config.
confWriter | conf writer instance | |
[in] | comment | target comment string |
bool writeConfNewLine | ( | ConfWriter | confWriter | ) |
Writes a new line to the config. ('\n')
confWriter | conf writer instance |
bool writeConfInt | ( | ConfWriter | confWriter, |
const char * | key, | ||
int64_t | value ) |
Writes an integer value to the config.
confWriter | conf writer instance | |
[in] | key | target item key string |
value | integer item value |
bool writeConfFloat | ( | ConfWriter | confWriter, |
const char * | key, | ||
double | value, | ||
uint8_t | precision ) |
Writes a floating value to the config.
confWriter | conf writer instance | |
[in] | key | target item key string |
value | floating item value | |
precision | number of digits after the decimal point, or 0 (auto detect) |
bool writeConfBool | ( | ConfWriter | confWriter, |
const char * | key, | ||
bool | value ) |
Writes a boolean value to the config.
confWriter | conf writer instance | |
[in] | key | target item key string |
value | boolean item value |
bool writeConfString | ( | ConfWriter | confWriter, |
const char * | key, | ||
const char * | value, | ||
size_t | length ) |
Writes a string value to the config.
confWriter | conf writer instance | |
[in] | key | target item key string |
[in] | value | string item value |
length | string value length, or 0 (auto detect) |