[ https://issues.apache.org/jira/browse/MINIFICPP-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16719106#comment-16719106 ]
ASF GitHub Bot commented on MINIFICPP-479: ------------------------------------------ Github user arpadboda commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/460#discussion_r241048908 --- Diff: libminifi/include/core/state/Value.h --- @@ -74,94 +157,215 @@ class BoolValue : public Value { explicit BoolValue(bool value) : Value(value ? "true" : "false"), value(value) { + setTypeId<bool>(); + } + explicit BoolValue(const std::string &strvalue) + : Value(strvalue) { + bool l; + std::istringstream(strvalue) >> std::boolalpha >> l; + value = l; // avoid warnings } - bool getValue() { + + bool getValue() const { return value; } protected: + + virtual bool getValue(int &ref) { + if (ref == 1) { + ref = true; + return true; + } else if (ref == 0) { + ref = false; + return true; + } else { + return false; + } + } + + virtual bool getValue(int64_t &ref) { + if (ref == 1) { + ref = true; + return true; + } else if (ref == 0) { + ref = false; + return true; + } else { + return false; + } + } + + virtual bool getValue(uint64_t &ref) { + if (ref == 1) { + ref = true; + return true; + } else if (ref == 0) { + ref = false; + return true; + } else { + return false; + } + } + + virtual bool getValue(bool &ref) { + ref = value; + return true; + } + bool value; }; -class Int64Value : public Value { +class UInt64Value : public Value { public: - explicit Int64Value(uint64_t value) + explicit UInt64Value(uint64_t value) : Value(std::to_string(value)), value(value) { + setTypeId<uint64_t>(); + } + explicit UInt64Value(const std::string &strvalue) + : Value(strvalue), + value(std::stoull(strvalue)) { + setTypeId<uint64_t>(); } - uint64_t getValue() { + + uint64_t getValue() const { return value; } protected: + + virtual bool getValue(int &ref) { + return false; + } + + virtual bool getValue(int64_t &ref) { + if (value < std::numeric_limits<int64_t>::max()) { + ref = value; + return true; + } + return false; + } + + virtual bool getValue(uint64_t &ref) { + ref = value; + return true; + } + + virtual bool getValue(bool &ref) { + return false; + } + uint64_t value; }; +class Int64Value : public Value { + public: + explicit Int64Value(int64_t value) + : Value(std::to_string(value)), + value(value) { + setTypeId<int64_t>(); + } + explicit Int64Value(const std::string &strvalue) + : Value(strvalue), + value(std::stoll(strvalue)) { + setTypeId<int64_t>(); + } + + int64_t getValue() { + return value; + } + protected: + + virtual bool getValue(int &ref) { + return false; + } + + virtual bool getValue(int64_t &ref) { + ref = value; + return true; + } + + virtual bool getValue(uint64_t &ref) { + if (value >= 0) { + ref = value; + return true; + } + return true; + } + + virtual bool getValue(bool &ref) { + return false; + } -static inline std::shared_ptr<Value> createValue( - const bool &object) { + int64_t value; --- End diff -- Honestly I don't really like to hanem a member with different type but same name in each derived type. Why don't simply create value as a template class and use "using" directive to create Int64Value as value<int64_t> ? In my opinion it would require less code duplication. > Incorporate property validation information into manifest > --------------------------------------------------------- > > Key: MINIFICPP-479 > URL: https://issues.apache.org/jira/browse/MINIFICPP-479 > Project: NiFi MiNiFi C++ > Issue Type: Improvement > Reporter: Andrew Christianson > Assignee: Mr TheSegfault > Priority: Major > > High-level intent is to avoid round-trip to c2 to know that flow is valid > (or, invalid in common/trivial ways). -- This message was sent by Atlassian JIRA (v7.6.3#76005)