martinzink commented on code in PR #1543:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1543#discussion_r1155850661


##########
libminifi/src/properties/Properties.cpp:
##########
@@ -62,8 +63,100 @@ int Properties::getInt(const std::string &key, int 
default_value) const {
   return it != properties_.end() ? std::stoi(it->second.active_value) : 
default_value;
 }
 
+namespace {
+const core::PropertyValidator* getValidator(const std::string& lookup_value) {
+  auto configuration_property = 
Configuration::CONFIGURATION_PROPERTIES.find(lookup_value);
+
+  if (configuration_property != Configuration::CONFIGURATION_PROPERTIES.end())
+    return configuration_property->second;
+  return nullptr;
+}
+
+std::optional<std::string> 
ensureTimePeriodValidatedPropertyHasExplicitUnit(const core::PropertyValidator* 
const validator, std::string& value) {
+  if (validator != core::StandardValidators::get().TIME_PERIOD_VALIDATOR.get())
+    return std::nullopt;
+  if (value.empty() || !std::all_of(value.begin(), value.end(), ::isdigit))
+    return std::nullopt;
+
+  return value + " ms";
+}
+
+std::optional<std::string> 
ensureDataSizeValidatedPropertyHasExplicitUnit(const core::PropertyValidator* 
const validator, std::string& value) {
+  if (validator != core::StandardValidators::get().DATA_SIZE_VALIDATOR.get())
+    return std::nullopt;
+  if (value.empty() || !std::all_of(value.begin(), value.end(), ::isdigit))
+    return std::nullopt;
+
+  return value + " B";
+}
+
+bool integerValidatedProperty(const core::PropertyValidator* const validator) {
+  return validator == core::StandardValidators::get().INTEGER_VALIDATOR.get()
+      || validator == 
core::StandardValidators::get().UNSIGNED_INT_VALIDATOR.get()
+      || validator == core::StandardValidators::get().LONG_VALIDATOR.get()
+      || validator == 
core::StandardValidators::get().UNSIGNED_LONG_VALIDATOR.get();
+}
+
+std::optional<uint64_t> stringToDataSize(std::string_view input) {

Review Comment:
   it even makes sense to use signed for these, so I've changed it to use 
int64_t in 
https://github.com/apache/nifi-minifi-cpp/pull/1543/commits/64c5975e3fda0911820465778fa4d73f16d12002#diff-f841426e292e70012a81b0fae92f08df7b13120e17b17a92fc360f2f50ec072fR100



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