c_ios.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: c_ios.h /main/4 1996/08/21 15:54:50 drk $ */
  24. #ifndef _ios_h
  25. #define _ios_h
  26. #include <sys/types.h>
  27. #include "utility/macro.h"
  28. #include "utility/c_streambuf.h"
  29. class ios
  30. {
  31. protected:
  32. streambuf* sbuf; // buffer that provides char sequence read/write
  33. int f_state;
  34. public:
  35. enum open_mode { in=1, out=2, app=4, trunc=8 };
  36. enum seek_dir { beg=0, cur=1, end=2 } ;
  37. enum states { OK=0, BAD=1, FAIL=2 } ;
  38. ios(streambuf* sb = 0);
  39. virtual ~ios();
  40. int rdstate() { return f_state; };
  41. int fail() ;
  42. int bad() ;
  43. int good() {
  44. return !(fail() || bad()) ;
  45. };
  46. void set_bad() { f_state |= BAD;};
  47. void set_fail() { f_state |= FAIL;};
  48. void clear() { f_state = OK; };
  49. int operator!() { return fail(); };
  50. operator void*() { return (void*)(size_t)good(); };
  51. };
  52. #endif