sbuild  1.7.1
mntstream.h
1 /* Copyright © 2003-2013 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_MNTSTREAM_H
20 #define SBUILD_MNTSTREAM_H
21 
22 #include <sbuild/custom-error.h>
23 
24 #include <iostream>
25 #include <deque>
26 #include <string>
27 
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <mntent.h>
31 
32 namespace sbuild
33 {
34 
46  class mntstream
47  {
48  public:
51  {
54  };
55 
58 
65  struct mntentry
66  {
69  {};
70 
76  mntentry (const struct mntent& entry);
77 
79  std::string filesystem_name;
81  std::string directory;
83  std::string type;
85  std::string options;
89  int fsck_pass;
90  };
91 
97  mntstream(const std::string& file);
98 
100  virtual ~mntstream();
101 
112  void open(const std::string& file);
113 
121  void close();
122 
130  bool eof() const;
131 
139  bool bad() const;
140 
147  operator bool ();
148 
155  bool
156  operator ! ();
157 
158  friend mntstream&
159  operator >> (mntstream& stream,
160  mntentry& entry);
161 
162  private:
173  void read (int quantity=1);
174 
176  std::string file;
177 
179  FILE *mntfile;
180 
185  std::deque<mntentry> data;
186 
189 
192  };
193 
202  mntstream&
203  operator >> (mntstream& stream,
204  mntstream::mntentry& entry);
205 
206 }
207 
208 #endif /* SBUILD_MNTSTREAM_H */
209 
210 /*
211  * Local Variables:
212  * mode:C++
213  * End:
214  */