comparison src/oct-stream.h @ 2317:8c09c04f7747

[project @ 1996-07-14 22:30:15 by jwe]
author jwe
date Sun, 14 Jul 1996 22:40:35 +0000
parents 587b867918de
children 3be97fe02051
comparison
equal deleted inserted replaced
2316:fbc76f6e4893 2317:8c09c04f7747
27 27
28 #include <iostream.h> 28 #include <iostream.h>
29 #include <strstream.h> 29 #include <strstream.h>
30 30
31 #include "Array.h" 31 #include "Array.h"
32 #include "data-conv.h"
33 #include "mach-info.h"
32 34
33 #include "oct-obj.h" 35 #include "oct-obj.h"
34 #include "str-vec.h" 36 #include "str-vec.h"
35 37
36 struct 38 struct
213 { 215 {
214 friend class octave_stream; 216 friend class octave_stream;
215 217
216 public: 218 public:
217 219
218 enum arch_type
219 {
220 at_unknown,
221 at_native
222 };
223
224 enum data_type
225 {
226 dt_unknown,
227 dt_char,
228 dt_schar,
229 dt_uchar,
230 dt_short,
231 dt_ushort,
232 dt_int,
233 dt_uint,
234 dt_long,
235 dt_ulong,
236 dt_float,
237 dt_double,
238 dt_float_complex,
239 dt_double_complex
240 };
241
242 octave_base_stream (ios::openmode arg_md = ios::in|ios::out, 220 octave_base_stream (ios::openmode arg_md = ios::in|ios::out,
243 arch_type arg_at = at_native) 221 oct_mach_info::float_format ff = oct_mach_info::native)
244 : md (arg_md), at (arg_at), fail (false) { } 222 : md (arg_md), flt_fmt (ff), fail (false) { }
245 223
246 virtual ~octave_base_stream (void) { } 224 virtual ~octave_base_stream (void) { }
247 225
248 // The remaining functions are not specific to input or output only, 226 // The remaining functions are not specific to input or output only,
249 // and must be provided by the derived classes. 227 // and must be provided by the derived classes.
284 262
285 protected: 263 protected:
286 264
287 int mode (void) { return md; } 265 int mode (void) { return md; }
288 266
289 arch_type architecture (void) { return at; } 267 oct_mach_info::float_format float_format (void) { return flt_fmt; }
290 268
291 // Set current error state and set fail to TRUE. 269 // Set current error state and set fail to TRUE.
292 270
293 void error (const string& msg); 271 void error (const string& msg);
294 272
301 // The permission bits for the file. Should be some combination of 279 // The permission bits for the file. Should be some combination of
302 // ios::open_mode bits. 280 // ios::open_mode bits.
303 int md; 281 int md;
304 282
305 // Data format. 283 // Data format.
306 arch_type at; 284 oct_mach_info::float_format flt_fmt;
307 285
308 // TRUE if an error has occurred. 286 // TRUE if an error has occurred.
309 bool fail; 287 bool fail;
310 288
311 // Should contain error message if fail is TRUE. 289 // Should contain error message if fail is TRUE.
312 string errmsg; 290 string errmsg;
313 291
314 // Functions that are defined for all input streams (input streams 292 // Functions that are defined for all input streams (input streams
315 // are those that define is). 293 // are those that define is).
316 294
317 string do_gets (int max_len, bool& err, bool strip_newline, const char *fcn); 295 string do_gets (int max_len, bool& err, bool strip_newline,
296 const char *fcn);
318 297
319 string getl (int max_len, bool& err); 298 string getl (int max_len, bool& err);
320 string gets (int max_len, bool& err); 299 string gets (int max_len, bool& err);
321 300
322 octave_value do_read (int nr, int nc, data_type dt, int skip, 301 octave_value do_read (int nr, int nc, oct_data_conv::data_type dt,
323 arch_type at, int& count); 302 int skip, oct_mach_info::float_format flt_fmt,
324 303 int& count);
325 octave_value read (const Matrix& size, data_type dt, int skip, 304
326 arch_type at, int& count); 305 octave_value read (const Matrix& size, oct_data_conv::data_type dt,
306 int skip, oct_mach_info::float_format flt_fmt,
307 int& count);
327 308
328 octave_value do_char_scanf (scanf_format_list& fmt_list, 309 octave_value do_char_scanf (scanf_format_list& fmt_list,
329 int nr, int nc, int& count); 310 int nr, int nc, int& count);
330 311
331 octave_value do_real_scanf (scanf_format_list& fmt_list, 312 octave_value do_real_scanf (scanf_format_list& fmt_list,
343 // Functions that are defined for all output streams (output streams 324 // Functions that are defined for all output streams (output streams
344 // are those that define os). 325 // are those that define os).
345 326
346 int flush (void); 327 int flush (void);
347 328
348 int do_write (const double *d, int n, data_type dt, int skip, 329 int do_write (const Matrix& m, oct_data_conv::data_type dt, int skip,
349 arch_type at); 330 oct_mach_info::float_format flt_fmt);
350 331
351 int write (const octave_value& data, data_type dt, int skip, 332 int write (const octave_value& data, oct_data_conv::data_type dt,
352 arch_type at); 333 int skip, oct_mach_info::float_format flt_fmt);
353 334
354 int do_printf (printf_format_list& fmt_list, const octave_value_list& args); 335 int do_printf (printf_format_list& fmt_list, const octave_value_list& args);
355 336
356 int printf (const string& fmt, const octave_value_list& args); 337 int printf (const string& fmt, const octave_value_list& args);
357 338
398 379
399 long tell (void) const; 380 long tell (void) const;
400 381
401 int rewind (void); 382 int rewind (void);
402 383
403 octave_value read (const Matrix& size, 384 octave_value read (const Matrix& size, oct_data_conv::data_type dt,
404 octave_base_stream::data_type dt, 385 int skip, oct_mach_info::float_format flt_fmt,
405 int skip, octave_base_stream::arch_type at,
406 int& count); 386 int& count);
407 387
408 int write (const octave_value& data, 388 int write (const octave_value& data, oct_data_conv::data_type dt,
409 octave_base_stream::data_type dt, int skip, 389 int skip, oct_mach_info::float_format flt_fmt);
410 octave_base_stream::arch_type at);
411 390
412 octave_value scanf (const string& fmt, const Matrix& size, int& count); 391 octave_value scanf (const string& fmt, const Matrix& size, int& count);
413 392
414 octave_value_list oscanf (const string& fmt); 393 octave_value_list oscanf (const string& fmt);
415 394
434 413
435 string name (void); 414 string name (void);
436 415
437 int mode (void); 416 int mode (void);
438 417
439 octave_base_stream::arch_type architecture (void); 418 oct_mach_info::float_format float_format (void);
440 419
441 static string mode_as_string (int mode); 420 static string mode_as_string (int mode);
442
443 static string arch_as_string (octave_base_stream::arch_type at);
444
445 static octave_base_stream::data_type string_to_data_type (const string& s);
446 static octave_base_stream::arch_type string_to_arch_type (const string& s);
447 421
448 private: 422 private:
449 423
450 // The actual representation of this stream. 424 // The actual representation of this stream.
451 octave_base_stream *rep; 425 octave_base_stream *rep;