File: afx.h

package info (click to toggle)
courier 0.60.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 52,288 kB
  • ctags: 12,677
  • sloc: ansic: 165,348; cpp: 24,820; sh: 16,410; perl: 6,839; makefile: 3,621; yacc: 289; sed: 16
file content (87 lines) | stat: -rw-r--r-- 1,937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef	afx_h
#define	afx_h

/*
** Copyright 1998 - 2007 Double Precision, Inc.
** See COPYING for distribution information.
*/

#include	"afx/config.h"

#if	HAVE_UNISTD_H
#include	<unistd.h>
#endif

#include	<iostream>
#include	<istream>
#include	<ostream>

static const char afx_h_rcs_id[]="$Id: afx.h,v 2.4 2007/07/30 00:25:53 mrsam Exp $";

/////////////////////////////////////////////////////////////////////
//
// Some wanker in ISO got rid of ifstream(int), ofstream(int), and
// fstream(int).  Twit.

class afxpipestreambuf : public std::streambuf {
	int fd;
	char buffer[8192];

 public:

	std::ios *iosp;

	afxpipestreambuf(int);
	~afxpipestreambuf();
	void close();
	void seekg(std::streampos);
	void seekp(std::streampos);
	int handle() { return (fd); }
	void handle(int f);
	int sync();
 protected:
	int overflow(int);
	int underflow();
} ;

class afxipipestream : public std::istream {
	afxpipestreambuf fd_;
 public:
	afxipipestream(int = -1);
	~afxipipestream();

	void close() { fd_.close(); }
	void seekg(std::streampos p) { fd_.seekg(p); }
	void seekp(std::streampos p) { fd_.seekp(p); }
	int fd() { return (fd_.handle()); }
	void fd(int f) { fd_.handle(f); }
	void sync() { fd_.sync(); }
} ;

class afxopipestream: public std::ostream {
	afxpipestreambuf fd_;
 public:
	afxopipestream(int = -1);
	~afxopipestream();
	void close() { fd_.close(); }
	void seekg(std::streampos p) { fd_.seekg(p); }
	void seekp(std::streampos p) { fd_.seekp(p); }
	int fd() { return (fd_.handle()); }
	void fd(int f) { fd_.handle(f); }
	void sync() { fd_.sync(); }
} ;

class afxiopipestream: public std::iostream {
	afxpipestreambuf fd_;
 public:
	afxiopipestream(int = -1);
	~afxiopipestream();
	void close() { fd_.close(); }
	void seekg(std::streampos p) { fd_.seekg(p); }
	void seekp(std::streampos p) { fd_.seekp(p); }
	int fd() { return (fd_.handle()); }
	void fd(int f) { fd_.handle(f); }
	void sync() { fd_.sync(); }
} ;

#endif