xtd 0.2.0
size.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.hpp"
6#include "size_f.hpp"
7#include <xtd/iequatable>
8#include <xtd/object>
9#include <xtd/string>
10#include <ostream>
11
13namespace xtd {
15 namespace drawing {
17 struct point;
19
33
38
40
43 size() = default;
46 explicit size(const xtd::drawing::point& point) noexcept;
50 size(int32 width, int32 height) noexcept;
52
54 size(const xtd::drawing::size&) noexcept = default;
55 size& operator =(const xtd::drawing::size& size) noexcept = default;
56 operator size_f() const noexcept;
58
60
65 int32 width = 0;
66
70 int32 height = 0;
71
74 bool is_empty() const noexcept;
76
78
83 bool equals(const xtd::object& obj) const noexcept override;
87 bool equals(const xtd::drawing::size& other) const noexcept override;
88
91 xtd::size get_hash_code() const noexcept override;
92
95 xtd::string to_string() const noexcept override;
97
99
105 static size add(const size& size1, const size& size2) noexcept;
106
110 static size ceiling(const size_f& value) noexcept;
111
115 static size round(const size_f& value) noexcept;
116
121 static xtd::drawing::size subtract(const xtd::drawing::size& sz1, const xtd::drawing::size& sz2) noexcept;
122
126 static size truncate(const size_f& value) noexcept;
128
130
135 size operator +(const xtd::drawing::size& size) const noexcept;
136
140 size& operator +=(const xtd::drawing::size& size) noexcept;
141
145 size operator -(const xtd::drawing::size& size) const noexcept;
146
150 size& operator -=(const xtd::drawing::size& size) noexcept;
152 };
153 }
154
156 template<>
157 inline drawing::size parse<drawing::size>(const std::string& str) {
158 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
159 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
160 }
162}
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.hpp:116
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ point
Specifies a printer's point (1/72 inch) as the unit of measure.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::drawing::size_f class.
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.hpp:31
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
size(const xtd::drawing::point &point) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified xtd::drawing::point cla...
size(int32 width, int32 height) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified dimensions.
size()=default
Initializes a new instance of the xtd::drawing::size class that has a Height and Width value of 0.
static const xtd::drawing::size empty
Gets a xtd::drawing::size class that has a Height and Width value of 0. This field is constant.
Definition size.hpp:36