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