Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
IOBase.h
1 //
2 // Created by Lectem on 12/11/2016.
3 //
4 
5 #pragma once
6 
7 #include <string>
8 
9 namespace WorldStone
10 {
16 class IOBase
17 {
18 public:
19  using Path = std::string;
20  using iostate = int;
21 
22 protected:
23  static constexpr iostate goodbit = 0x0;
24  static constexpr iostate eofbit = 0x1;
25  static constexpr iostate failbit = 0x2;
26  static constexpr iostate badbit = 0x4;
27  iostate _state = goodbit;
28 
29  void setstate(iostate state) { _state = _state | state; }
30 
31 public:
32  explicit operator bool() const { return !fail(); }
33  bool operator!() const { return fail(); }
34 
35  bool good() const { return _state == goodbit; }
36  bool eof() const { return _state & eofbit; }
37  bool fail() const { return (_state & (badbit | failbit)) != 0; }
38  bool bad() const { return (_state & badbit) != 0; }
39 };
40 }
This class reuses the parts of std::ios API but doesn't provide heavy stream functionnality (ie...
Definition: IOBase.h:16