ColumnCount.h 717 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. namespace Web::CSS {
  8. class ColumnCount {
  9. public:
  10. enum class Type {
  11. Auto,
  12. Integer
  13. };
  14. static ColumnCount make_auto()
  15. {
  16. return ColumnCount();
  17. }
  18. static ColumnCount make_integer(int value)
  19. {
  20. return ColumnCount(value);
  21. }
  22. bool is_auto() const { return m_type == Type::Auto; }
  23. int value() const { return *m_value; }
  24. private:
  25. ColumnCount(int value)
  26. : m_type(Type::Integer)
  27. , m_value(value)
  28. {
  29. }
  30. ColumnCount() {};
  31. Type m_type { Type::Auto };
  32. Optional<int> m_value;
  33. };
  34. }