XcfInfo.hpp
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace iv
8 {
9 
10 class XcfInfo;
11 
12 //---------------------------------------------------------------
13 class XcfInfo_Resource : public SingularResource< XcfInfo >
14 {
15 public:
18  SingularResource< XcfInfo >( inst, path ),
19  cm( inst, this, "XcfInfo_Resource" )
20  {
21  this->cm.inherits( this->SingularResource< XcfInfo >::cm );
22  }
23 };
24 
25 //---------------------------------------------------------------
27 {
28 public:
30  XcfInfo_Subprovider( Instance * inst, StreamResourceProvider const * provider ) :
31  Plain_StreamResourceSubprovider( inst, provider, "xcf" ),
32  cm( inst, this, "XcfInfo_Subprovider" )
33  {
35  }
36 };
37 
38 //---------------------------------------------------------------
39 class XcfInfo : private StreamResource
40 {
41 public:
42  struct Layer
43  {
45 
46  float global_left;
47  float global_right;
48  float global_top;
50 
51  float local_left;
52  float local_right;
53  float local_top;
54  float local_bottom;
55 
56  Layer() : size(), global_left( 0 ), global_right( 0 ), global_top( 0 ), global_bottom( 0 ), local_left( 0 ), local_right( 0 ), local_top( 0 ), local_bottom( 0 ){}
57  };
58 
59 public:
62  XcfInfo( Instance * inst, StreamResourceProvider const * provider, XcfInfo_Subprovider const *, ResourcePath const & path );
63 
64  float2 size() const;
65  Layer const & layer( char const * name ) const;
66 
67 private:
68  void Parse( std::istream & in );
69 
70 private:
71  float2 _size;
72  std::unordered_map< std::string, Layer > _layers;
73 };
74 
75 }