xtd 0.2.0
size_f.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.hpp"
6#include <xtd/iequatable>
7#include <xtd/object>
8#include <xtd/string>
9#include <ostream>
10
12namespace xtd {
14 namespace drawing {
16 struct point_f;
17 struct size;
19
33
38
40
43 size_f() noexcept = default;
44
47 explicit size_f(const xtd::drawing::point_f& point) noexcept;
48
52 size_f(float width, float height) noexcept;
54
56 size_f(const xtd::drawing::size_f&) noexcept = default;
57 size_f& operator =(const xtd::drawing::size_f& size) noexcept = default;
59
61
66 float width = .0f;
67
71 float height = .0f;
72
75 bool is_empty() const noexcept;
77
79
84 bool equals(const xtd::object& obj) const noexcept override;
88 bool equals(const xtd::drawing::size_f& other) const noexcept override;
89
92 xtd::size get_hash_code() const noexcept override;
93
96 xtd::string to_string() const noexcept override;
98
100
106 static xtd::drawing::size_f add(const xtd::drawing::size_f& size1, const xtd::drawing::size_f& size2) noexcept;
107
112 static xtd::drawing::size_f subtract(const xtd::drawing::size_f& sz1, const xtd::drawing::size_f& sz2) noexcept;
114
116
121 size_f operator +(const xtd::drawing::size_f& size) const noexcept;
125 size_f operator +(const xtd::drawing::size& size) const noexcept;
126
130 size_f& operator +=(const xtd::drawing::size_f& size) noexcept;
134 size_f& operator +=(const xtd::drawing::size& size) noexcept;
135
139 size_f operator -(const xtd::drawing::size_f& size) const noexcept;
143 size_f operator -(const xtd::drawing::size& size) const noexcept;
144
148 size_f& operator -=(const xtd::drawing::size_f& size) noexcept;
152 size_f& operator -=(const xtd::drawing::size& size) noexcept;
154 };
155 }
156
158 template<>
159 inline drawing::size_f parse<drawing::size_f>(const std::string& str) {
160 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
161 return {xtd::parse<float>(values[0]), xtd::parse<float>(values[1])};
162 }
164}
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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition parse.hpp:190
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35
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
static const xtd::drawing::size_f empty
Gets a Size class that has a Height and Width value of 0. This field is constant.
Definition size_f.hpp:36
size_f() noexcept=default
Initializes a new instance of the Size class that has a Height and Width value of 0.
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31