Refactor: Modernizing filters to Cpp11. #1323
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #977
The change is mostly C-style casts to Cpp style casts.
Marked all
parseToString
overrides asoverride
.Additionally, some changes I think it might be beneficial, but I would like an opinion before starting on them:
parseToString
being marked asconst
.Reasoning: The conversion to string should not modify the filter internals under any circumstances.
Potential issues: If someone has written custom filters inherited from
GenericFilter
or down the chain and implemented their ownparseToString
this will be a breaking change for the custom filter asparseToString
andparseToString const
are considered different functions by the compiler.No expected issues with plain usage of the function, if only one version exists, or the non-const version calls the const version as a default via some black magics like:
enum
->enum class
- Read some of the discussion in Refactor code: use enum class in TcpLayer #1289, about potential solutions to that. Duplicated enums/ctors seem like the best solution for keeping the backwards compatibility in the intermediary period. Although I am debating on the naming. Simplest solution is to stick aV2
orType
suffix or something? (exampleDirection
->DirectionV2
orDirectionType
).Also I am wondering what to do with the functions that return an enum like
Direction getDir()
?Implement C++11 move semantics for filter ctors that take
string const&
. Either by implementing 'perfect forwarding' or 'pass by value and move' as a simpler alternative.Explicitly defaulting empty destructors. Should produce no compatibility issues in the current situation but can have some caveats in other situations explained here