You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/01/09 16:07:57 UTC
[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request
#707: MINIFICPP-1117 - minifi::Exception is now nothrow copyable
arpadboda commented on a change in pull request #707: MINIFICPP-1117 - minifi::Exception is now nothrow copyable
URL: https://github.com/apache/nifi-minifi-cpp/pull/707#discussion_r364825410
##########
File path: libminifi/include/Exception.h
##########
@@ -44,49 +43,56 @@ enum ExceptionType {
MAX_EXCEPTION
};
-// Exception String
static const char *ExceptionStr[MAX_EXCEPTION] = { "File Operation", "Flow File Operation", "Processor Operation", "Process Session Operation", "Process Schedule Operation", "Site2Site Protocol",
"General Operation", "Regex Operation" };
-// Exception Type to String
inline const char *ExceptionTypeToString(ExceptionType type) {
if (type < MAX_EXCEPTION)
return ExceptionStr[type];
else
return NULL;
}
-// Exception Class
-class Exception : public std::exception {
- public:
- // Constructor
- /*!
- * Create a new exception
- */
- Exception(ExceptionType type, std::string errorMsg)
- : _type(type),
- _errorMsg(std::move(errorMsg)) {
- }
+namespace detail {
+inline size_t StringLength(const char* str) { return strlen(str); }
- // Destructor
- virtual ~Exception() noexcept {
- }
- virtual const char * what() const noexcept {
+template<size_t L>
+constexpr size_t StringLength(const char (&str)[L]) { return L; }
- _whatStr = ExceptionTypeToString(_type);
+inline size_t StringLength(const std::string& str) { return str.size(); }
- _whatStr += ":" + _errorMsg;
- return _whatStr.c_str();
- }
+template<typename... SizeT>
+size_t sum(SizeT... ns) {
+ size_t result = 0;
+ (void)(std::initializer_list<size_t>{(
+ result += ns
+ )...});
+ return result; // (ns + ...)
+}
- private:
- // Exception type
- ExceptionType _type;
- // Exception detailed information
- std::string _errorMsg;
- // Hold the what result
- mutable std::string _whatStr;
+template<typename... Strs>
+std::string StringJoin(Strs&&... strs) {
Review comment:
Good point, we do have a join there.
----------------------------------------------------------------
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