xtd - Reference Guide 0.2.0
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 #include "size_f.h"
12 namespace xtd {
14  namespace drawing {
16  class point;
30  class drawing_export_ size : public xtd::object {
31  public:
36  static const xtd::drawing::size empty;
43  size() = default;
46  explicit size(const xtd::drawing::point& point) noexcept;
50  size(int32_t width, int32_t height) noexcept;
54  size(const xtd::drawing::size&) noexcept = default;
55  bool operator ==(const xtd::drawing::size& value) const noexcept;
56  bool operator !=(const xtd::drawing::size& value) const noexcept;
57  size& operator =(const xtd::drawing::size& size) noexcept = default;
58  size operator +(const xtd::drawing::size& size) const noexcept;
59  size operator -(const xtd::drawing::size& size) const noexcept;
60  size& operator +=(const xtd::drawing::size& size) noexcept;
61  size& operator -=(const xtd::drawing::size& size) noexcept;
62  operator size_f() const noexcept;
71  int32_t height() const noexcept;
75  void height(int32_t value) noexcept;
79  bool is_empty() const noexcept;
84  int32_t width() const noexcept;
88  void width(int32_t value) noexcept;
98  static size add(const size& size1, const size& size2) noexcept;
103  static size ceiling(const size_f& value) noexcept;
108  static size round(const size_f& value) noexcept;
114  static xtd::drawing::size subtract(const xtd::drawing::size& sz1, const xtd::drawing::size& sz2) noexcept;
118  xtd::ustring to_string() const noexcept override;
123  static size truncate(const size_f& value) noexcept;
126  private:
127  int32_t width_ = 0;
128  int32_t height_ = 0;
129  };
130  }
133  template<>
134  inline drawing::size parse<drawing::size>(const std::string& str) {
135  auto values = xtd::ustring(str).replace("}", "").replace(" height=", "").replace("{width=", "").split({','});
136  return {xtd::parse<int32_t>(values[0]), xtd::parse<int32_t>(values[1])};
137  }
139 }
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
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.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
Contains xtd::drawing::size_f class.
Specifies a printer&#39;s point (1/72 inch) as the unit of measure.
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.h:36