LogLevel.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-20
  6. * Changed: 2023-05-19
  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 <string_view>
  15. #include <unordered_map>
  16. namespace ls::std::io
  17. {
  18. class LS_STD_DYNAMIC_GOAL LogLevel : public ls::std::core::Class
  19. {
  20. public:
  21. explicit LogLevel(const ls::std::io::LogLevelValue &_value);
  22. LogLevel();
  23. ~LogLevel() noexcept override;
  24. ls::std::io::LogLevel &operator=(const ls::std::io::LogLevelValue &_value);
  25. bool operator<(const ls::std::io::LogLevelValue &_value) const;
  26. bool operator<=(const ls::std::io::LogLevelValue &_value) const;
  27. bool operator>(const ls::std::io::LogLevelValue &_value) const;
  28. bool operator>=(const ls::std::io::LogLevelValue &_value) const;
  29. bool operator==(const ls::std::io::LogLevelValue &_value) const;
  30. [[nodiscard]] ls::std::io::LogLevelValue getValue() const;
  31. void setLogLevel(const ls::std::io::LogLevelValue &_value);
  32. void setLogLevel(const ::std::string &_value);
  33. [[nodiscard]] ::std::string toString() const;
  34. private:
  35. ::std::unordered_map<ls::std::io::LogLevelValue, ::std::string> level{};
  36. ls::std::io::LogLevelValue value{};
  37. [[nodiscard]] ls::std::io::LogLevelValue _getValueFromString(const ::std::string &_value);
  38. void _init();
  39. [[nodiscard]] bool _isValidLogLevelString(::std::string_view _value) const;
  40. };
  41. }
  42. #endif