adamdebreceni commented on code in PR #1387:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1387#discussion_r966924796
##########
libminifi/src/utils/RegexUtils.cpp:
##########
@@ -22,58 +22,86 @@
#include <vector>
#include "Exception.h"
+#include <regex.h>
+
+namespace org::apache::nifi::minifi::utils {
#ifndef NO_MORE_REGFREEE
-namespace {
-std::size_t getMaxGroupCountOfRegex(const std::string& regex) {
- return std::count(regex.begin(), regex.end(), '(') + 1;
+SMatch::SMatch(const SMatch& other) {
+ *this = other;
}
-} // namespace
-#endif
-
-namespace org::apache::nifi::minifi::utils {
+SMatch::SMatch(SMatch&& other) {
+ *this = std::move(other);
+}
-#ifndef NO_MORE_REGFREEE
-SMatch::SuffixWrapper SMatch::suffix() const {
- if ((size_t) matches_[0].match.rm_eo >= string_.size()) {
- return SuffixWrapper{std::string()};
- } else {
- return SuffixWrapper{string_.substr(matches_[0].match.rm_eo)};
+SMatch& SMatch::operator=(const SMatch& other) {
+ if (this == &other) {
+ return *this;
+ }
+ reset(other.string_);
+ matches_.reserve(other.matches_.size());
+ ready_ = other.ready_;
+ for (const auto& sub_match : other.matches_) {
+ size_t begin_off =
gsl::narrow<size_t>(std::distance(other.string_.begin(), sub_match.first));
+ size_t end_off = gsl::narrow<size_t>(std::distance(other.string_.begin(),
sub_match.second));
+ matches_.push_back(Regmatch{sub_match.matched, string_.begin() +
begin_off, string_.begin() + end_off});
Review Comment:
changed these to `emplace_back`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]