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



##########
File path: libminifi/src/utils/LineByLineInputOutputStreamCallback.cpp
##########
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+#include "utils/LineByLineInputOutputStreamCallback.h"
+
+#include "utils/gsl.h"
+
+namespace org::apache::nifi::minifi::utils {
+
+LineByLineInputOutputStreamCallback::LineByLineInputOutputStreamCallback(CallbackType
 callback)
+  : callback_(std::move(callback)) {
+}
+
+int64_t LineByLineInputOutputStreamCallback::process(const 
std::shared_ptr<io::BaseStream>& input, const std::shared_ptr<io::BaseStream>& 
output) {
+  gsl_Expects(input);
+  gsl_Expects(output);
+
+  if (int64_t status = readInput(*input); status <= 0) {
+    return status;
+  }
+
+  std::size_t total_bytes_written_ = 0;
+  bool is_first_line = true;
+  readLine();
+  do {
+    readLine();
+    std::string output_line = callback_(*current_line_, is_first_line, 
isLastLine());
+    output->write(reinterpret_cast<const uint8_t *>(output_line.data()), 
output_line.size());

Review comment:
       should we check the return value of `write` here?




-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to