xtd 1.0.0
Loading...
Searching...
No Matches
size_f.hpp
Go to the documentation of this file.
1
4#pragma once
6#include <xtd/icomparable>
7#include <xtd/iequatable>
8#include <xtd/object>
9#include <xtd/string>
10#include <ostream>
11
13namespace xtd {
15 namespace drawing {
17 struct point_f;
18 struct size;
20
34
37 static const size_f empty;
39
41
44 size_f() noexcept = default;
45
48 explicit size_f(const xtd::drawing::point_f& point) noexcept;
49
53 size_f(float width, float height) noexcept;
55
57
62 float width = .0f;
63
67 float height = .0f;
68
71 [[nodiscard]] auto is_empty() const noexcept -> bool;
73
75
86 [[nodiscard]] auto compare_to(const size_f& obj) const noexcept -> xtd::int32 override;
91 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
95 [[nodiscard]] auto equals(const size_f& other) const noexcept -> bool override;
96
99 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
100
103 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
105
107
113 [[nodiscard]] static auto add(const size_f& size1, const size_f& size2) noexcept -> size_f;
114
119 [[nodiscard]] static auto subtract(const size_f& sz1, const size_f& sz2) noexcept -> size_f;
121
123
128 auto operator +(const xtd::drawing::size_f& size) const noexcept -> size_f;
132 auto operator +(const xtd::drawing::size& size) const noexcept -> size_f;
133
137 auto operator +=(const xtd::drawing::size_f& size) noexcept -> size_f&;
141 auto operator +=(const xtd::drawing::size& size) noexcept -> size_f&;
142
146 auto operator -(const xtd::drawing::size_f& size) const noexcept -> size_f;
150 auto operator -(const xtd::drawing::size& size) const noexcept -> size_f;
151
155 auto operator -=(const xtd::drawing::size_f& size) noexcept -> size_f&;
159 auto operator -=(const xtd::drawing::size& size) noexcept -> size_f&;
161 };
162 }
163
165 template<>
166 [[nodiscard]] inline auto parse<xtd::drawing::size_f>(const std::string& str) -> xtd::drawing::size_f {
167 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
168 return {xtd::parse<float>(values[0]), xtd::parse<float>(values[1])};
169 }
171}
static const basic_string empty_string
Definition basic_string.hpp:111
auto replace(value_type old_char, value_type new_char) const noexcept -> basic_string
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.hpp:711
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains drawing_export_ keyword.
#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
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto parse(const std::string &str) -> value_t
Convert a string into a type.
Definition parse.hpp:34
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
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
static const size_f empty
Gets a Size class that has a Height and Width value of 0. This field is constant.
Definition size_f.hpp:37
auto to_string() const noexcept -> xtd::string override
Creates a human-readable string that represents this xtd::drawing::size_f class.
size_f() noexcept=default
Initializes a new instance of the Size class that has a Height and Width value of 0.
float height
Gets or sets he vertical component of this xtd::drawing::size_f class.
Definition size_f.hpp:67
static auto add(const size_f &size1, const size_f &size2) noexcept -> size_f
Adds the width and height of one xtd::drawing::size_f class to the width and height of another xtd::d...
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
float width
Gets or sets the horizontal component of this xtd::drawing::size_f class.
Definition size_f.hpp:62
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto is_empty() const noexcept -> bool
Tests whether this Size class has xtd::drawing::size_f::width and xtd::drawing::size_f::height of 0.
auto compare_to(const size_f &obj) const noexcept -> xtd::int32 override
Compares the current instance with another object of the same type.
static auto subtract(const size_f &sz1, const size_f &sz2) noexcept -> size_f
Returns the result of subtracting specified xtd::drawing::size_f from the specified xtd::drawing::siz...
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:32