Struct chFilterIf

Struct Documentation

struct chFilterIf

Channel Filter Interface.

Routines to be implemented by each Channel Filter.

Parsing event handlers

A filter that doesn’t accept a particular JSON value type may use a NULL pointer to the parsing handler for that value type, which is equivalent to a routine that always returns parse_stop.

parse_result (*parse_start)(chFilter *filter)

Create new filter instance.

Called when a new filter instance is requested. Filter may allocate resources for this instance and store in filter->puser. If parse_start() returns parse_continue for a filter, one of parse_abort() or parse_end() will later be called for that same filter.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

void (*parse_abort)(chFilter *filter)

Parsing of filter instance is being cancelled.

This function should release any memory allocated for the given filter instance; no further parsing handlers will be called for it.

Param filter

Pointer to instance data.

parse_result (*parse_end)(chFilter *filter)

Parsing of filter instance has completed successfully.

The parser has reached the end of this instance and no further parsing handlers will be called for it. The filter must check the instance data and indicate whether it was complete or not.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

parse_result (*parse_null)(chFilter *filter)

Parser saw null value.

Optional. Null values are rarely accepted by channel filters.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

parse_result (*parse_boolean)(chFilter *filter, int boolVal)

Parser saw boolean value.

Optional.

Param filter

Pointer to instance data.

Param boolVal

true/false Value.

Return

parse_stop on error, or parse_continue

parse_result (*parse_integer)(chFilter *filter, long integerVal)

Parser saw integer value.

Optional.

Param filter

Pointer to instance data.

Param integerVal

Value.

Return

parse_stop on error, or parse_continue

parse_result (*parse_double)(chFilter *filter, double doubleVal)

Parser saw double value.

Optional.

Param filter

Pointer to instance data.

Param doubleVal

Value.

Return

parse_stop on error, or parse_continue

parse_result (*parse_string)(chFilter *filter, const char *stringVal, size_t stringLen)

Parser saw string value.

Optional.

Param filter

Pointer to instance data.

Param stringVal

Value, not zero-terminated.

Param stringLen

Number of chars in stringVal.

Return

parse_stop on error, or parse_continue

parse_result (*parse_start_map)(chFilter *filter)

Parser saw start of a JSON map value.

Optional. Inside a JSON map all data consists of key/value pairs.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

parse_result (*parse_map_key)(chFilter *filter, const char *key, size_t stringLen)

Parser saw a JSON map key.

Optional.

Param filter

Pointer to instance data.

Param key

Value not zero-terminated.

Param stringLen

Number of chars in key

Return

parse_stop on error, or parse_continue

parse_result (*parse_end_map)(chFilter *filter)

Parser saw end of a JSON map value.

Optional.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

parse_result (*parse_start_array)(chFilter *filter)

Parser saw start of a JSON array value.

Optional. Data inside a JSON array doesn’t have to be all of the same type.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

parse_result (*parse_end_array)(chFilter *filter)

Parser saw end of a JSON array value.

Optional.

Param filter

Pointer to instance data.

Return

parse_stop on error, or parse_continue

Channel operations

long (*channel_open)(chFilter *filter)

Open filter on channel.

Optional, initialize instance.

Param filter

Pointer to instance data.

Return

0, or an error status value.

void (*channel_register_pre)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)

Get pre-chain filter function.

Optional. Returns pre-chain filter function and context.

Param filter

[in] Pointer to instance data.

Param cb_out

[out] Write filter function pointer here.

Param arg_out

[out] Write private data pointer here.

Param probe

[inout] db_field_log with metadata for adjusting.

void (*channel_register_post)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)

Get post-chain filter function.

Optional, return post-chain filter function and context.

Param filter

[in] Pointer to instance data.

Param cb_out

[out] Write filter function pointer here.

Param arg_out

[out] Write private data pointer here.

Param probe

[inout] db_field_log with metadata for adjusting.

void (*channel_report)(chFilter *filter, int level, const unsigned short indent)

Print information about filter to stdout.

Optional.

Param filter

Pointer to instance data.

Param level

Higher levels may provide more detail.

Param indent

Indent all lines by this many spaces.

void (*channel_close)(chFilter *filter)

Close filter.

Optional, releases resources allocated for this instance.

Param filter

Pointer to instance data.

Public Members

void (*priv_free)(void *puser)

Release private filter data.

Called during database shutdown to release resources allocated by the filter.

Param puser

The user-pointer passed into dbRegisterFilter().