Coverage Report

Created: 2026-10-19 14:15

src/zserio/IWalkFilter.h
Line
Count
Source
1
#ifndef ZSERIO_I_WALK_FILTER_H_INC
2
#define ZSERIO_I_WALK_FILTER_H_INC
3
4
#include "zserio/IReflectable.h"
5
#include "zserio/ITypeInfo.h"
6
#include "zserio/Types.h"
7
#include "zserio/WalkerConst.h"
8
9
namespace zserio
10
{
11
12
/**
13
 * Interface for filters which can influence the walking.
14
 */
15
template <typename ALLOC = std::allocator<uint8_t>>
16
class IBasicWalkFilter
17
{
18
public:
19
    /** Destructor. */
20
133
    virtual ~IBasicWalkFilter() = default;
21
22
    /**
23
     * Called before an array.
24
     *
25
     * Note that for unset arrays (i.e. non-present optionals) the beforeValue method with nullptr is called
26
     * instead!
27
     *
28
     * \param array Reflectable zserio array.
29
     * \param fieldInfo Array field info.
30
     *
31
     * \return True when the walking should continue to the array.
32
     */
33
    virtual bool beforeArray(
34
            const IBasicReflectableConstPtr<ALLOC>& array, const BasicFieldInfo<ALLOC>& fieldInfo) = 0;
35
36
    /**
37
     * Called after an array.
38
     *
39
     *
40
     * \param array Reflectable zserio array.
41
     * \param fieldInfo Array field info.
42
     *
43
     * \return True when the walking should continue to a next sibling, false to return to the parent.
44
     */
45
    virtual bool afterArray(
46
            const IBasicReflectableConstPtr<ALLOC>& array, const BasicFieldInfo<ALLOC>& fieldInfo) = 0;
47
48
    /**
49
     * Called before a compound object.
50
     *
51
     * Note that for unset compounds (i.e. non-present optionals) the beforeValue method with nullptr is called
52
     * instead!
53
     *
54
     * \param compound Reflectable compound zserio object.
55
     * \param fieldInfo Compound field info.
56
     * \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the compound is not in array.
57
     *
58
     * \return True when the walking should continue into the compound object, false otherwise.
59
     */
60
    virtual bool beforeCompound(const IBasicReflectableConstPtr<ALLOC>& compound,
61
            const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0;
62
63
    /**
64
     * Called after a compound object.
65
     *
66
     * \param compound Reflectable compound zserio object.
67
     * \param fieldInfo Compound field info.
68
     * \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the compound is not in array.
69
     *
70
     * \return True when the walking should continue to a next sibling, false to return to the parent.
71
     */
72
    virtual bool afterCompound(const IBasicReflectableConstPtr<ALLOC>& compound,
73
            const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0;
74
75
    /**
76
     * Called before a simple (or an unset compound or array - i.e. nullptr) value.
77
     *
78
     * \param value Reflectable simple value.
79
     * \param fieldInfo Field info.
80
     * \param elementIndex Element index in array or WALKER_NOT_ELEMENT if the value is not in array.
81
82
     * \return True when the walking should continue to the simple value, false otherwise.
83
     */
84
    virtual bool beforeValue(const IBasicReflectableConstPtr<ALLOC>& value,
85
            const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0;
86
87
    /**
88
     * Called after a simple (or an unset compound or array - i.e. nullptr) value.
89
     *
90
     * \param value Reflectable simple value.
91
     * \param fieldInfo Field info.
92
     * \param elementIndex Element index in array or None if the value is not in array.
93
     *
94
     * \return True when the walking should continue to a next sibling, false to return to the parent.
95
     */
96
    virtual bool afterValue(const IBasicReflectableConstPtr<ALLOC>& value,
97
            const BasicFieldInfo<ALLOC>& fieldInfo, size_t elementIndex) = 0;
98
};
99
100
/** Typedefs to walk filter interface provided for convenience - using default std::allocator<uint8_t>. */
101
/** \{ */
102
using IWalkFilter = IBasicWalkFilter<>;
103
/** \} */
104
105
} // namespace zserio
106
107
#endif // ZSERIO_I_WALK_FILTER_H_INC