szaszm commented on a change in pull request #710: MINIFICPP - 1110,1111 -
PublishKafka, OPC processors should config and
URL: https://github.com/apache/nifi-minifi-cpp/pull/710#discussion_r375869797
##########
File path: libminifi/test/integration/IntegrationBase.h
##########
@@ -42,6 +42,17 @@ class IntegrationBase {
configureSecurity();
}
+ // Return the last position and number of occurrences.
+ std::pair<size_t, uint32_t> countPatInStr(const std::string &str, const
std::string &pattern) {
+ size_t last_pos = 0;
+ unsigned int occurrences = 0;
Review comment:
Indeed, it should be consistent. This is minor, but I'll write it down
anyway.
I don't think the count type should be `uint32_t`, since there's nothing
that mandates 32 bits of storage for our integer.
The position is fine as `size_t`.
Some candidates:
- `int`: plain and simple, we return an integer
- `unsigned int`: as above, but a count can not be smaller than zero and we
can signal this with the type
- `size_t`: The max. possible count of matches, in the case of a theoretical
string spanning the full addressable memory and a search string matching on
every character.
- `ptrdiff_t`: The max. possible count of matches is the size of the string,
that is the difference between the last and first element pointers. Note:
signed integer
- `typename iterator_traits<std::string::iterator>::difference_type`: Same
rationale as for `ptrdiff_t`, but for last and first iterators. This is what
`std::count` returns.
My suggestion would be a simple `int`, `unsigned int` or a correct `typename
iterator_traits<std::string::iterator>::difference_type`, in the order of my
preference.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services