xtd 0.2.0
point.h
Go to the documentation of this file.
1 #pragma once
5 #include "../drawing_export.h"
6 #include "point_f.h"
7 #include <xtd/iequatable>
8 #include <xtd/object>
9 #include <xtd/ustring>
10 #include <cstdint>
11 #include <ostream>
12 
14 namespace xtd {
16  namespace drawing {
18  class size;
20 
54  class drawing_export_ point : public xtd::object, public xtd::iequatable<point> {
55  public:
57 
60  static const point empty;
62 
64 
68  point() noexcept = default;
69 
92  explicit point(int32 dw) noexcept;
93 
116  point(int32 x, int32 y) noexcept;
117 
139  explicit point(const size& sz) noexcept;
141 
143  point(const point&) noexcept = default;
144  point& operator =(const point&) noexcept = default;
145  operator point_f() const noexcept;
147 
149 
153  bool is_empty() const noexcept;
154 
176  int32 x() const noexcept;
177 
199  void x(int32 x) noexcept;
200 
222  int32 y() const noexcept;
223 
245  void y(int32 y) noexcept;
247 
249 
265  static point add(const point& pt, const size& sz) noexcept;
270  static point add(const point& pt1, const point& pt2) noexcept;
271 
275  static point ceiling(const point_f& value) noexcept;
276 
277  bool equals(const point& value) const noexcept override;
278 
282  void offset(int32 dx, int32 dy) noexcept;
283 
297  void offset(const point& p) noexcept;
298 
302  static point round(const point_f& value) noexcept;
303 
309  static point subtract(const point& pt, const size& sz) noexcept;
314  static point subtract(const point& pt1, const point& pt2) noexcept;
315 
318  xtd::ustring to_string() const noexcept override;
319 
323  static point truncate(const point_f& value) noexcept;
325 
327 
332  point operator +(const size& sz) const noexcept;
336  point operator +(const point& pt) const noexcept;
337 
341  point& operator +=(const size& sz) noexcept;
345  point& operator +=(const point& pt) noexcept;
346 
350  point operator -(const size& sz) const noexcept;
354  point operator -(const point& pt) const noexcept;
355 
359  point& operator -=(const size& sz) noexcept;
363  point& operator -=(const point& pt) noexcept;
365 
366  private:
367  int32 x_ = 0;
368  int32 y_ = 0;
369  };
370  }
371 
372  template<>
373  inline drawing::point parse<drawing::point>(const std::string& str) {
374  auto values = xtd::ustring(str).replace("}", "").replace(" y=", "").replace("{x=", "").split({','});
375  return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
376  }
377 }
static const point empty
Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values se...
Definition: point.h:60
value_t parse(const std::string &str)
Convert a string into a type.
Definition: parse.h:23
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
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...
Contains xtd::drawing::point_f class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
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:1063
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:35
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
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...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Specifies a printer&#39;s point (1/72 inch) as the unit of measure.
size_t size
Represents a size of any object in bytes.
Definition: types.h:195