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