fgerlits commented on a change in pull request #791:
URL: https://github.com/apache/nifi-minifi-cpp/pull/791#discussion_r435306612



##########
File path: extensions/standard-processors/processors/TailFile.cpp
##########
@@ -58,42 +47,108 @@
 #define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
 #endif
 
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wsign-compare"
-#elif defined(__GNUC__) || defined(__GNUG__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 namespace org {
 namespace apache {
 namespace nifi {
 namespace minifi {
 namespace processors {
 
-core::Property TailFile::FileName("File to Tail", "Fully-qualified filename of 
the file that should be tailed when using single file mode, or a file regex 
when using multifile mode", "");
-core::Property TailFile::StateFile("State File", "DEPRECATED. Only use it for 
state migration from the legacy state file.",
-                                   "TailFileState");
-core::Property TailFile::Delimiter("Input Delimiter", "Specifies the character 
that should be used for delimiting the data being tailed"
-                                   "from the incoming file."
-                                   "If none is specified, data will be 
ingested as it becomes available.",
-                                   "");
+core::Property TailFile::FileName(
+    core::PropertyBuilder::createProperty("File to Tail")
+        ->withDescription("Fully-qualified filename of the file that should be 
tailed when using single file mode, or a file regex when using multifile mode")
+        ->isRequired(true)
+        ->build());
+
+core::Property TailFile::StateFile(
+    core::PropertyBuilder::createProperty("State File")
+        ->withDescription("DEPRECATED. Only use it for state migration from 
the legacy state file.")
+        ->isRequired(false)
+        ->withDefaultValue<std::string>("TailFileState")
+        ->build());
+
+core::Property TailFile::Delimiter(
+    core::PropertyBuilder::createProperty("Input Delimiter")
+        ->withDescription("Specifies the character that should be used for 
delimiting the data being tailed"
+         "from the incoming file. If none is specified, data will be ingested 
as it becomes available.")
+        ->isRequired(false)
+        ->withDefaultValue<std::string>("\\n")
+        ->build());
 
 core::Property TailFile::TailMode(
-    core::PropertyBuilder::createProperty("tail-mode", "Tailing 
Mode")->withDescription(
-        "Specifies the tail file mode. In 'Single file' mode only a single 
file will be watched. "
+    core::PropertyBuilder::createProperty("tail-mode", "Tailing Mode")
+        ->withDescription("Specifies the tail file mode. In 'Single file' mode 
only a single file will be watched. "
         "In 'Multiple file' mode a regex may be used. Note that in multiple 
file mode we will still continue to watch for rollover on the initial set of 
watched files. "
         "The Regex used to locate multiple files will be run during the 
schedule phrase. Note that if rotated files are matched by the regex, those 
files will be tailed.")->isRequired(true)
-        ->withAllowableValue<std::string>("Single 
file")->withAllowableValue("Multiple file")->withDefaultValue("Single 
file")->build());
-
-core::Property 
TailFile::BaseDirectory(core::PropertyBuilder::createProperty("tail-base-directory",
 "Base Directory")->isRequired(false)->build());
+        ->withAllowableValue<std::string>("Single 
file")->withAllowableValue("Multiple file")->withDefaultValue("Single file")
+        ->build());
+
+core::Property TailFile::BaseDirectory(
+    core::PropertyBuilder::createProperty("tail-base-directory", "Base 
Directory")
+        ->withDescription("Base directory used to look for files to tail. This 
property is required when using Multiple file mode.")
+        ->isRequired(false)
+        ->build());
+
+core::Property TailFile::RollingFilenamePattern(
+    core::PropertyBuilder::createProperty("Rolling Filename Pattern")
+        ->withDescription("If the file to tail \"rolls over\" as would be the 
case with log files, this filename pattern will be used to "
+        "identify files that have rolled over so MiNiFi can read the remaining 
of the rolled-over file and then continue with the new log file. "
+        "This pattern supports the wildcard characters * and ?, it also 
supports the notation ${filename} to specify a pattern based on the name of the 
file "
+        "(without extension), and will assume that the files that have rolled 
over live in the same directory as the file being tailed.")
+        ->isRequired(false)
+        ->withDefaultValue<std::string>("${filename}.*")
+        ->build());
 
 core::Relationship TailFile::Success("success", "All files are routed to 
success");
 
 const char *TailFile::CURRENT_STR = "CURRENT.";
 const char *TailFile::POSITION_STR = "POSITION.";
 
+namespace {
+  template<typename Container, typename Key>
+  bool containsKey(const Container &container, const Key &key) {
+    return container.find(key) != container.end();
+  }
+
+  template <typename Container, typename Key>
+  uint64_t readOptionalUint64(const Container &container, const Key &key) {
+    const auto it = container.find(key);
+    if (it != container.end()) {
+      return std::stoull(it->second);
+    } else {
+      return 0;
+    }
+  }
+
+  // the delimiter is the first character of the input, allowing some escape 
sequences
+  std::string parseDelimiter(const std::string &input) {
+    if (!input.empty()) {
+      if (input[0] == '\\') {
+        if (input.size() > (std::size_t) 1) {
+          switch (input[1]) {
+            case 'r':
+              return "\r";
+            case 't':
+              return "\t";
+            case 'n':
+              return "\n";
+            case '\\':
+              return "\\";
+            default:
+              return input.substr(1, 1);
+          }
+        } else {
+          return "\\";
+        }
+      } else {
+        return input.substr(0, 1);
+      }
+    } else {
+      return "";
+    }
+  }

Review comment:
       done




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to