nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] nghiaxlee commented on a change in pull request #710: MINIFICPP - 1110, 1111 - PublishKafka, OPC processors should config and
Date Fri, 07 Feb 2020 14:28:33 GMT
nghiaxlee commented on a change in pull request #710: MINIFICPP - 1110,1111 - PublishKafka,
OPC processors should config and
URL: https://github.com/apache/nifi-minifi-cpp/pull/710#discussion_r376417867
 
 

 ##########
 File path: libminifi/include/core/state/Value.h
 ##########
 @@ -115,6 +125,64 @@ class Value {
   std::type_index type_id;
 };
 
+class UInt32Value : public Value {
+ public:
+  explicit UInt32Value(uint32_t value)
+      : Value(std::to_string(value)),
+        value(value) {
+    setTypeId<uint32_t>();
+  }
+
+  explicit UInt32Value(const std::string &strvalue)
+      : Value(strvalue),
+        value(std::stoul(strvalue)) {
+    /**
+     * This is a fundamental change in that we would be changing where this error occurs.
+     * We should be prudent about breaking backwards compatibility, but since Uint32Value
+     * is only created with a validator and type, we **should** be okay.
+     */
+    const auto negative = strvalue.find_first_of('-') != std::string::npos;
+     if (negative){
+       throw std::out_of_range("negative value detected");
+     }
+    setTypeId<uint32_t>();
+  }
+
+  uint32_t getValue() const {
+    return value;
+  }
+ protected:
+
+  virtual bool getValue(uint32_t &ref) {
+    ref = value;
+    return true;
+  }
+
+  virtual bool getValue(int &ref) {
+    if (value <= (std::numeric_limits<int>::max)()) {
 
 Review comment:
   Could you elaborate it?
   This is derived from previous impl of uint64, but I think it makes sense (in logic, not
sure that's actually what we want).
   From my understanding, this check whether `value`(0..2^32-1) is smaller than 2^31-1 or
not, if it is smaller then we assign to `ref`

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


With regards,
Apache Git Services

Mime
View raw message