xref: /386bsd/usr/include/nonstd/gnu/g++/PlotFile.h (revision a2142627)
1 // This may look like C code, but it is really -*- C++ -*-
2 /*
3 Copyright (C) 1988 Free Software Foundation
4     written by Doug Lea (dl@rocky.oswego.edu)
5 
6 This file is part of GNU CC.
7 
8 GNU CC is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY.  No author or distributor
10 accepts responsibility to anyone for the consequences of using it
11 or for whether it serves any particular purpose or works at all,
12 unless he says so in writing.  Refer to the GNU CC General Public
13 License for full details.
14 
15 Everyone is granted permission to copy, modify and redistribute
16 GNU CC, but only under the conditions described in the
17 GNU CC General Public License.   A copy of this license is
18 supposed to have been given to you along with GNU CC so you
19 can know your rights and responsibilities.  It should be in a
20 file named COPYING.  Among other things, the copyright notice
21 and this notice must be preserved on all copies.
22 */
23 
24 /*
25    a very simple implementation of a class to output unix "plot"
26    format plotter files. See corresponding unix man pages for
27    more details.
28 */
29 
30 #ifndef _PlotFile_h
31 #ifdef __GNUG__
32 #pragma once
33 #pragma interface
34 #endif
35 #define _PlotFile_h
36 
37 #include <File.h>
38 
39 /*
40    Some plot libraries have the `box' command to draw boxes. Some don't.
41    `box' is included here via moves & lines to allow both possiblilties.
42 */
43 
44 
45 class PlotFile : private File
46 {
47 protected:
48   PlotFile& cmd(char c);
49   PlotFile& operator << (const int x);
50   PlotFile& operator << (const char *s);
51 
52 public:
53 
54   PlotFile();
55   PlotFile(const char* filename, io_mode m, access_mode a);
56   PlotFile(const char* filename, const char* m);
57   PlotFile(int filedesc, const io_mode m = io_writeonly);
58   PlotFile(FILE* fileptr);
59 
60   ~PlotFile();
61 
62   operator void*();
63 
close()64   PlotFile& close() { File::close(); return *this; }
remove()65   PlotFile& remove() { File::remove(); return *this; }
66 
filedesc()67   int           filedesc() { return File::filedesc(); }
name()68   const char*   name() { return File::name(); }
setname(const char * newname)69   void          setname(const char* newname) { File::setname(newname); }
iocount()70   int           iocount() { return File::iocount(); }
71 
rdstate()72   int           rdstate() { return File::rdstate(); }
eof()73   int           eof() { return File::eof(); }
fail()74   int           fail() { return File::fail(); }
bad()75   int           bad() { return File::bad(); }
good()76   int           good() { return File::good(); }
77 
78   // other status queries
79 
readable()80   int           readable() { return File::readable(); }
writable()81   int           writable() { return File::writable(); }
is_open()82   int           is_open() { return File::is_open(); }
83 
error()84   void          error() {  File::error(); }
85   void          clear(state_value f = _good) {  File::clear(f); }
set(state_value f)86   void          set(state_value f) { File::set(f); }
unset(state_value f)87   void          unset(state_value f) { File::unset(f); }
failif(int cond)88   PlotFile&     failif(int cond) {  File::failif(cond); return *this; }
check_state()89   void          check_state() { File::check_state(); }
90 
raw()91   PlotFile&     raw() { File::raw(); return *this; }
92 
93   PlotFile& open(const char* filename, io_mode m, access_mode a);
94   PlotFile& open(const char* filename, const char* m);
95   PlotFile& open(int  filedesc,  io_mode m);
96   PlotFile& open(FILE* fileptr);
97   PlotFile& setbuf(const int buffer_kind); // vals: _IONBF, _IOFBF, _IOLBF
98   PlotFile& setbuf(const int size, char* buf);
99 
100   PlotFile& arc(const int xi, const int yi,
101                 const int x0, const int y0,
102                 const int x1, const int y1);
103   PlotFile& box(const int x0, const int y0,
104                 const int x1, const int y1);
105   PlotFile& circle(const int x, const int y, const int r);
106   PlotFile& cont(const int xi, const int yi);
107   PlotFile& dot(const int xi, const int yi, const int dx,
108                 int n, const int* pat);
109   PlotFile& erase();
110   PlotFile& label(const char* s);
111   PlotFile& line(const int x0, const int y0,
112                  const int x1, const int y1);
113   PlotFile& linemod(const char* s);
114   PlotFile& move(const int xi, const int yi);
115   PlotFile& point(const int xi, const int yi);
116   PlotFile& space(const int x0, const int y0,
117                   const int x1, const int y1);
118 };
119 
120 
121 #endif
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155