replaced separate inbuf and outbuf with iobuf
This commit is contained in:
parent
db6b0cca5e
commit
e9fa798ee7
@ -1,5 +1,5 @@
|
||||
//
|
||||
// fdostream.cpp
|
||||
// fdiobuf.cpp
|
||||
// libscio
|
||||
//
|
||||
// Created by Bob Polis at 2020-02-14
|
||||
@ -14,7 +14,20 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
std::streambuf::int_type sc::io::fdoutbuf::overflow(std::streambuf::int_type c) {
|
||||
std::streambuf::int_type sc::io::fdiobuf::underflow() {
|
||||
int num = ::read(_fd, &_ch, 1);
|
||||
if (num <= 0) {
|
||||
return EOF;
|
||||
}
|
||||
setg(&_ch, &_ch, &_ch + 1);
|
||||
return _ch;
|
||||
}
|
||||
|
||||
std::streamsize sc::io::fdiobuf::xsgetn(char* s, std::streamsize n) {
|
||||
return ::read(_fd, s, n);
|
||||
}
|
||||
|
||||
std::streambuf::int_type sc::io::fdiobuf::overflow(std::streambuf::int_type c) {
|
||||
if (c != EOF) {
|
||||
int res;
|
||||
if ((res = ::write(_fd, &c, 1)) != 1) {
|
||||
@ -27,7 +40,7 @@ std::streambuf::int_type sc::io::fdoutbuf::overflow(std::streambuf::int_type c)
|
||||
return c;
|
||||
}
|
||||
|
||||
std::streamsize sc::io::fdoutbuf::xsputn(const char* s, std::streamsize num) {
|
||||
std::streamsize sc::io::fdiobuf::xsputn(const char* s, std::streamsize num) {
|
||||
int res = ::write(_fd, s, num);
|
||||
if (res != num) {
|
||||
std::cerr << "write result = " << res << ", errno = " << errno << '\n';
|
@ -1,30 +0,0 @@
|
||||
//
|
||||
// fdistream.cpp
|
||||
// libscio
|
||||
//
|
||||
// Created by Bob Polis at 2020-02-14
|
||||
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
||||
//
|
||||
|
||||
#include "libscio.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using namespace sc::io;
|
||||
|
||||
std::streambuf::int_type fdinbuf::underflow() {
|
||||
int num = read(_fd, &_ch, 1);
|
||||
if (num <= 0) {
|
||||
return EOF;
|
||||
}
|
||||
setg(&_ch, &_ch, &_ch + 1);
|
||||
return _ch;
|
||||
}
|
||||
|
||||
std::streamsize fdinbuf::xsgetn(char* s, std::streamsize n) {
|
||||
return read(_fd, s, n);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user