Quantum Fog  0.9.3
MY_FSTREAMS.h
1 #pragma once
2 #include <iostream.h>
3 #include <iomanip.h>
4 #include <fstream.h>
5 
6 class END_OF_FILE {};
7 
8 #define seekg_(offset, base) rdbuf()->pubseekpos(offset, base)
9 //#define tellg_() rdbuf()->pubseekoff(0, ios::cur, ios::in).offset()
10 #define tellg_() rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in)
11 
12 
13 //******************************************
14 class MY_IFSTREAM : public IFSTREAM
15 {
16 public:
17  MY_IFSTREAM();
18  MY_IFSTREAM(const CHAR * name);
19  virtual ~MY_IFSTREAM();
20 
21  USHORT cur_line();
22  VOID my_get(CHAR & ch);
23  VOID my_get_line(
24  CHAR * ch_p,
25  USHORT max_len,
26  CHAR last_ch);
27 
28 #ifdef _mac_gui_app //''''''''''''''''''''''''''''''''''''''''''''\\.
29 
30  VOID mac_open(const FSSpec & fs_spec, openmode mode = in);
31 #endif //_mac_gui_app \\............................................//
32 
33 };
34 //******************************************
35 class MY_OFSTREAM : public ofstream
36 {
37 public:
38  MY_OFSTREAM();
39  MY_OFSTREAM(const CHAR * name);
40  virtual ~MY_OFSTREAM();
41 
42 #ifdef _mac_gui_app //''''''''''''''''''''''''''''''''''''''''''''\\.
43 
44  VOID mac_open(const FSSpec & fs_spec, openmode mode = out|trunc);
45 #endif //_mac_gui_app \\............................................//
46 
47 };
48 
49 /*
50 The new ANSI C++ standard is very strict with its file opening modes.
51  Only certain combinations are allowed.
52 
53 In the draft C++ standard for the Library, the following are defined (para
54 17.4.8.1.4) as valid combinations of ios::openmode for opening a
55 file---these are defined in terms of the equivalent modestr used in
56 fopen(s, modestr) (see para 7.9.5.3 of ANSI standard for C):
57  ios::in modestr = "r"
58  ios::out | ios::trunc modestr = "w"
59  ios::out | ios::app modestr = "a"
60  ios::in | ios::binary modestr = "rb"
61  ios::out | ios::trunc | ios::binary modestr = "wb"
62  ios::out | ios::app | ios::binary modestr = "ab"
63  ios::in | ios::out modestr = "r+"
64  ios::in | ios::out | ios::trunc modestr = "w+"
65  ios::in | ios::out | ios::app modestr = "a+"
66  ios::in | ios::out | ios::binary modestr = "r+b"
67  ios::in | ios::out | ios::trunc | ios::binary modestr = "w+b"
68  ios::in | ios::out | ios::app | ios::binary modestr = "a+b"
69 All other combinations are invalid and no file is opened and no error
70 message is produced.
71 
72 With the ANSI Draft Version used by Metrowerks, you can use
73 is_open() to check that the file has been opened properly, as in
74 
75  OutStream(outfile, ios::out | ios::trunc);
76 if( !OutStream.is_open() ) { cerr << "file failed to open"; exit(1); }
77 
78 */
Definition: MY_FSTREAMS.h:35
Definition: MY_FSTREAMS.h:6
Definition: MY_FSTREAMS.h:14