Conf file reader. More...
Typedefs | |
| typedef struct ConfReader_T | ConfReader_T |
| Conf reader structure. | |
| typedef ConfReader_T * | ConfReader |
| Conf reader instance. | |
Functions | |
| ConfResult | createFileConfReader (const char *filePath, ConfReader *confReader, size_t *errorLine) |
| Creates a new Conf file reader instance. | |
| ConfResult | createDataConfReader (const char *data, ConfReader *confReader, size_t *errorLine) |
| Create a new Conf data reader instance. | |
| void | destroyConfReader (ConfReader confReader) |
| Destroys Conf reader instance. | |
| bool | getConfReaderType (ConfReader confReader, const char *key, ConfDataType *type) |
| Returns the type of value by key. | |
| bool | getConfReaderInt (ConfReader confReader, const char *key, int64_t *value) |
| Returns the integer value by key. | |
| bool | getConfReaderFloat (ConfReader confReader, const char *key, double *value) |
| Returns the floating value by key. | |
| bool | getConfReaderBool (ConfReader confReader, const char *key, bool *value) |
| Returns the boolean value by key. | |
| bool | getConfReaderString (ConfReader confReader, const char *key, const char **value, uint64_t *length) |
| Returns the string value by key. | |
Conf file reader.
Used to read Conf files. Reads all data from a file and organizes it into a list optimized for fast retrieval of values by key.
| ConfResult createFileConfReader | ( | const char * | filePath, |
| ConfReader * | confReader, | ||
| size_t * | errorLine ) |
Creates a new Conf file reader instance.
The main function for reading Conf files.
| [in] | filePath | target Conf file path string |
| [out] | confReader | pointer to the Conf reader instance |
| [out] | errorLine | pointer to the error line or NULL |
| SUCCESS_CONF_RESULT | on success |
| FAILED_TO_ALLOCATE_CONF_RESULT | if out of memory |
| FAILED_TO_OPEN_FILE_CONF_RESULT | if file doesn't exist |
| BAD_KEY_CONF_RESULT | if config has invalid key |
| BAD_VALUE_CONF_RESULT | if config has invalid value |
| BAD_ITEM_CONF_RESULT | if config has invalid key / value pair |
| REPEATING_KEYS_CONF_RESULT | if config has duplicate keys |
| ConfResult createDataConfReader | ( | const char * | data, |
| ConfReader * | confReader, | ||
| size_t * | errorLine ) |
Create a new Conf data reader instance.
The main function for reading Conf data from strings.
| [in] | data | target Conf data string |
| [out] | confReader | pointer to the Conf reader instance |
| [out] | errorLine | pointer to the error line or NULL |
| SUCCESS_CONF_RESULT | on success |
| FAILED_TO_ALLOCATE_CONF_RESULT | if out of memory |
| FAILED_TO_OPEN_FILE_CONF_RESULT | if file doesn't exist |
| BAD_KEY_CONF_RESULT | if config has invalid key |
| BAD_VALUE_CONF_RESULT | if config has invalid value |
| BAD_ITEM_CONF_RESULT | if config has invalid key / value pair |
| REPEATING_KEYS_CONF_RESULT | if config has duplicate keys |
| void destroyConfReader | ( | ConfReader | confReader | ) |
Destroys Conf reader instance.
| confReader | conf reader instance or NULL |
| bool getConfReaderType | ( | ConfReader | confReader, |
| const char * | key, | ||
| ConfDataType * | type ) |
Returns the type of value by key.
Useful if we are reading a config we don't know anything about.
| confReader | conf reader instance | |
| [in] | key | target item key string |
| [out] | type | pointer to the value type |
| bool getConfReaderInt | ( | ConfReader | confReader, |
| const char * | key, | ||
| int64_t * | value ) |
Returns the integer value by key.
| confReader | conf reader instance | |
| [in] | key | target item key string |
| [out] | value | pointer to the integer value |
| bool getConfReaderFloat | ( | ConfReader | confReader, |
| const char * | key, | ||
| double * | value ) |
Returns the floating value by key.
| confReader | conf reader instance | |
| [in] | key | target item key string |
| [out] | value | pointer to the floating value |
| bool getConfReaderBool | ( | ConfReader | confReader, |
| const char * | key, | ||
| bool * | value ) |
Returns the boolean value by key.
| confReader | conf reader instance | |
| [in] | key | target item key string |
| [out] | value | pointer to the boolean value |
| bool getConfReaderString | ( | ConfReader | confReader, |
| const char * | key, | ||
| const char ** | value, | ||
| uint64_t * | length ) |
Returns the string value by key.
| confReader | conf reader instance | |
| [in] | key | target item key string |
| [out] | value | pointer to the string value |
| [out] | length | pointer to the string length or NULL |