easyloggingpp icon indicating copy to clipboard operation
easyloggingpp copied to clipboard

ConfigurationTypeHelper::kMaxValid incorrect value?

Open SnorlaxGengar opened this issue 4 years ago • 0 comments

It seems that kMaxValid should be ConfigurationType::LogFlushThreshold?

Version: 9.96.7

enum class ConfigurationType : base::type::EnumType {
        /// @brief Specifies log file max size.
        ///
        /// @detail If file size of corresponding log file (for corresponding level) is >= specified size, log file will
        /// be truncated and re-initiated.
        MaxLogFileSize = 128,
        /// @brief Specifies number of log entries to hold until we flush pending log data
        LogFlushThreshold = 256,
}

class ConfigurationTypeHelper : base::StaticClass {
      public:
        /// @brief Represents minimum valid configuration type. Useful when iterating through enum.
        static const base::type::EnumType kMinValid = static_cast<base::type::EnumType>(ConfigurationType::Enabled);
        /// @brief Represents maximum valid configuration type. This is used internally and you should not need it.
        static const base::type::EnumType kMaxValid = static_cast<base::type::EnumType>(ConfigurationType::MaxLogFileSize);
}

void ConfigurationTypeHelper::forEachConfigType(base::type::EnumType* startIndex, const std::function<bool(void)>& fn) {
  base::type::EnumType cIndexMax = ConfigurationTypeHelper::kMaxValid;
  do {
    if (fn()) {
      break;
    }
    *startIndex = static_cast<base::type::EnumType>(*startIndex << 1);
  } while (*startIndex <= cIndexMax);
}

SnorlaxGengar avatar Oct 29 '20 02:10 SnorlaxGengar