xtd 1.0.0
Loading...
Searching...
No Matches
size.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "size_f.hpp"
7#include <xtd/icomparable>
8#include <xtd/iequatable>
9#include <xtd/object>
10#include <xtd/string>
11#include <ostream>
12
14namespace xtd {
16 namespace drawing {
18 struct point;
20
34
39
41
44 size() = default;
47 explicit size(const xtd::drawing::point& point) noexcept;
53
55 operator xtd::drawing::size_f() const noexcept;
57
59
65
70
73 [[nodiscard]] auto is_empty() const noexcept -> bool;
75
77
89 [[nodiscard]] auto compare_to(const xtd::drawing::size& obj) const noexcept -> xtd::int32 override;
93 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
97 [[nodiscard]] auto equals(const xtd::drawing::size& other) const noexcept -> bool override;
98
101 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
102
105 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
107
109
115 [[nodiscard]] static auto add(const size& size1, const size& size2) noexcept -> size;
116
120 [[nodiscard]] static auto ceiling(const xtd::drawing::size_f& value) noexcept -> size;
121
125 [[nodiscard]] static auto round(const xtd::drawing::size_f& value) noexcept -> size;
126
131 [[nodiscard]] static auto subtract(const size& sz1, const size& sz2) noexcept -> size;
132
136 [[nodiscard]] static auto truncate(const xtd::drawing::size_f& value) noexcept -> size;
138
140
145 auto operator +(const size& size) const noexcept -> xtd::drawing::size;
146
150 auto operator +=(const size& size) noexcept -> xtd::drawing::size&;
151
155 auto operator -(const size& size) const noexcept -> xtd::drawing::size;
156
160 auto operator -=(const size& size) noexcept -> xtd::drawing::size&;
162 };
163 }
164
166 template<>
167 inline auto parse<xtd::drawing::size>(const std::string& str) -> xtd::drawing::size {
168 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
169 return {xtd::parse<xtd::int32>(values[0]), xtd::parse<xtd::int32>(values[1])};
170 }
172}
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
auto parse< xtd::int32 >(const std::string &str, number_styles styles) -> xtd::int32
Convert a string into a type.
Definition parse.hpp:136
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
Contains xtd::drawing::size_f struct.
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:32
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:32
size(const xtd::drawing::point &point) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified xtd::drawing::point cla...
static auto ceiling(const xtd::drawing::size_f &value) noexcept -> size
Converts the specified xtd::drawing::size_f to a xtd::drawing::size by rounding the values of the xtd...
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto compare_to(const xtd::drawing::size &obj) const noexcept -> xtd::int32 override
Compares the current instance with another object of the same type.
auto to_string() const noexcept -> xtd::string override
Creates a human-readable string that represents this xtd::drawing::size class.
size()=default
Initializes a new instance of the xtd::drawing::size class that has a Height and Width value of 0.
auto equals(const xtd::object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
xtd::int32 height
Gets or sets he vertical component of this xtd::drawing::size class.
Definition size.hpp:69
size(xtd::int32 width, xtd::int32 height) noexcept
Initializes a new instance of the xtd::drawing::size class from the specified dimensions.
auto is_empty() const noexcept -> bool
Tests whether this xtd::drawing::size class has xtd::drawing::size_fwidth and xtd::drawing::size_fhei...
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:37
static auto add(const size &size1, const size &size2) noexcept -> size
Adds the width and height of one xtd::drawing::size class to the width and height of another size cla...
xtd::int32 width
Gets or sets the horizontal component of this xtd::drawing::size class.
Definition size.hpp:64
static auto truncate(const xtd::drawing::size_f &value) noexcept -> size
Converts the specified xtd::drawing::size_f to a xtd::drawing::size by truncating the values of the x...
static auto subtract(const size &sz1, const size &sz2) noexcept -> size
Returns the result of subtracting specified xtd::drawing::size from the specified xtd::drawing::size.
static auto round(const xtd::drawing::size_f &value) noexcept -> size
Converts the specified xtd::drawing::size_f to a xtd::drawing::size object by rounding the xtd::drawi...