1 /***********************************************************************************************************************************
2 IO Filter Interface
3 
4 Filters can modify an i/o stream (e.g. GzCompress, GzDecompress), generate a result (e.g. IoSize, CryptoHash), or even do both.
5 
6 A filter is created using a constructor implemented by each filter (e.g. ioBufferNew).  Filter processing is managed by
7 IoFilterGroup so the only user facing functions are ioFilterResult() and ioFilterType().
8 
9 Information on implementing a filter is in filter.internal.h.
10 ***********************************************************************************************************************************/
11 #ifndef COMMON_IO_FILTER_FILTER_H
12 #define COMMON_IO_FILTER_FILTER_H
13 
14 /***********************************************************************************************************************************
15 Object type
16 ***********************************************************************************************************************************/
17 typedef struct IoFilter IoFilter;
18 
19 #include "common/io/filter/filter.intern.h"
20 #include "common/type/object.h"
21 #include "common/type/string.h"
22 #include "common/type/variant.h"
23 
24 /***********************************************************************************************************************************
25 Getters/Setters
26 ***********************************************************************************************************************************/
27 // Get filter result
28 Variant *ioFilterResult(const IoFilter *this);
29 
30 // Identifies the filter and is used when pulling results from the filter group
31 __attribute__((always_inline)) static inline const String *
ioFilterType(const IoFilter * const this)32 ioFilterType(const IoFilter *const this)
33 {
34     return THIS_PUB(IoFilter)->type;
35 }
36 
37 /***********************************************************************************************************************************
38 Destructor
39 ***********************************************************************************************************************************/
40 __attribute__((always_inline)) static inline void
ioFilterFree(IoFilter * const this)41 ioFilterFree(IoFilter *const this)
42 {
43     objFree(this);
44 }
45 
46 /***********************************************************************************************************************************
47 Macros for function logging
48 ***********************************************************************************************************************************/
49 String *ioFilterToLog(const IoFilter *this);
50 
51 #define FUNCTION_LOG_IO_FILTER_TYPE                                                                                                \
52     IoFilter *
53 #define FUNCTION_LOG_IO_FILTER_FORMAT(value, buffer, bufferSize)                                                                   \
54     FUNCTION_LOG_STRING_OBJECT_FORMAT(value, ioFilterToLog, buffer, bufferSize)
55 
56 #endif
57