SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
size.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include <cstdint>
6#include <ostream>
7
8namespace slideio
9{
10 class Size
11 {
12 public:
13 Size() {
14 width = 0;
15 height = 0;
16 }
17 Size(int32_t _width, int32_t _height) {
18 width = _width;
19 height = _height;
20 }
21 Size(const Size& sz) {
22 width = sz.width;
23 height = sz.height;
24 }
25 Size(Size&& sz) noexcept {
26 width = sz.width;
27 height = sz.height;
28 sz.width = 0;
29 sz.height = 0;
30 }
31 ~Size() = default;
32 Size& operator = (const Size& sz) = default;
33 Size& operator = (Size&& sz) noexcept {
34 if (this != &sz) {
35 width = sz.width;
36 height = sz.height;
37 sz.width = 0;
38 sz.height = 0;
39 }
40 return *this;
41 }
42 bool operator == (const Size& other) const {
43 return width == other.width && height == other.height;
44 }
45
46 int32_t area() const {
47 return width * height;
48 }
49 bool empty() const {
50 return width <= 0 || height <= 0;
51 }
52
53 friend std::ostream& operator<<(std::ostream& os, const Size& size) {
54 os << "Size (width: " << size.width << ", height: " << size.height << ")";
55 return os;
56 }
57 int32_t width;
58 int32_t height;
59 };
60}
Definition: exceptions.hpp:15