2117
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2117
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2117
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_octave_stream_h) |
|
25 #define octave_octave_stream_h 1 |
|
26 |
2877
|
27 class Matrix; |
|
28 class string_vector; |
|
29 class octave_value; |
|
30 class octave_value_list; |
2117
|
31 |
3503
|
32 #include <iostream> |
5765
|
33 #include <sstream> |
2877
|
34 #include <string> |
6757
|
35 #include <map> |
2117
|
36 |
|
37 #include "Array.h" |
2317
|
38 #include "data-conv.h" |
3640
|
39 #include "lo-utils.h" |
2317
|
40 #include "mach-info.h" |
2117
|
41 |
3640
|
42 class |
6109
|
43 OCTINTERP_API |
2117
|
44 scanf_format_elt |
|
45 { |
3640
|
46 public: |
|
47 |
3483
|
48 enum special_conversion |
|
49 { |
|
50 whitespace_conversion = 1, |
|
51 literal_conversion = 2 |
|
52 }; |
|
53 |
2215
|
54 scanf_format_elt (const char *txt = 0, int w = 0, bool d = false, |
3483
|
55 char typ = '\0', char mod = '\0', |
3523
|
56 const std::string& ch_class = std::string ()) |
3640
|
57 : text (strsave (txt)), width (w), discard (d), type (typ), |
|
58 modifier (mod), char_class (ch_class) { } |
|
59 |
|
60 scanf_format_elt (const scanf_format_elt& e) |
|
61 : text (strsave (e.text)), width (e.width), discard (e.discard), |
|
62 type (e.type), modifier (e.modifier), char_class (e.char_class) { } |
2117
|
63 |
3640
|
64 scanf_format_elt& operator = (const scanf_format_elt& e) |
|
65 { |
|
66 if (this != &e) |
|
67 { |
|
68 text = strsave (e.text); |
|
69 width = e.width; |
|
70 discard = e.discard; |
|
71 type = e.type; |
|
72 modifier = e.modifier; |
|
73 char_class = e.char_class; |
|
74 } |
2117
|
75 |
3640
|
76 return *this; |
|
77 } |
|
78 |
|
79 ~scanf_format_elt (void) { delete [] text; } |
|
80 |
|
81 // The C-style format string. |
2117
|
82 const char *text; |
3640
|
83 |
|
84 // The maximum field width. |
2215
|
85 int width; |
3640
|
86 |
|
87 // TRUE if we are not storing the result of this conversion. |
2117
|
88 bool discard; |
3640
|
89 |
|
90 // Type of conversion -- `d', `i', `o', `u', `x', `e', `f', `g', |
|
91 // `c', `s', `p', `%', or `['. |
2117
|
92 char type; |
3640
|
93 |
|
94 // A length modifier -- `h', `l', or `L'. |
2117
|
95 char modifier; |
3640
|
96 |
|
97 // The class of characters in a `[' format. |
3523
|
98 std::string char_class; |
2117
|
99 }; |
|
100 |
|
101 class |
6109
|
102 OCTINTERP_API |
2117
|
103 scanf_format_list |
|
104 { |
|
105 public: |
|
106 |
3523
|
107 scanf_format_list (const std::string& fmt = std::string ()); |
2117
|
108 |
|
109 ~scanf_format_list (void); |
|
110 |
|
111 int num_conversions (void) { return nconv; } |
|
112 |
2215
|
113 // The length can be different than the number of conversions. |
|
114 // For example, "x %d y %d z" has 2 conversions but the length of |
|
115 // the list is 3 because of the characters that appear after the |
|
116 // last conversion. |
|
117 |
|
118 int length (void) { return list.length (); } |
|
119 |
2117
|
120 const scanf_format_elt *first (void) |
|
121 { |
|
122 curr_idx = 0; |
|
123 return current (); |
|
124 } |
|
125 |
|
126 const scanf_format_elt *current (void) const |
|
127 { return list.length () > 0 ? list.elem (curr_idx) : 0; } |
|
128 |
3640
|
129 const scanf_format_elt *next (bool cycle = true) |
2117
|
130 { |
|
131 curr_idx++; |
3640
|
132 |
2117
|
133 if (curr_idx >= list.length ()) |
3640
|
134 { |
|
135 if (cycle) |
|
136 curr_idx = 0; |
|
137 else |
|
138 return 0; |
|
139 } |
2117
|
140 return current (); |
|
141 } |
|
142 |
|
143 void printme (void) const; |
|
144 |
|
145 bool ok (void) const { return (nconv >= 0); } |
|
146 |
3145
|
147 operator bool () const { return ok (); } |
2117
|
148 |
|
149 bool all_character_conversions (void); |
|
150 |
|
151 bool all_numeric_conversions (void); |
|
152 |
|
153 private: |
|
154 |
3642
|
155 // Number of conversions specified by this format string, or -1 if |
2117
|
156 // invalid conversions have been found. |
|
157 int nconv; |
|
158 |
|
159 // Index to current element; |
|
160 int curr_idx; |
|
161 |
|
162 // List of format elements. |
|
163 Array<scanf_format_elt*> list; |
|
164 |
|
165 // Temporary buffer. |
5765
|
166 std::ostringstream *buf; |
2117
|
167 |
2215
|
168 void add_elt_to_list (int width, bool discard, char type, char modifier, |
3640
|
169 int& num_elts, |
|
170 const std::string& char_class = std::string ()); |
2117
|
171 |
3523
|
172 void process_conversion (const std::string& s, int& i, int n, int& width, |
2215
|
173 bool& discard, char& type, char& modifier, |
|
174 int& num_elts); |
2117
|
175 |
3523
|
176 int finish_conversion (const std::string& s, int& i, int n, int& width, |
2215
|
177 bool discard, char& type, char modifier, |
|
178 int& num_elts); |
2117
|
179 // No copying! |
|
180 |
|
181 scanf_format_list (const scanf_format_list&); |
|
182 |
|
183 scanf_format_list& operator = (const scanf_format_list&); |
|
184 }; |
|
185 |
3640
|
186 class |
2117
|
187 printf_format_elt |
|
188 { |
3640
|
189 public: |
|
190 |
|
191 printf_format_elt (const char *txt = 0, int n = 0, int w = 0, |
|
192 int p = 0, const std::string& f = std::string (), |
|
193 char typ = '\0', char mod = '\0') |
|
194 : text (strsave (txt)), args (n), fw (w), prec (p), flags (f), |
|
195 type (typ), modifier (mod) { } |
|
196 |
|
197 printf_format_elt (const printf_format_elt& e) |
|
198 : text (strsave (e.text)), args (e.args), fw (e.fw), prec (e.prec), |
|
199 flags (e.flags), type (e.type), modifier (e.modifier) { } |
|
200 |
|
201 printf_format_elt& operator = (const printf_format_elt& e) |
|
202 { |
|
203 if (this != &e) |
|
204 { |
|
205 text = strsave (e.text); |
|
206 args = e.args; |
|
207 fw = e.fw; |
|
208 prec = e.prec; |
|
209 flags = e.flags; |
|
210 type = e.type; |
|
211 modifier = e.modifier; |
|
212 } |
2117
|
213 |
3640
|
214 return *this; |
|
215 } |
2117
|
216 |
3640
|
217 ~printf_format_elt (void) { delete [] text; } |
|
218 |
|
219 // The C-style format string. |
2117
|
220 const char *text; |
3640
|
221 |
|
222 // How many args do we expect to consume? |
2117
|
223 int args; |
3640
|
224 |
|
225 // Field width. |
|
226 int fw; |
|
227 |
|
228 // Precision. |
|
229 int prec; |
|
230 |
|
231 // Flags -- `-', `+', ` ', `0', or `#'. |
3642
|
232 std::string flags; |
3640
|
233 |
|
234 // Type of conversion -- `d', `i', `o', `x', `X', `u', `c', `s', |
|
235 // `f', `e', `E', `g', `G', `p', or `%' |
2117
|
236 char type; |
3640
|
237 |
|
238 // A length modifier -- `h', `l', or `L'. |
2117
|
239 char modifier; |
|
240 }; |
|
241 |
|
242 class |
6109
|
243 OCTINTERP_API |
2117
|
244 printf_format_list |
|
245 { |
|
246 public: |
|
247 |
3523
|
248 printf_format_list (const std::string& fmt = std::string ()); |
2117
|
249 |
|
250 ~printf_format_list (void); |
|
251 |
|
252 int num_conversions (void) { return nconv; } |
|
253 |
|
254 const printf_format_elt *first (void) |
|
255 { |
|
256 curr_idx = 0; |
|
257 return current (); |
|
258 } |
|
259 |
|
260 const printf_format_elt *current (void) const |
|
261 { return list.length () > 0 ? list.elem (curr_idx) : 0; } |
|
262 |
3640
|
263 const printf_format_elt *next (bool cycle = true) |
2117
|
264 { |
|
265 curr_idx++; |
3640
|
266 |
2117
|
267 if (curr_idx >= list.length ()) |
3640
|
268 { |
|
269 if (cycle) |
|
270 curr_idx = 0; |
|
271 else |
|
272 return 0; |
|
273 } |
|
274 |
2117
|
275 return current (); |
|
276 } |
|
277 |
3640
|
278 bool last_elt_p (void) { return (curr_idx + 1 == list.length ()); } |
|
279 |
2117
|
280 void printme (void) const; |
|
281 |
|
282 bool ok (void) const { return (nconv >= 0); } |
|
283 |
3145
|
284 operator bool () const { return ok (); } |
2117
|
285 |
|
286 private: |
|
287 |
3642
|
288 // Number of conversions specified by this format string, or -1 if |
2117
|
289 // invalid conversions have been found. |
|
290 int nconv; |
|
291 |
|
292 // Index to current element; |
|
293 int curr_idx; |
|
294 |
|
295 // List of format elements. |
|
296 Array<printf_format_elt*> list; |
|
297 |
|
298 // Temporary buffer. |
5765
|
299 std::ostringstream *buf; |
2117
|
300 |
3640
|
301 void add_elt_to_list (int args, const std::string& flags, int fw, |
|
302 int prec, char type, char modifier, |
|
303 int& num_elts); |
|
304 |
|
305 void process_conversion (const std::string& s, int& i, int n, |
|
306 int& args, std::string& flags, int& fw, |
|
307 int& prec, char& modifier, char& type, |
|
308 int& num_elts); |
|
309 |
3523
|
310 void finish_conversion (const std::string& s, int& i, int args, |
3640
|
311 const std::string& flags, int fw, int prec, |
2117
|
312 char modifier, char& type, int& num_elts); |
|
313 |
|
314 // No copying! |
|
315 |
|
316 printf_format_list (const printf_format_list&); |
|
317 |
|
318 printf_format_list& operator = (const printf_format_list&); |
|
319 }; |
|
320 |
|
321 // Provide an interface for Octave streams. |
|
322 |
|
323 class |
6109
|
324 OCTINTERP_API |
2117
|
325 octave_base_stream |
|
326 { |
|
327 friend class octave_stream; |
|
328 |
|
329 public: |
|
330 |
3544
|
331 octave_base_stream (std::ios::openmode arg_md = std::ios::in|std::ios::out, |
5015
|
332 oct_mach_info::float_format ff |
|
333 = oct_mach_info::native_float_format ()) |
3340
|
334 : count (0), md (arg_md), flt_fmt (ff), fail (false), open_state (true) |
|
335 { } |
2117
|
336 |
|
337 virtual ~octave_base_stream (void) { } |
|
338 |
|
339 // The remaining functions are not specific to input or output only, |
|
340 // and must be provided by the derived classes. |
|
341 |
|
342 // Position a stream at OFFSET relative to ORIGIN. |
|
343 |
4797
|
344 virtual int seek (long offset, int origin) = 0; |
2117
|
345 |
|
346 // Return current stream position. |
|
347 |
4797
|
348 virtual long tell (void) = 0; |
2117
|
349 |
3340
|
350 // Return TRUE if EOF has been reached on this stream. |
2117
|
351 |
|
352 virtual bool eof (void) const = 0; |
|
353 |
|
354 // The name of the file. |
|
355 |
3523
|
356 virtual std::string name (void) const = 0; |
2117
|
357 |
|
358 // If the derived class provides this function and it returns a |
|
359 // pointer to a valid istream, scanf(), read(), getl(), and gets() |
|
360 // will automatically work for this stream. |
|
361 |
3523
|
362 virtual std::istream *input_stream (void) { return 0; } |
2117
|
363 |
|
364 // If the derived class provides this function and it returns a |
|
365 // pointer to a valid ostream, flush(), write(), and printf() will |
|
366 // automatically work for this stream. |
|
367 |
3523
|
368 virtual std::ostream *output_stream (void) { return 0; } |
2117
|
369 |
3340
|
370 // Return TRUE if this stream is open. |
|
371 |
|
372 bool is_open (void) const { return open_state; } |
|
373 |
3652
|
374 virtual void do_close (void) { } |
|
375 |
|
376 void close (void) |
|
377 { |
|
378 if (is_open ()) |
|
379 { |
|
380 open_state = false; |
|
381 do_close (); |
|
382 } |
|
383 } |
3340
|
384 |
3148
|
385 int file_number (void); |
3145
|
386 |
2117
|
387 bool ok (void) const { return ! fail; } |
|
388 |
|
389 // Return current error message for this stream. |
|
390 |
3523
|
391 std::string error (bool clear, int& err_num); |
2117
|
392 |
|
393 protected: |
|
394 |
3340
|
395 int mode (void) const { return md; } |
2117
|
396 |
3340
|
397 oct_mach_info::float_format float_format (void) const { return flt_fmt; } |
2117
|
398 |
|
399 // Set current error state and set fail to TRUE. |
|
400 |
3523
|
401 void error (const std::string& msg); |
4468
|
402 void error (const std::string& who, const std::string& msg); |
2117
|
403 |
|
404 // Clear any error message and set fail to FALSE. |
|
405 |
|
406 void clear (void); |
|
407 |
4889
|
408 // Clear stream state. |
|
409 |
|
410 void clearerr (void); |
|
411 |
2117
|
412 private: |
|
413 |
3340
|
414 // A reference count. |
5275
|
415 octave_idx_type count; |
3340
|
416 |
2117
|
417 // The permission bits for the file. Should be some combination of |
3544
|
418 // std::ios::open_mode bits. |
2117
|
419 int md; |
|
420 |
|
421 // Data format. |
2317
|
422 oct_mach_info::float_format flt_fmt; |
2117
|
423 |
|
424 // TRUE if an error has occurred. |
|
425 bool fail; |
|
426 |
3340
|
427 // TRUE if this stream is open. |
|
428 bool open_state; |
|
429 |
2117
|
430 // Should contain error message if fail is TRUE. |
3523
|
431 std::string errmsg; |
2117
|
432 |
|
433 // Functions that are defined for all input streams (input streams |
|
434 // are those that define is). |
|
435 |
5275
|
436 std::string do_gets (octave_idx_type max_len, bool& err, bool strip_newline, |
4468
|
437 const std::string& who /* = "gets" */); |
2117
|
438 |
5275
|
439 std::string getl (octave_idx_type max_len, bool& err, const std::string& who /* = "getl" */); |
|
440 std::string gets (octave_idx_type max_len, bool& err, const std::string& who /* = "gets" */); |
2117
|
441 |
5275
|
442 octave_value do_scanf (scanf_format_list& fmt_list, octave_idx_type nr, octave_idx_type nc, |
|
443 bool one_elt_size_spec, octave_idx_type& count, |
4468
|
444 const std::string& who /* = "scanf" */); |
2117
|
445 |
4468
|
446 octave_value scanf (const std::string& fmt, const Array<double>& size, |
5275
|
447 octave_idx_type& count, const std::string& who /* = "scanf" */); |
2117
|
448 |
4468
|
449 bool do_oscanf (const scanf_format_elt *elt, octave_value&, |
|
450 const std::string& who /* = "scanf" */); |
2117
|
451 |
4468
|
452 octave_value_list oscanf (const std::string& fmt, |
|
453 const std::string& who /* = "scanf" */); |
2215
|
454 |
2117
|
455 // Functions that are defined for all output streams (output streams |
|
456 // are those that define os). |
|
457 |
|
458 int flush (void); |
|
459 |
4468
|
460 int do_printf (printf_format_list& fmt_list, const octave_value_list& args, |
|
461 const std::string& who /* = "printf" */); |
2117
|
462 |
4468
|
463 int printf (const std::string& fmt, const octave_value_list& args, |
|
464 const std::string& who /* = "printf" */); |
2117
|
465 |
4468
|
466 int puts (const std::string& s, const std::string& who /* = "puts" */); |
2117
|
467 |
|
468 // We can always do this in terms of seek(), so the derived class |
|
469 // only has to provide that. |
|
470 |
4468
|
471 void invalid_operation (const std::string& who, const char *rw); |
2117
|
472 |
|
473 // No copying! |
|
474 |
|
475 octave_base_stream (const octave_base_stream&); |
|
476 |
|
477 octave_base_stream& operator = (const octave_base_stream&); |
|
478 }; |
|
479 |
|
480 class |
6109
|
481 OCTINTERP_API |
2117
|
482 octave_stream |
|
483 { |
|
484 public: |
|
485 |
3340
|
486 octave_stream (octave_base_stream *bs = 0); |
|
487 |
|
488 ~octave_stream (void); |
2117
|
489 |
3340
|
490 octave_stream (const octave_stream&); |
|
491 |
|
492 octave_stream& operator = (const octave_stream&); |
2117
|
493 |
|
494 int flush (void); |
|
495 |
5275
|
496 std::string getl (octave_idx_type max_len, bool& err, const std::string& who /* = "getl" */); |
4468
|
497 std::string getl (const octave_value& max_len, bool& err, |
|
498 const std::string& who /* = "getl" */); |
2117
|
499 |
5275
|
500 std::string gets (octave_idx_type max_len, bool& err, const std::string& who /* = "gets" */); |
4468
|
501 std::string gets (const octave_value& max_len, bool& err, |
|
502 const std::string& who /* = "gets" */); |
2117
|
503 |
4797
|
504 int seek (long offset, int origin); |
2117
|
505 int seek (const octave_value& offset, const octave_value& origin); |
|
506 |
4797
|
507 long tell (void); |
2117
|
508 |
|
509 int rewind (void); |
|
510 |
3340
|
511 bool is_open (void) const; |
|
512 |
|
513 void close (void); |
|
514 |
5275
|
515 octave_value read (const Array<double>& size, octave_idx_type block_size, |
4944
|
516 oct_data_conv::data_type input_type, |
|
517 oct_data_conv::data_type output_type, |
5275
|
518 octave_idx_type skip, oct_mach_info::float_format flt_fmt, |
|
519 octave_idx_type& count); |
2117
|
520 |
5275
|
521 octave_idx_type write (const octave_value& data, octave_idx_type block_size, |
4944
|
522 oct_data_conv::data_type output_type, |
5275
|
523 octave_idx_type skip, oct_mach_info::float_format flt_fmt); |
4944
|
524 |
|
525 template <class T> |
5275
|
526 octave_idx_type write (const Array<T>&, octave_idx_type block_size, |
4944
|
527 oct_data_conv::data_type output_type, |
5275
|
528 octave_idx_type skip, oct_mach_info::float_format flt_fmt); |
2117
|
529 |
4468
|
530 octave_value scanf (const std::string& fmt, const Array<double>& size, |
5275
|
531 octave_idx_type& count, const std::string& who /* = "scanf" */); |
2117
|
532 |
5279
|
533 octave_value scanf (const octave_value& fmt, const Array<double>& size, |
5299
|
534 octave_idx_type& count, const std::string& who /* = "scanf" */); |
5279
|
535 |
4468
|
536 octave_value_list oscanf (const std::string& fmt, |
|
537 const std::string& who /* = "scanf" */); |
2215
|
538 |
5279
|
539 octave_value_list oscanf (const octave_value& fmt, |
|
540 const std::string& who /* = "scanf" */); |
|
541 |
4468
|
542 int printf (const std::string& fmt, const octave_value_list& args, |
|
543 const std::string& who /* = "printf" */); |
2117
|
544 |
5279
|
545 int printf (const octave_value& fmt, const octave_value_list& args, |
|
546 const std::string& who /* = "printf" */); |
|
547 |
4468
|
548 int puts (const std::string& s, const std::string& who /* = "puts" */); |
|
549 int puts (const octave_value& s, const std::string& who /* = "puts" */); |
2117
|
550 |
|
551 bool eof (void) const; |
|
552 |
3523
|
553 std::string error (bool clear, int& err_num); |
2117
|
554 |
3523
|
555 std::string error (bool clear = false) |
2117
|
556 { |
2435
|
557 int err_num; |
|
558 return error (clear, err_num); |
2117
|
559 } |
|
560 |
4799
|
561 // Set the error message and state. |
|
562 |
|
563 void error (const std::string& msg) |
|
564 { |
|
565 if (rep) |
|
566 rep->error (msg); |
|
567 } |
|
568 |
|
569 void error (const char *msg) { error (std::string (msg)); } |
|
570 |
3148
|
571 int file_number (void) { return rep ? rep->file_number () : -1; } |
3145
|
572 |
3340
|
573 bool is_valid (void) const { return (rep != 0); } |
|
574 |
2117
|
575 bool ok (void) const { return rep && rep->ok (); } |
|
576 |
3145
|
577 operator bool () const { return ok (); } |
2117
|
578 |
3523
|
579 std::string name (void) const; |
2117
|
580 |
3340
|
581 int mode (void) const; |
2117
|
582 |
3340
|
583 oct_mach_info::float_format float_format (void) const; |
2117
|
584 |
3523
|
585 static std::string mode_as_string (int mode); |
2117
|
586 |
6757
|
587 std::istream *input_stream (void) |
|
588 { |
|
589 return rep ? rep->input_stream () : 0; |
|
590 } |
2902
|
591 |
6757
|
592 std::ostream *output_stream (void) |
|
593 { |
|
594 return rep ? rep->output_stream () : 0; |
|
595 } |
2902
|
596 |
4889
|
597 void clearerr (void) { if (rep) rep->clearerr (); } |
|
598 |
2117
|
599 private: |
|
600 |
|
601 // The actual representation of this stream. |
|
602 octave_base_stream *rep; |
|
603 |
5659
|
604 bool stream_ok (bool clear = true) const |
|
605 { |
|
606 bool retval = true; |
|
607 |
|
608 if (rep) |
|
609 { |
|
610 if (clear) |
|
611 rep->clear (); |
|
612 } |
|
613 else |
|
614 retval = false; |
|
615 |
|
616 return retval; |
|
617 } |
4944
|
618 |
|
619 void invalid_operation (const std::string& who, const char *rw) |
|
620 { |
|
621 if (rep) |
|
622 rep->invalid_operation (who, rw); |
|
623 } |
2117
|
624 }; |
|
625 |
|
626 class |
6109
|
627 OCTINTERP_API |
2117
|
628 octave_stream_list |
|
629 { |
|
630 protected: |
|
631 |
6757
|
632 octave_stream_list (void) : list () { } |
2117
|
633 |
|
634 public: |
|
635 |
|
636 ~octave_stream_list (void) { } |
|
637 |
2926
|
638 static bool instance_ok (void); |
|
639 |
6757
|
640 static int insert (octave_stream& os); |
2117
|
641 |
4468
|
642 static octave_stream |
|
643 lookup (int fid, const std::string& who = std::string ()); |
|
644 |
|
645 static octave_stream |
|
646 lookup (const octave_value& fid, const std::string& who = std::string ()); |
2117
|
647 |
3523
|
648 static int remove (int fid, const std::string& who = std::string ()); |
3341
|
649 static int remove (const octave_value& fid, |
3523
|
650 const std::string& who = std::string ()); |
2117
|
651 |
|
652 static void clear (void); |
|
653 |
|
654 static string_vector get_info (int fid); |
|
655 static string_vector get_info (const octave_value& fid); |
|
656 |
3523
|
657 static std::string list_open_files (void); |
2117
|
658 |
|
659 static octave_value open_file_numbers (void); |
|
660 |
2609
|
661 static int get_file_number (const octave_value& fid); |
|
662 |
2117
|
663 private: |
|
664 |
6757
|
665 typedef std::map<int, octave_stream> ostrl_map; |
2117
|
666 |
6757
|
667 ostrl_map list; |
2117
|
668 |
|
669 static octave_stream_list *instance; |
|
670 |
6757
|
671 int do_insert (octave_stream& os); |
2117
|
672 |
3523
|
673 octave_stream do_lookup (int fid, const std::string& who = std::string ()) const; |
3341
|
674 octave_stream do_lookup (const octave_value& fid, |
3523
|
675 const std::string& who = std::string ()) const; |
2117
|
676 |
3523
|
677 int do_remove (int fid, const std::string& who = std::string ()); |
|
678 int do_remove (const octave_value& fid, const std::string& who = std::string ()); |
2117
|
679 |
|
680 void do_clear (void); |
|
681 |
|
682 string_vector do_get_info (int fid) const; |
|
683 string_vector do_get_info (const octave_value& fid) const; |
|
684 |
3523
|
685 std::string do_list_open_files (void) const; |
2117
|
686 |
|
687 octave_value do_open_file_numbers (void) const; |
|
688 |
2609
|
689 int do_get_file_number (const octave_value& fid) const; |
2117
|
690 }; |
|
691 |
|
692 #endif |
|
693 |
|
694 /* |
|
695 ;;; Local Variables: *** |
|
696 ;;; mode: C++ *** |
|
697 ;;; End: *** |
|
698 */ |