LogLevel.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2023-02-06
  7. *
  8. * */
  9. #ifndef LS_STD_LOG_LEVEL_HPP
  10. #define LS_STD_LOG_LEVEL_HPP
  11. #include "LogLevelValue.hpp"
  12. #include <ls-std/core/Class.hpp>
  13. #include <ls-std/os/dynamic-goal.hpp>
  14. #include <unordered_map>
  15. namespace ls::std::io
  16. {
  17. class LS_STD_DYNAMIC_GOAL LogLevel : public ls::std::core::Class
  18. {
  19. public:
  20. explicit LogLevel(const ls::std::io::LogLevelValue &_value);
  21. LogLevel();
  22. ~LogLevel() override;
  23. operator unsigned char() const;
  24. ls::std::io::LogLevel &operator=(const ls::std::io::LogLevelValue &_value);
  25. bool operator<(const ls::std::io::LogLevelValue &_value);
  26. bool operator<=(const ls::std::io::LogLevelValue &_value);
  27. bool operator>(const ls::std::io::LogLevelValue &_value);
  28. bool operator>=(const ls::std::io::LogLevelValue &_value);
  29. bool operator==(const ls::std::io::LogLevelValue &_value);
  30. void setLogLevel(const ls::std::io::LogLevelValue &_value);
  31. void setLogLevel(const ::std::string &_value);
  32. [[nodiscard]] ::std::string toString() const;
  33. private:
  34. ::std::unordered_map<uint8_t, ::std::string> level{};
  35. ls::std::io::LogLevelValue value{};
  36. [[nodiscard]] ls::std::io::LogLevelValue _getValueFromString(const ::std::string &_value);
  37. void _init();
  38. [[nodiscard]] bool _isValidLogLevelString(const ::std::string &_value);
  39. };
  40. }
  41. #endif