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


##########
minifi-api/include/minifi-cpp/core/Property.h:
##########
@@ -53,158 +47,67 @@ class Property {
 
   Property();
 
-  Property(const PropertyReference&);
+  Property(const PropertyReference &);
 
   virtual ~Property() = default;
 
-  void setTransient() {
-    is_transient_ = true;
-  }
+  void setTransient() { is_transient_ = true; }
 
-  bool isTransient() const {
-    return is_transient_;
-  }
+  bool isTransient() const { return is_transient_; }
+  std::vector<std::string> getAllowedValues() const { return allowed_values_; }
+  void setAllowedValues(std::vector<std::string> allowed_values) { 
allowed_values_ = std::move(allowed_values); }
+  std::optional<std::string> getDefaultValue() const { return default_value_; }
   std::string getName() const;
   std::string getDisplayName() const;
   std::vector<std::string> getAllowedTypes() const;
   std::string getDescription() const;
   const PropertyValidator& getValidator() const;
-  const PropertyValue &getValue() const;
+  [[nodiscard]] nonstd::expected<std::span<const std::string>, 
std::error_code> getAllValues() const;
+  [[nodiscard]] nonstd::expected<std::string_view, std::error_code> getValue() 
const;
+  nonstd::expected<void, std::error_code> setValue(std::string value);
+  nonstd::expected<void, std::error_code> appendValue(std::string value);
+  void clearValues();
   bool getRequired() const;
   bool isSensitive() const;
   bool supportsExpressionLanguage() const;
   std::vector<std::string> getDependentProperties() const;
   std::vector<std::pair<std::string, std::string>> getExclusiveOfProperties() 
const;
   std::vector<std::string> getValues();
-
-  const PropertyValue &getDefaultValue() const {
-    return default_value_;
-  }
-
-  template<typename T = std::string>
-  void setValue(const T &value) {
-    if (!is_collection_) {
-      values_.clear();
-      values_.push_back(default_value_);
-    } else {
-      values_.push_back(default_value_);
-    }
-    PropertyValue& vn = values_.back();
-    vn.setValidator(*validator_);
-    vn = value;
-    ValidationResult result = vn.validate(name_);
-    if (!result.valid) {
-      throw utils::internal::InvalidValueException(name_ + " value validation 
failed");
-    }
+  PropertyReference getReference() const {
+    return PropertyReference(name_, display_name_, description_, is_required_, 
is_sensitive_, {}, {}, {}, {}, default_value_, validator_, supports_el_);
   }
 
-  void setValue(PropertyValue &newValue) {
-    if (!is_collection_) {
-      values_.clear();
-      values_.push_back(newValue);
-    } else {
-      values_.push_back(newValue);
-    }
-    PropertyValue& vn = values_.back();
-    vn.setValidator(*validator_);
-    ValidationResult result = vn.validate(name_);
-    if (!result.valid) {
-      throw utils::internal::InvalidValueException(name_ + " value validation 
failed");
-    }
-  }
   void setSupportsExpressionLanguage(bool supportEl);
 
-  std::vector<PropertyValue> getAllowedValues() const {
-    return allowed_values_;
-  }
-
-  void setAllowedValues(gsl::span<const std::string_view> allowed_values, 
const core::PropertyParser& property_parser);
-
+  /**
+   * Add value to the collection of values.
+   */
   void addValue(const std::string &value);
   Property &operator=(const Property &other) = default;
   Property &operator=(Property &&other) = default;
-
-  bool operator<(const Property & right) const;
-
-  static bool StringToPermissions(const std::string& input, uint32_t& output) {
-    uint32_t temp = 0U;
-    if (input.size() == 9U) {
-      /* Probably rwxrwxrwx formatted */
-      for (size_t i = 0; i < 3; i++) {
-        if (input[i * 3] == 'r') {
-          temp |= 04 << ((2 - i) * 3);
-        } else if (input[i * 3] != '-') {
-          return false;
-        }
-        if (input[i * 3 + 1] == 'w') {
-          temp |= 02 << ((2 - i) * 3);
-        } else if (input[i * 3 + 1] != '-') {
-          return false;
-        }
-        if (input[i * 3 + 2] == 'x') {
-          temp |= 01 << ((2 - i) * 3);
-        } else if (input[i * 3 + 2] != '-') {
-          return false;
-        }
-      }
-    } else {
-      /* Probably octal */
-      try {
-        size_t pos = 0U;
-        temp = std::stoul(input, &pos, 8);
-        if (pos != input.size()) {
-          return false;
-        }
-        if ((temp & ~static_cast<uint32_t>(0777)) != 0U) {
-          return false;
-        }
-      } catch (...) {
-        return false;
-      }
-    }
-    output = temp;
-    return true;
-  }
-
-  template<typename T>
-  static bool StringToInt(std::string input, T &output);
-
-  static bool StringToInt(std::string input, int64_t &output) {
-    return StringToInt<int64_t>(input, output);
-  }
-
-  static bool StringToInt(std::string input, uint64_t &output) {
-    return StringToInt<uint64_t>(input, output);
-  }
-
-  static bool StringToInt(std::string input, int32_t &output) {
-    return StringToInt<int32_t>(input, output);
-  }
-
-  static bool StringToInt(std::string input, uint32_t &output) {
-    return StringToInt<uint32_t>(input, output);
-  }
+  // Compare

Review Comment:
   👍 
https://github.com/apache/nifi-minifi-cpp/pull/1926/commits/4df97ce16513a4e98884d604bbafef2d143466cb



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