attribute_scope.h 708 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // attribute_scope.hpp
  3. // ncurses-wrapper
  4. //
  5. // Created by Sam Jaffe on 7/23/24.
  6. //
  7. #pragma once
  8. #include <vector>
  9. #include <ncurses-wrapper/forward.h>
  10. namespace curses {
  11. class AttributeScope {
  12. private:
  13. Window *window_{nullptr};
  14. std::vector<NCURSES_ATTR_T> self_{};
  15. bool good_{true};
  16. public:
  17. AttributeScope() = default;
  18. AttributeScope(std::vector<NCURSES_ATTR_T> init, Window &window);
  19. AttributeScope(AttributeScope const &) = delete;
  20. AttributeScope(AttributeScope &&other) = default;
  21. AttributeScope &operator=(AttributeScope const &) = delete;
  22. AttributeScope &operator=(AttributeScope &&other) = default;
  23. ~AttributeScope();
  24. operator bool() const { return good_; }
  25. };
  26. }