vfs: check userland buffers before reading them.
[haiku.git] / src / servers / app / IntPoint.h
blob6ec0c334f291ac12bb97bfa6724ef7e7ae1bfb17
1 /*
2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Frans van Nispen
7 * Stephan Aßmus <superstippi@gmx.de>
8 */
10 #ifndef INT_POINT_H
11 #define INT_POINT_H
13 #include <Point.h>
15 class IntRect;
17 class IntPoint {
18 public:
19 int32 x;
20 int32 y;
22 IntPoint();
23 IntPoint(int32 X, int32 Y);
24 IntPoint(const IntPoint& p);
25 IntPoint(const BPoint& p);
27 IntPoint& operator=(const IntPoint& p);
28 void Set(int32 x, int32 y);
30 void ConstrainTo(const IntRect& r);
31 void PrintToStream() const;
33 IntPoint operator+(const IntPoint& p) const;
34 IntPoint operator-(const IntPoint& p) const;
35 IntPoint& operator+=(const IntPoint& p);
36 IntPoint& operator-=(const IntPoint& p);
38 bool operator!=(const IntPoint& p) const;
39 bool operator==(const IntPoint& p) const;
41 // conversion to BPoint
42 operator BPoint() const
43 { return BPoint((float)x, (float)y); }
47 inline
48 IntPoint::IntPoint()
49 : x(0),
50 y(0)
55 inline
56 IntPoint::IntPoint(int32 x, int32 y)
57 : x(x),
58 y(y)
63 inline
64 IntPoint::IntPoint(const IntPoint& p)
65 : x(p.x),
66 y(p.y)
71 inline
72 IntPoint::IntPoint(const BPoint& p)
73 : x((int32)p.x),
74 y((int32)p.y)
79 inline IntPoint&
80 IntPoint::operator=(const IntPoint& from)
82 x = from.x;
83 y = from.y;
84 return *this;
88 inline void
89 IntPoint::Set(int32 x, int32 y)
91 this->x = x;
92 this->y = y;
95 #endif // INT_POINT_H