1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/utils/streams.hpp

47 lines
744 B
C++
Raw Normal View History

#if 0
#pragma once
2016-05-19 10:41:06 -04:00
#include <iostream>
#include <streambuf>
#include <cstdio>
#include <unistd.h>
namespace streams
{
class fdoutbuf : public std::streambuf
{
protected:
int fd;
virtual int_type overflow(int_type c)
{
if (c != EOF) {
char z = c;
if (write (fd, &z, 1) != 1)
return EOF;
}
return c;
}
virtual std::streamsize xsputn(const char* s, std::streamsize num) {
return write(fd,s,num);
}
public:
fdoutbuf(int _fd) : fd(_fd) {}
};
class fdout : public std::ostream
{
protected:
fdoutbuf buf;
public:
fdout(int fd) : std::ostream(0), buf(fd) {
rdbuf(&buf);
}
};
}
#endif