xtd - Reference Guide 0.2.0
size_f.h
Go to the documentation of this file.
1 #pragma once
5 #include <ostream>
6 #include <xtd/object.h>
7 #include <xtd/ustring.h>
8 #include "../drawing_export.h"
9 
11 namespace xtd {
13  namespace drawing {
15  class point_f;
17 
29  class drawing_export_ size_f : public xtd::object {
30  public:
32 
37 
39 
42  size_f() noexcept = default;
43 
46  explicit size_f(const xtd::drawing::point_f& point) noexcept;
47 
51  size_f(float width, float height) noexcept;
53 
55  size_f(const xtd::drawing::size_f&) noexcept = default;
56  bool operator ==(const xtd::drawing::size_f& value) const noexcept;
57  bool operator !=(const xtd::drawing::size_f& value) const noexcept;
58  size_f& operator =(const xtd::drawing::size_f& size) noexcept = default;
59  size_f operator +(const xtd::drawing::size_f& size) const noexcept;
60  size_f operator -(const xtd::drawing::size_f& size) const noexcept;
61  size_f& operator +=(const xtd::drawing::size_f& size) noexcept;
62  size_f& operator -=(const xtd::drawing::size_f& size) noexcept;
64 
66 
71  float height() const noexcept;
72 
76  void height(float value) noexcept;
77 
80  bool is_empty() const noexcept;
81 
85  float width() const noexcept;
86 
90  void width(float value) noexcept;
92 
94 
100  static xtd::drawing::size_f add(const xtd::drawing::size_f& size1, const xtd::drawing::size_f& size2) noexcept;
101 
106  static xtd::drawing::size_f subtract(const xtd::drawing::size_f& sz1, const xtd::drawing::size_f& sz2) noexcept;
107 
110  xtd::ustring to_string() const noexcept override;
112 
113  private:
114  float width_ = 0;
115  float height_ = 0;
116  };
117  }
118 
120  template<>
121  inline drawing::size_f parse<drawing::size_f>(const std::string& str) {
122  auto values = xtd::ustring(str).replace("}", "").replace(" height=", "").replace("{width=", "").split({','});
123  return {xtd::parse<float>(values[0]), xtd::parse<float>(values[1])};
124  }
126 }
value_t parse(const std::string &str)
Convert a string into a type.
Definition: parse.h:22
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:53
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
ustring replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this string with another specified char_t...
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:51
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1100
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:34
Stores an ordered pair of floating-point, which specify a height and width.
Definition: size_f.h:29
std::vector< ustring > split(const std::vector< value_type > &separators, size_t count, string_split_options options) const noexcept
Splits this string into a maximum number of substrings based on the characters in an array...
Contains xtd::ustring class.
float parse< float >(const std::string &str, number_styles styles)
Convert a string into a type.
Definition: parse.h:175
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
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.h:35