00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <ppl-config.h>
00025
00026 #include "stdiobuf.defs.hh"
00027
00028 namespace Parma_Polyhedra_Library {
00029
00030 stdiobuf::int_type
00031 stdiobuf::uflow() {
00032 ungetc_buf = getc(fp);
00033 return ungetc_buf;
00034 }
00035
00036 stdiobuf::int_type
00037 stdiobuf::underflow() {
00038 int_type c = getc(fp);
00039 return ungetc(c, fp);
00040 }
00041
00042 std::streamsize
00043 stdiobuf::xsgetn(char_type* s, std::streamsize n) {
00044 std::streamsize r = fread(s, 1, n, fp);
00045 if (r > 0)
00046 ungetc_buf = traits_type::to_int_type(s[r - 1]);
00047 else
00048 ungetc_buf = traits_type::eof();
00049 return r;
00050 }
00051
00052 stdiobuf::int_type
00053 stdiobuf::pbackfail(int_type c) {
00054 const int_type eof = traits_type::eof();
00055 int_type u = traits_type::eq_int_type(c, eof) ? ungetc_buf : c;
00056 ungetc_buf = eof;
00057 return traits_type::eq_int_type(u, eof) ? eof : ungetc(u, fp);
00058 }
00059
00060 std::streamsize
00061 stdiobuf::xsputn(const char_type* s, std::streamsize n) {
00062 return fwrite(s, 1, n, fp);
00063 }
00064
00065 stdiobuf::int_type
00066 stdiobuf::overflow(int_type c) {
00067 const int_type eof = traits_type::eof();
00068 if (traits_type::eq_int_type(c, eof))
00069 return fflush(fp) ? eof : traits_type::not_eof(c);
00070 else
00071 return putc(c, fp);
00072 }
00073
00074 int
00075 stdiobuf::sync() {
00076 return fflush(fp);
00077 }
00078
00079 }