cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
size.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <cstddef>
13#include <cstdint>
14
15namespace Term
16{
17
18class Rows
19{
20public:
21 Rows() = default;
22 explicit Rows(const std::uint16_t& rows) : m_rows(rows) {}
23 operator std::size_t() const noexcept { return m_rows; }
24
25private:
26 std::uint16_t m_rows{0};
27};
28
30{
31public:
32 Columns() = default;
33 explicit Columns(const std::uint16_t& columns) : m_columns(columns) {}
34 operator std::size_t() const noexcept { return m_columns; }
35
36private:
37 std::uint16_t m_columns{0};
38};
39
40class Size
41{
42public:
43 Size() = default;
46 std::size_t area() const noexcept { return static_cast<std::size_t>(m_rows) * static_cast<std::size_t>(m_columns); }
47 const Rows& rows() const noexcept { return m_rows; }
48 const Columns& columns() const noexcept { return m_columns; }
49
50private:
53};
54
55} // namespace Term
std::uint16_t m_columns
Definition size.hpp:37
Columns(const std::uint16_t &columns)
Definition size.hpp:33
Columns()=default
std::uint16_t m_rows
Definition size.hpp:26
Rows()=default
Rows(const std::uint16_t &rows)
Definition size.hpp:22
std::size_t area() const noexcept
Definition size.hpp:46
Size(const Rows &rows, const Columns &columns)
Definition size.hpp:44
Size()=default
Rows m_rows
Definition size.hpp:51
Size(const Columns &columns, const Rows &rows)
Definition size.hpp:45
Columns m_columns
Definition size.hpp:52
const Rows & rows() const noexcept
Definition size.hpp:47
const Columns & columns() const noexcept
Definition size.hpp:48
Definition args.cpp:13