xtd 0.2.0
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 size(const xtd::drawing::size&) noexcept = default;
56 size& operator =(const xtd::drawing::size& size) noexcept = default;
57 operator size_f() const noexcept;
59
61
67
72
75 bool is_empty() const noexcept;
77
79
91 int32 compare_to(const xtd::drawing::size& obj) const noexcept override;
95 bool equals(const xtd::object& obj) const noexcept override;
99 bool equals(const xtd::drawing::size& other) const noexcept override;
100
103 xtd::size get_hash_code() const noexcept override;
104
107 xtd::string to_string() const noexcept override;
109
111
117 static size add(const size& size1, const size& size2) noexcept;
118
122 static size ceiling(const size_f& value) noexcept;
123
127 static size round(const size_f& value) noexcept;
128
133 static xtd::drawing::size subtract(const xtd::drawing::size& sz1, const xtd::drawing::size& sz2) noexcept;
134
138 static size truncate(const size_f& value) noexcept;
140
142
147 size operator +(const xtd::drawing::size& size) const noexcept;
148
152 size& operator +=(const xtd::drawing::size& size) noexcept;
153
157 size operator -(const xtd::drawing::size& size) const noexcept;
158
162 size& operator -=(const xtd::drawing::size& size) noexcept;
164 };
165 }
166
168 template<>
169 inline drawing::size parse<drawing::size>(const std::string& str) {
170 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" height=", xtd::string::empty_string).replace("{width=", xtd::string::empty_string).split(',');
171 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
172 }
174}
basic_string replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.hpp:1607
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
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
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
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
@ other
The operating system is other.
Definition platform_id.hpp:58
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 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: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...
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 xtd::drawing::size subtract(const xtd::drawing::size &sz1, const xtd::drawing::size &sz2) noexcept
Returns the result of subtracting specified xtd::drawing::size from the specified xtd::drawing::size.
static size ceiling(const size_f &value) noexcept
Converts the specified xtd::drawing::size_f to a xtd::drawing::size by rounding the values of the xtd...
int32 height
Gets or sets he vertical component of this xtd::drawing::size class.
Definition size.hpp:71
static size round(const size_f &value) noexcept
Converts the specified xtd::drawing::size_f to a xtd::drawing::size object by rounding the xtd::drawi...
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
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool is_empty() const noexcept
Tests whether this xtd::drawing::size class has xtd::drawing::size_fwidth and xtd::drawing::size_fhei...
bool equals(const xtd::object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
int32 compare_to(const xtd::drawing::size &obj) const noexcept override
Compares the current instance with another object of the same type.
xtd::string to_string() const noexcept override
Creates a human-readable string that represents this xtd::drawing::size class.
static size add(const size &size1, const size &size2) noexcept
Adds the width and height of one xtd::drawing::size class to the width and height of another size cla...
static size truncate(const size_f &value) noexcept
Converts the specified xtd::drawing::size_f to a xtd::drawing::size by truncating the values of the x...
int32 width
Gets or sets the horizontal component of this xtd::drawing::size class.
Definition size.hpp:66