Mercurial > hg > octave-lyh
diff src/oct-stream.h @ 2215:ab0e1fd337f5
[project @ 1996-05-16 15:56:40 by jwe]
author | jwe |
---|---|
date | Thu, 16 May 1996 15:56:40 +0000 |
parents | ee08cc210438 |
children | 587b867918de |
line wrap: on
line diff
--- a/src/oct-stream.h +++ b/src/oct-stream.h @@ -36,13 +36,14 @@ struct scanf_format_elt { - scanf_format_elt (const char *txt = 0, bool d = false, + scanf_format_elt (const char *txt = 0, int w = 0, bool d = false, char typ = '\0', char mod = '\0') - : text (txt), discard (d), type (typ), modifier (mod) { } + : text (txt), width (w), discard (d), type (typ), modifier (mod) { } ~scanf_format_elt (void) { delete text; } const char *text; + int width; bool discard; char type; char modifier; @@ -59,6 +60,13 @@ int num_conversions (void) { return nconv; } + // The length can be different than the number of conversions. + // For example, "x %d y %d z" has 2 conversions but the length of + // the list is 3 because of the characters that appear after the + // last conversion. + + int length (void) { return list.length (); } + const scanf_format_elt *first (void) { curr_idx = 0; @@ -101,14 +109,16 @@ // Temporary buffer. ostrstream *buf; - void add_elt_to_list (bool discard, char type, char modifier, + void add_elt_to_list (int width, bool discard, char type, char modifier, int& num_elts); - void process_conversion (const string& s, int& i, int n, bool& discard, - char& type, char& modifier, int& num_elts); + void process_conversion (const string& s, int& i, int n, int& width, + bool& discard, char& type, char& modifier, + int& num_elts); - int finish_conversion (const string& s, int& i, int n, bool discard, - char& type, char modifier, int& num_elts); + int finish_conversion (const string& s, int& i, int n, int& width, + bool discard, char& type, char modifier, + int& num_elts); // No copying! scanf_format_list (const scanf_format_list&); @@ -326,6 +336,10 @@ octave_value scanf (const string& fmt, const Matrix& size, int& count); + octave_value do_oscanf (const scanf_format_elt *elt); + + octave_value_list oscanf (const string& fmt); + // Functions that are defined for all output streams (output streams // are those that define os). @@ -397,6 +411,8 @@ octave_value scanf (const string& fmt, const Matrix& size, int& count); + octave_value_list oscanf (const string& fmt); + int printf (const string& fmt, const octave_value_list& args); int puts (const string& s);