Sun, 15 Dec 2024 13:44:08 +0100
add cxJsonReset() and cxPropertiesReset()
relates to #431
src/cx/json.h | file | annotate | diff | comparison | revisions | |
src/cx/properties.h | file | annotate | diff | comparison | revisions |
--- a/src/cx/json.h Sun Dec 15 12:19:21 2024 +0100 +++ b/src/cx/json.h Sun Dec 15 13:44:08 2024 +0100 @@ -436,6 +436,21 @@ void cxJsonDestroy(CxJson *json); /** + * Destroys and re-initializes the json interface. + * + * You might want to use this, to reset the parser after + * encountering a syntax error. + * + * @param json the json interface + */ +cx_attr_nonnull +static inline void cxJsonReset(CxJson *json) { + const CxAllocator *allocator = json->allocator; + cxJsonDestroy(json); + cxJsonInit(json, allocator); +} + +/** * Adds more data to the input buffer. * * The data will be copied.
--- a/src/cx/properties.h Sun Dec 15 12:19:21 2024 +0100 +++ b/src/cx/properties.h Sun Dec 15 13:44:08 2024 +0100 @@ -363,6 +363,21 @@ void cxPropertiesDestroy(CxProperties *prop); /** + * Destroys and re-initializes the properties interface. + * + * You might want to use this, to reset the parser after + * encountering a syntax error. + * + * @param prop the properties interface + */ +cx_attr_nonnull +static inline void cxPropertiesReset(CxProperties *prop) { + CxPropertiesConfig config = prop->config; + cxPropertiesDestroy(prop); + cxPropertiesInit(prop, config); +} + +/** * Initialize a properties parser with the default configuration. * * @param prop the properties interface