adamdebreceni commented on a change in pull request #1188:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1188#discussion_r724255158



##########
File path: extensions/standard-processors/processors/DefragTextFlowFiles.h
##########
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <regex>
+#include <memory>
+#include <string>
+#include <set>
+
+#include "core/Processor.h"
+#include "utils/FlowFileStore.h"
+#include "utils/Enum.h"
+#include "serialization/PayloadSerializer.h"
+
+
+namespace org::apache::nifi::minifi::processors {
+
+class DefragTextFlowFiles : public core::Processor {
+ public:
+  explicit DefragTextFlowFiles(const std::string& name,  const 
utils::Identifier& uuid = {})
+      : Processor(name, uuid) {
+    logger_ = logging::LoggerFactory<DefragTextFlowFiles>::getLogger();
+  }
+  EXTENSIONAPI static core::Relationship Self;
+  EXTENSIONAPI static core::Relationship Success;
+  EXTENSIONAPI static core::Relationship Original;
+  EXTENSIONAPI static core::Relationship Failure;
+
+  EXTENSIONAPI static core::Property Pattern;
+  EXTENSIONAPI static core::Property PatternLoc;
+  EXTENSIONAPI static core::Property MaxBufferAge;
+  EXTENSIONAPI static core::Property MaxBufferSize;
+
+  void initialize() override;
+  void onSchedule(core::ProcessContext* context, core::ProcessSessionFactory* 
sessionFactory) override;
+  void onTrigger(core::ProcessContext* context, core::ProcessSession* session) 
override;
+  void restore(const std::shared_ptr<core::FlowFile>& flowFile) override;
+  std::set<std::shared_ptr<core::Connectable>> getOutGoingConnections(const 
std::string &relationship) const override;
+
+  SMART_ENUM(PatternLocation,
+             (END_OF_MESSAGE, "End of Message"),
+             (START_OF_MESSAGE, "Start of Message")
+  )
+
+  class LastPatternFinder : public InputStreamCallback {
+   public:
+    LastPatternFinder(const std::regex& pattern, PatternLocation 
pattern_location) : pattern_(pattern), pattern_location_(pattern_location) {}
+    ~LastPatternFinder() override = default;
+    int64_t process(const std::shared_ptr<io::BaseStream>& stream) override;
+
+    bool foundPattern() const { return last_pattern_location.has_value(); }

Review comment:
       we could also employ the initializer form of the if-statement
   
   ```
   if (auto split_position = find_last_pattern.getLastPatternPosition()) {
     ...
   }
   ```
   unfortunately we would have to use it as `*split_position`, not sure which 
one would be "better" overall




-- 
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]


Reply via email to