1 // Aseprite Gfx Library
2 // Copyright (C) 2001-2016 David Capello
3 //
4 // This file is released under the terms of the MIT license.
5 // Read LICENSE.txt for more information.
6 
7 #ifndef GFX_RECT_IO_H_INCLUDED
8 #define GFX_RECT_IO_H_INCLUDED
9 #pragma once
10 
11 #include "gfx/rect.h"
12 #include <iosfwd>
13 
14 namespace gfx {
15 
16   inline std::ostream& operator<<(std::ostream& os, const Rect& rect) {
17     return os << "("
18               << rect.x << ", "
19               << rect.y << ", "
20               << rect.w << ", "
21               << rect.h << ")";
22   }
23 
24   inline std::istream& operator>>(std::istream& in, Rect& rect) {
25     while (in && in.get() != '(')
26       ;
27 
28     if (!in)
29       return in;
30 
31     char chr;
32     in >> rect.x >> chr
33        >> rect.y >> chr
34        >> rect.w >> chr
35        >> rect.h >> chr;
36 
37     return in;
38   }
39 
40 }
41 
42 #endif
43