field_characters_count_manager.h 608 B

1234567891011121314151617181920212223242526
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. class FieldCharsCountManager final {
  9. public:
  10. FieldCharsCountManager();
  11. void setCount(int count);
  12. [[nodiscard]] int count() const;
  13. [[nodiscard]] bool isLimitExceeded() const;
  14. [[nodiscard]] rpl::producer<> limitExceeds() const;
  15. private:
  16. int _current = 0;
  17. int _previous = 0;
  18. bool _isLimitExceeded = false;
  19. rpl::event_stream<> _limitExceeds;
  20. };