24 #if defined (HAVE_CONFIG_H)
90 catch (
const octave::execution_exception&)
121 ::error (
"%s: NaN is invalid as size specification", who.c_str ());
128 ::error (
"%s: negative value invalid as size specification",
132 ::
error (
"%s: dimension too large for Octave's index type",
148 one_elt_size_spec =
false;
157 one_elt_size_spec =
true;
161 dnc = (dnr == 0.0) ? 0.0 : 1.0;
163 else if (sz_len == 2)
168 ::error (
"%s: invalid size specification", who.c_str ());
173 ::error (
"%s: invalid size specification", who.c_str ());
188 whitespace_conversion = 1,
189 literal_conversion = 2,
194 char typ =
'\0',
char mod =
'\0',
197 modifier (
mod), char_class (ch_class)
202 type (e.
type), modifier (e.modifier), char_class (e.char_class)
258 size_t length (
void)
const {
return fmt_elts.size (); }
268 return length () > 0 ? fmt_elts[curr_idx] : 0;
278 if (curr_idx >=
length ())
289 void printme (
void)
const;
291 bool ok (
void)
const {
return (nconv >= 0); }
293 operator bool ()
const {
return ok (); }
295 bool all_character_conversions (
void);
297 bool all_numeric_conversions (
void);
314 void add_elt_to_list (
int width,
bool discard,
char type,
char modifier,
317 void process_conversion (
const std::string&
s,
size_t&
i,
size_t n,
318 int& width,
bool& discard,
char&
type,
321 int finish_conversion (
const std::string&
s,
size_t&
i,
size_t n,
322 int& width,
bool discard,
char&
type,
332 : nconv (0), curr_idx (0), fmt_elts (), buf ()
334 size_t n = s.length ();
339 bool discard =
false;
340 char modifier =
'\0';
343 bool have_more =
true;
355 have_more = (
buf.tellp () != 0);
357 else if (isspace (s[i]))
366 while (++i < n && isspace (s[i]))
381 while (i < n && ! isspace (s[i]) && s[i] !=
'%')
407 for (
size_t i = 0;
i < n;
i++)
425 modifier, char_class);
445 unsigned char c = s[i++];
447 if (c ==
'-' && i > 1 && i < len
448 && ( static_cast<unsigned char> (s[i-2])
449 <= static_cast<unsigned char> (s[i])))
454 for (c = s[i-2]+1; c < s[
i]; c++)
462 if (c !=
'-' || i == len)
472 size_t n,
int& width,
bool& discard,
473 char&
type,
char& modifier)
482 bool have_width =
false;
498 case '0':
case '1':
case '2':
case '3':
case '4':
499 case '5':
case '6':
case '7':
case '8':
case '9':
505 width = 10 * width + c -
'0';
508 while (i < n && isdigit (s[i]))
511 width = 10 * width + c -
'0';
517 case 'h':
case 'l':
case 'L':
518 if (modifier !=
'\0')
524 case 'd':
case 'i':
case 'o':
case 'u':
case 'x':
532 case 'e':
case 'f':
case 'g':
544 case 'c':
case 's':
case 'p':
case '%':
case '[':
545 if (modifier !=
'\0')
555 type, modifier) == 0)
574 size_t n,
int& width,
bool discard,
575 char&
type,
char modifier)
581 size_t beg_idx = std::string::npos;
582 size_t end_idx = std::string::npos;
614 else if (s[i] ==
']')
618 while (i < n && s[i] !=
']')
621 if (i < n && s[i] ==
']')
638 if (beg_idx != std::string::npos && end_idx != std::string::npos)
640 end_idx - beg_idx + 1));
653 for (
size_t i = 0;
i < n;
i++)
658 <<
"width: " << elt->
width <<
"\n"
659 <<
"discard: " << elt->
discard <<
"\n"
663 std::cerr <<
"literal text\n";
665 std::cerr <<
"whitespace\n";
667 std::cerr << elt->
type <<
"\n";
670 <<
"modifier: " << elt->
modifier <<
"\n"
683 for (
size_t i = 0;
i < n;
i++)
689 case 'c':
case 's':
case '%':
case '[':
case '^':
713 for (
size_t i = 0;
i < n;
i++)
719 case 'd':
case 'i':
case 'o':
case 'u':
case 'x':
720 case 'e':
case 'f':
case 'g':
742 char typ =
'\0',
char mod =
'\0')
749 flags (e.flags),
type (e.
type), modifier (e.modifier)
812 return length () > 0 ? fmt_elts[curr_idx] : 0;
815 size_t length (
void)
const {
return fmt_elts.size (); }
821 if (curr_idx >=
length ())
834 void printme (
void)
const;
836 bool ok (
void)
const {
return (nconv >= 0); }
838 operator bool ()
const {
return ok (); }
856 int prec,
char type,
char modifier);
858 void process_conversion (
const std::string&
s,
size_t&
i,
size_t n,
860 int& prec,
char& modifier,
char&
type);
864 char modifier,
char&
type);
874 : nconv (0), curr_idx (0), fmt_elts (), buf ()
876 size_t n = s.length ();
884 char modifier =
'\0';
887 bool have_more =
true;
888 bool empty_buf =
true;
903 empty_buf = (
buf.tellp () == 0);
920 have_more = (
buf.tellp () != 0);
960 for (
size_t i = 0;
i < n;
i++)
969 int fw,
int prec,
char type,
991 int& prec,
char& modifier,
1009 case '-':
case '+':
case ' ':
case '0':
case '#':
1037 sscanf (tmp.c_str (),
"%d%n", &fw, &
nn);
1040 while (i < n && isdigit (s[i]))
1045 if (i < n && s[i] ==
'.')
1070 sscanf (tmp.c_str (),
"%d%n", &prec, &
nn);
1073 while (i < n && isdigit (s[i]))
1087 case 'h':
case 'l':
case 'L':
1105 int fw,
int prec,
char modifier,
1110 case 'd':
case 'i':
case 'o':
case 'x':
case 'X':
1112 if (modifier ==
'L')
1119 case 'f':
case 'e':
case 'E':
case 'g':
case 'G':
1120 if (modifier ==
'h' || modifier ==
'l')
1127 case 's':
case 'p':
case '%':
1128 if (modifier !=
'\0')
1141 if (type !=
'%' || args != 0)
1162 for (
size_t i = 0;
i < n;
i++)
1167 <<
"args: " << elt->
args <<
"\n"
1168 <<
"flags: '" << elt->
flags <<
"'\n"
1169 <<
"width: " << elt->
fw <<
"\n"
1170 <<
"prec: " << elt->
prec <<
"\n"
1171 <<
"type: '" << elt->
type <<
"'\n"
1172 <<
"modifier: '" << elt->
modifier <<
"'\n"
1185 for (
unsigned int d = n;
d;
d >>= 1)
1243 int refresh_buf (
void);
1250 return eof () ? std::istream::traits_type::eof () : *idx++;
1252 return get_undelim ();
1256 int get_undelim (
void);
1259 int peek (
void) {
return eof () ? std::istream::traits_type::eof () : *idx; }
1262 int peek_undelim (
void);
1274 char *read (
char *buffer,
int size,
char* &new_start);
1280 void seekg (
char *old_idx) { idx = old_idx; }
1284 return (eob == buf && i_stream.eof ()) || (flags & std::ios_base::eofbit);
1287 operator const void* (void) {
return (! eof () && ! flags) ?
this : 0; }
1289 bool fail (
void) {
return flags & std::ios_base::failbit; }
1291 std::ios_base::iostate
rdstate (
void) {
return flags; }
1296 = (std::ios_base::eofbit & ~std::ios_base::eofbit))
1359 int longest_lookahead,
1361 : bufsize (bsize), i_stream (is), longest (longest_lookahead),
1362 delims (delimiters),
1363 flags (
std::ios::failbit & ~
std::ios::failbit)
1376 : bufsize (ds.bufsize), i_stream (is), longest (ds.longest),
1378 flags (
std::ios::failbit & ~
std::ios::failbit)
1410 return std::istream::traits_type::eof ();
1422 retval = std::istream::traits_type::eof ();
1455 return std::istream::traits_type::eof ();
1462 size_t old_remaining =
eob -
idx;
1466 if (old_remaining > 0)
1469 memmove (
buf, idx, old_remaining);
1485 eob = buf + old_remaining + gcount;
1495 retval = std::istream::traits_type::eof ();
1503 if (
delims.find (*
last) != std::string::npos)
1514 if (retval == std::istream::traits_type::eof ())
1579 for (i = 0; i < size && !
eof (); i++)
1582 memset (buffer, 0, size - i);
1596 int len = out.length (),
used = 0;
1599 && ch != std::istream::traits_type::eof ())
1623 whitespace_conversion = 1,
1624 literal_conversion = 2
1628 int bw = 0,
bool dis =
false,
char typ =
'\0',
1630 :
text (txt), width (
w), prec (
p), bitwidth (bw),
1631 char_class (ch_class),
type (typ), discard (dis),
1632 numeric (typ ==
'd' || typ ==
'u' ||
type ==
'f' ||
type ==
'n')
1636 :
text (e.
text), width (e.width), prec (e.prec),
1637 bitwidth (e.bitwidth), char_class (e.char_class),
type (e.
type),
1638 discard (e.discard), numeric (e.numeric)
1707 size_t numel (
void)
const {
return fmt_elts.size (); }
1717 return numel () > 0 ? fmt_elts[curr_idx] : 0;
1724 if (curr_idx >=
numel ())
1735 void printme (
void)
const;
1737 bool ok (
void)
const {
return (nconv >= 0); }
1739 operator const void* (void)
const {
return ok () ?
this : 0; }
1752 std::list<octave_value>
out_buf (
void)
const {
return (output_container); }
1772 void add_elt_to_list (
unsigned int width,
int prec,
int bitwidth,
1777 void process_conversion (
const std::string&
s,
size_t&
i,
size_t n);
1781 int finish_conversion (
const std::string&
s,
size_t&
i,
size_t n,
1782 unsigned int& width,
int& prec,
int& bitwidth,
1784 bool discard,
char& type);
1886 std::list<octave_value>&
retval,
1919 bool case_sensitive =
true)
const;
1929 return ((delim_table.empty () && (isspace (ch) || ch == eol1 || ch == eol2))
1930 || delim_table[ch] !=
'\0');
1933 bool isspace (
unsigned int ch)
const {
return whitespace_table[ch & 0xff]; }
1947 : who (who_arg), set_from_first (
false), has_string (
false),
1948 nconv (0), curr_idx (0), fmt_elts (), buf ()
1950 size_t n = s.length ();
1954 unsigned int width = -1;
1957 bool discard =
false;
1960 bool have_more =
true;
1974 set_from_first =
true;
1979 set_from_first =
false;
1985 if (s[i] ==
'%' && (i+1 == n || s[i+1] !=
'%'))
1997 have_more = (buf.tellp () != 0);
1999 else if (isspace (s[i]))
2001 while (++i < n && isspace (s[i]))
2015 while (i < n && ! isspace (s[i])
2016 && (s[
i] !=
'%' || (i+1 < n && s[i+1] ==
'%')))
2047 size_t n =
numel ();
2049 for (
size_t i = 0;
i < n;
i++)
2059 bool discard,
char type,
2064 if (! text.empty ())
2071 output_container.push_back (val_type);
2073 fmt_elts.push_back (elt);
2087 bool discard =
false;
2093 bool have_width =
false;
2109 case '0':
case '1':
case '2':
case '3':
case '4':
2110 case '5':
case '6':
case '7':
case '8':
case '9':
2116 width = width * 10 + c -
'0';
2119 while (i < n && isdigit (s[i]))
2122 width = width * 10 + c -
'0';
2126 if (i < n && s[i] ==
'.')
2130 while (i < n && isdigit (s[i]))
2133 prec = prec * 10 + c -
'0';
2143 buf << (type = s[i++]);
2155 else if (s[i] ==
'1' && i+1 < n && s[i+1] ==
'6')
2165 else if (s[i] ==
'3' && i+1 < n && s[i+1] ==
'2')
2171 else if (s[i] ==
'6' && i+1 < n && s[i+1] ==
'4')
2199 buf << (type = s[i++]);
2203 if (s[i] ==
'3' && i+1 < n && s[i+1] ==
'2')
2210 else if (s[i] ==
'6' && i+1 < n && s[i+1] ==
'4')
2224 buf << (type = s[i++]);
2229 case 's':
case 'q':
case '[':
case 'c':
2232 buf << (type = s[i++]);
2243 width =
static_cast<unsigned int> (-1);
2247 discard, type) == 0)
2253 error (
"%s: '%%%c' is not a valid format specifier",
2254 who.c_str (), s[
i]);
2279 int len = pattern.length ();
2286 int in = 0, out = 0;
2287 unsigned char ch, prev = 0;
2296 mask[pattern[in]] =
'\1';
2297 retval[out++] = pattern[in++];
2299 bool prev_was_range =
false;
2300 bool prev_prev_was_range =
false;
2301 for (; in < len; in++)
2303 bool was_range =
false;
2308 if (prev ==
'-' && in > 1 && isalnum (ch) && ! prev_prev_was_range)
2310 unsigned char start_of_range = pattern[in-2];
2311 if (start_of_range < ch
2312 && ((isupper (ch) && isupper (start_of_range))
2313 || (islower (ch) && islower (start_of_range))
2314 || (isdigit (ch) && isdigit (start_of_range))
2320 for (
int i = start_of_range;
i <= ch;
i++)
2322 if (mask[
i] ==
'\0')
2332 if (mask[ch]++ == 0)
2336 "%s: [...] contains two '%c's",
2339 if (prev ==
'-' && mask[
'-'] >= 2)
2341 (
"octave:textscan-pattern",
2342 "%s: [...] contains two '-'s outside range expressions",
2346 prev_prev_was_range = prev_was_range;
2347 prev_was_range = was_range;
2353 for (
int i = 0;
i < 256;
i++)
2358 retval.resize (out);
2365 size_t n,
unsigned int& width,
2366 int& prec,
int& bitwidth,
2374 size_t beg_idx = std::string::npos;
2375 size_t end_idx = std::string::npos;
2399 else if (s[i] ==
']')
2403 while (i < n && s[i] !=
']')
2406 if (i < n && s[i] ==
']')
2413 retval = nconv = -1;
2419 if (beg_idx != std::string::npos && end_idx != std::string::npos)
2421 end_idx - beg_idx + 1));
2433 size_t n =
numel ();
2435 for (
size_t i = 0;
i < n;
i++)
2440 <<
"width: " << elt->
width <<
"\n"
2441 <<
"digits " << elt->
prec <<
"\n"
2442 <<
"bitwidth: " << elt->
bitwidth <<
"\n"
2443 <<
"discard: " << elt->
discard <<
"\n"
2447 std::cerr <<
"literal text\n";
2449 std::cerr <<
"whitespace\n";
2451 std::cerr << elt->
type <<
"\n";
2468 is.
getline (first_line, static_cast<char> (ts.
eol2));
2470 if (! first_line.empty ()
2471 && first_line[first_line.length () - 1] == ts.
eol1)
2472 first_line.resize (first_line.length () - 1);
2474 std::istringstream strstr (first_line);
2481 int max_empty = 1000;
2487 bool already_skipped_delim =
false;
2490 bool progress =
false;
2507 already_skipped_delim =
true;
2515 if (val.imag () == 0)
2520 output_container.push_back (val_type);
2522 if (! already_skipped_delim)
2531 output_container.pop_front ();
2541 : who (who_arg), buf (), whitespace_table (), delim_table (),
2542 delims (), comment_style (), comment_len (0), comment_char (-2),
2543 buffer_size (0), date_locale (), inf_nan (
init_inf_nan ()),
2544 empty_value (
octave::numeric_limits<
double>::
NaN ()), exp_chars (
"edED"),
2545 header_lines (0), treat_as_empty (), treat_as_empty_len (0),
2546 whitespace (
" \b\t"), eol1 (
'\r'), eol2 (
'\n'),
2547 return_on_error (1), collect_output (
false),
2548 multiple_delims_as_one (
false), default_exp (true),
2549 numeric_delim (
false), lines (0)
2567 std::ios::iostate
state = isp.rdstate ();
2570 isp.setstate (state);
2582 error (
"%s: invalid format specified", who.c_str ());
2585 error (
"%s: no valid format conversion specifiers", who.c_str ());
2590 getline (isp, dummy, static_cast<char> (
eol2));
2602 else if (ntimes > 0)
2606 buf_size =
std::max (buf_size, ntimes);
2611 max_lookahead, buf_size);
2633 done_after = fmt_list.
numel () + 1;
2638 done_after = fmt_list.
out_buf ().size () + 1;
2640 std::list<octave_value> out = fmt_list.
out_buf ();
2648 bool merge_with_prev[fmt_list.
numel ()];
2653 for (std::list<octave_value>::iterator col = out.begin ();
2654 col != out.end (); col++)
2656 if (col->type_id () == prev_type
2658 merge_with_prev [conv++] =
true;
2660 merge_with_prev [conv++] =
false;
2662 prev_type = col->type_id ();
2669 error (
"%s: No conversions specified", who.c_str ());
2674 for (; row < ntimes || ntimes == -1; row++)
2676 if (row == 0 || row >= size)
2679 for (std::list<octave_value>::iterator col = out.begin ();
2680 col != out.end (); col++)
2681 *col = (*col).resize (
dim_vector (size, 1), 0);
2687 if ((err & ~1) > 0 || ! is || (
lines >= ntimes && ntimes > -1))
2693 error (
"%s: Read error in field %d of row %d", who.c_str (),
2694 done_after + 1, row + 1);
2697 bool uneven_columns =
false;
2699 uneven_columns =
true;
2700 else if (isp.eof ())
2703 isp.seekg (-1, std::ios_base::end);
2704 int last_char = isp.get ();
2705 isp.setstate (isp.eofbit);
2706 uneven_columns = (last_char !=
eol1 && last_char !=
eol2);
2715 done_after = out.size () + 1;
2717 int valid_rows = (row == ntimes) ? ntimes
2718 : (((err & 1) && (err & 8)) ? row : row+1);
2726 for (std::list<octave_value>::iterator col = out.begin ();
2727 col != out.end (); col++, i++)
2730 if (i == done_after && uneven_columns)
2746 for (std::list<octave_value>::iterator col = out.begin ();
2747 col != out.end (); col++)
2749 if (! merge_with_prev [conv++])
2751 if (prev_type != -1)
2759 prev_type = col->type_id ();
2763 ra_idx(1) = group_size++;
2783 unsigned int width_left = fmt.
width;
2787 int ch = is.
peek ();
2808 if (ch >=
'0' && ch <=
'9')
2810 while (width_left-- && is && (ch = is.
get ()) >=
'0' && ch <=
'9')
2811 retval = retval * 10 + (ch -
'0');
2816 if (ch ==
'.' && width_left)
2818 double multiplier = 1;
2819 int precision = fmt.
prec;
2825 if (precision == -1)
2831 for (i = 0; i < precision; i++)
2833 if (width_left-- && is && (ch = is.
get ()) >=
'0' && ch <=
'9')
2834 retval += (ch -
'0') * (multiplier *= 0.1);
2843 if ((i == precision || ! width_left) && (ch = is.
get ()) >=
'5'
2845 retval += multiplier;
2852 while (width_left-- && is && (ch = is.
get ()) >=
'0' && ch <=
'9')
2859 bool used_exp =
false;
2860 if (valid && width_left > 1 &&
exp_chars.find (ch) != std::string::npos)
2862 int ch1 = is.
peek ();
2863 if (ch1 ==
'-' || ch1 ==
'+' || (ch1 >=
'0' && ch1 <=
'9'))
2875 else if (ch1 ==
'-')
2883 while (width_left-- && is && (ch = is.
get ()) >=
'0' && ch <=
'9')
2885 exp = exp*10 + ch -
'0';
2889 if (ch != std::istream::traits_type::eof () && width_left)
2892 double multiplier =
pown (10, exp);
2894 retval *= multiplier;
2896 retval /= multiplier;
2902 if (! used_exp && ch != std::istream::traits_type::eof () && width_left)
2906 if (! valid && width_left >= 3)
2922 if (! valid && width_left >= 3)
2942 return retval * sign;
2955 bool as_empty =
false;
2958 int ch = is.
peek ();
2959 if (ch ==
'+' || ch ==
'-')
2962 int ch2 = is.
peek ();
2963 if (ch2 ==
'i' || ch2 ==
'j')
2968 if (is.
peek () ==
'n')
2970 char *pos = is.
tellg ();
2989 im = (ch ==
'+') ? value : -value;
2997 char *pos = is.
tellg ();
3027 char *look = is.
read (&look_buf[0], look_buf.size (), pos);
3036 if (!
strncmp (s.c_str (), look, s.size ()))
3040 is.
read (&look_buf[0], s.size (), pos);
3047 if (! is.
eof () && ! as_empty)
3052 if (ch ==
'i' || ch ==
'j')
3058 else if (ch ==
'+' || ch ==
'-')
3069 if (is.
peek () ==
'i' || is.
peek () ==
'j')
3094 int c1 = std::istream::traits_type::eof ();
3095 std::ostringstream obuf;
3097 while (is && ((c1 = (is && ! is.
eof ())
3099 : std::istream::traits_type::eof ())
3100 != std::istream::traits_type::eof ())
3101 && pattern.find (c1) == std::string::npos)
3102 obuf << static_cast<char> (c1);
3106 if (c1 != std::istream::traits_type::eof ())
3126 retval = retval +
next;
3128 int last = (! is.
eof ()
3129 ? is.
get_undelim () : std::istream::traits_type::eof ());
3131 if (last != std::istream::traits_type::eof ())
3133 retval = retval +
static_cast<char> (last);
3134 for (
int i = 0;
i < delimiters.
numel ();
i++)
3137 size_t start = (retval.length () > delim.length ()
3138 ? retval.length () - delim.length ()
3141 if (may_match == delim)
3144 retval = retval.substr (0, start);
3150 while (! done && is && ! is.
eof ());
3166 unsigned int width = fmt.
width;
3168 for (i = 0; i < width; i++)
3170 if (i+1 > val.length ())
3171 val = val + val +
' ';
3173 if (
is_delim (ch) || ch == std::istream::traits_type::eof ())
3181 val = val.substr (0, i);
3189 ends += tmp.substr (tmp.length () - 1);
3201 int c1 = std::istream::traits_type::eof ();
3202 std::ostringstream obuf;
3204 while (is && pattern.find (c1 = is.
get_undelim ()) != std::string::npos)
3205 obuf << static_cast<char> (c1);
3208 if (c1 != std::istream::traits_type::eof ())
3223 if (is.
peek () !=
'\"')
3231 while (is && is.
peek () ==
'\"')
3236 val = val +
"\"" + val1;
3249 val.resize (fmt.
width);
3251 for (
unsigned int i = 0; is &&
i < fmt.
width;
i++)
3254 if (ch != std::istream::traits_type::eof ())
3277 if (fmt.
type ==
'f' || fmt.
type ==
'n')
3362 if (fmt.
type ==
'd')
3375 if (fmt.
type ==
'd')
3436 std::list<octave_value>&
retval,
3440 std::list<octave_value>::iterator out = retval.begin ();
3441 bool no_conversions =
true;
3443 bool conversion_failed =
false;
3444 bool nothing_worked =
true;
3448 for (
size_t i = 0;
i < fmt_list.
numel ();
i++)
3450 bool this_conversion_failed =
false;
3459 warning (
"%s: conversion %c not yet implemented",
3460 who.c_str (), elem->
type);
3480 error (
"Unknown format element '%c'", elem->
type);
3486 no_conversions =
false;
3493 this_conversion_failed =
true;
3499 elem = fmt_list.
next ();
3500 char *pos = is.
tellg ();
3518 if (this_conversion_failed)
3520 if (is.
tellg () == pos && ! conversion_failed)
3524 conversion_failed =
true;
3527 this_conversion_failed =
false;
3529 else if (! done && !conversion_failed)
3530 nothing_worked =
false;
3536 return no_conversions
3537 + (is.
eof () ? 2 : 0)
3538 + (conversion_failed ? 4 : 0)
3539 + (nothing_worked ? 8 : 0);
3547 int last = args.
length ();
3551 error (
"%s: %d parameters given, but only %d values",
3552 who.c_str (), n-n/2, n/2);
3555 bool have_delims =
false;
3556 for (
int i = 0;
i < last;
i += 2)
3560 args(
i).type_name ().c_str (),
3562 std::transform (param.begin (), param.end (), param.begin (), ::tolower);
3564 if (param ==
"delimiter")
3566 bool invalid =
true;
3567 if (
args(
i+1).is_string ())
3572 if (
args(
i+1).is_sq_string ())
3575 else if (
args(
i+1).is_cell ())
3593 delim_len =
std::max (static_cast<int> (len), delim_len);
3598 error (
"%s: Delimiters must be either a string or cell array of strings",
3601 else if (param ==
"commentstyle")
3603 if (
args(
i+1).is_string ())
3608 else if (
args(
i+1).is_cell ())
3615 error (
"%s: CommentStyle must be either a string or cell array of one or two strings",
3619 error (
"%s: CommentStyle must be either a string or cell array of one or two strings",
3630 else if (param ==
"treatasempty")
3632 bool invalid =
false;
3633 if (
args(
i+1).is_string ())
3638 else if (
args(
i+1).is_cell ())
3652 error (
"%s: TreatAsEmpty must be either a string or cell array of one or two strings",
3657 else if (param ==
"collectoutput")
3659 collect_output =
args(
i+1).xbool_value (
"%s: CollectOutput must be logical or numeric", who.c_str ());
3661 else if (param ==
"emptyvalue")
3663 empty_value =
args(
i+1).xscalar_value (
"%s: EmptyValue must be numeric", who.c_str ());
3665 else if (param ==
"headerlines")
3667 header_lines =
args(
i+1).xscalar_value (
"%s: HeaderLines must be numeric", who.c_str ());
3669 else if (param ==
"bufsize")
3671 buffer_size =
args(
i+1).xscalar_value (
"%s: BufSize must be numeric", who.c_str ());
3673 else if (param ==
"multipledelimsasone")
3677 else if (param ==
"returnonerror")
3679 return_on_error =
args(
i+1).xbool_value (
"%s: ReturnOnError must be logical or numeric", who.c_str ());
3681 else if (param ==
"whitespace")
3683 whitespace =
args(
i+1).xstring_value (
"%s: Whitespace must be a character string", who.c_str ());
3685 else if (param ==
"expchars")
3687 exp_chars =
args(
i+1).xstring_value (
"%s: ExpChars must be a character string", who.c_str ());
3690 else if (param ==
"endofline")
3693 std::string s =
args(
i+1).xstring_value (
"%s: EndOfLine must be at most one character or '\\r\\n'", who.c_str ());
3694 if (
args(
i+1).is_sq_string ())
3696 int l = s.length ();
3703 eol1 = s.c_str ()[0];
3704 eol2 = s.c_str ()[1];
3712 error (
"%s: EndOfLine must be at most one character or '\\r\\n'",
3716 error (
"%s: unrecognized option '%s'", who.c_str (), param.c_str ());
3735 for (
unsigned int i = 0;
i < 256;
i++)
3741 for (
unsigned int i = 0;
i <
delims.length ();
i++)
3751 int c1 = std::istream::traits_type::eof ();
3752 bool found_comment =
false;
3756 found_comment =
false;
3758 while (is && (c1 = is.
get_undelim ()) != std::istream::traits_type::eof ()
3770 char *pos = is.
tellg ();
3778 found_comment =
true;
3797 std::string last = end_c.substr (end_c.size () - 1);
3805 may_match = may_match + dummy + last;
3806 if (may_match.length () > end_c.length ())
3808 size_t start = may_match.length () - end_c.length ();
3809 may_match = may_match.substr (start);
3812 while (may_match != end_c && is && ! is.
eof ());
3822 while (found_comment);
3824 if (c1 != std::istream::traits_type::eof ())
3835 bool case_sensitive)
const
3841 char *pos = is.
tellg ();
3844 char *look = is.
read (&tmp[0], tmp.size (), pos);
3851 int (*compare)(
const char *,
const char *,
size_t);
3852 compare = case_sensitive ?
strncmp : strncasecmp;
3854 for (i = 0; i < targets.
numel (); i++)
3857 if (! (*compare) (s.c_str (), look, s.size ()))
3859 is.
read (&tmp[0], s.size (), pos);
3864 if (i == targets.
numel ())
3889 != std::istream::traits_type::eof ())
3897 if (c1 != std::istream::traits_type::eof ())
3915 else if (c1 ==
eol2)
3926 != std::istream::traits_type::eof ())
3952 for (
unsigned int i = 0;
i < fmt.
width;
i++)
3955 if (ch != fmt.
text[
i])
3957 if (ch != std::istream::traits_type::eof ())
3978 errmsg = who +
": " + msg;
4008 if (octave::application::interactive () &&
file_number () == 0)
4009 ::error (
"%s: unable to read from stdin while running interactively",
4025 std::istream& is = *isp;
4027 std::ostringstream buf;
4034 while (is && (c = is.get ()) != std::istream::traits_type::eof ())
4041 if (! strip_newline)
4042 buf << static_cast<char> (
c);
4046 if (c != std::istream::traits_type::eof ())
4052 if (! strip_newline)
4053 buf << static_cast<char> (
c);
4063 if (! strip_newline)
4064 buf << static_cast<char> (
c);
4069 buf << static_cast<char> (
c);
4071 if (max_len > 0 && char_count == max_len)
4076 if (! is.eof () && char_count > 0)
4081 int disgusting_compatibility_hack = is.get ();
4083 is.putback (disgusting_compatibility_hack);
4086 if (is.good () || (is.eof () && char_count > 0))
4087 retval = buf.str ();
4092 if (is.eof () && char_count == 0)
4093 error (who,
"at end of file");
4095 error (who,
"read error");
4106 return do_gets (max_len, err,
true, who);
4113 return do_gets (max_len, err,
false, who);
4119 if (octave::application::interactive () &&
file_number () == 0)
4120 ::error (
"%s: unable to read from stdin while running interactively",
4136 std::istream& is = *isp;
4142 while (is && (c = is.get ()) != std::istream::traits_type::eof ())
4145 if (c ==
'\r' || (c ==
'\n' && lastc !=
'\r'))
4155 if (c ==
'\r' && is.peek () ==
'\n')
4161 error (who,
"read error");
4171 template <
typename T>
4180 is >> std::oct >> value >> std::dec;
4184 is >> std::hex >> value >> std::dec;
4189 int c1 = std::istream::traits_type::eof ();
4191 while (is && (c1 = is.get ()) != std::istream::traits_type::eof ()
4195 if (c1 != std::istream::traits_type::eof ())
4199 int c2 = is.peek ();
4201 if (c2 ==
'x' || c2 ==
'X')
4204 if (std::isxdigit (is.peek ()))
4205 is >> std::hex >> value >> std::dec;
4211 if (c2 ==
'0' || c2 ==
'1' || c2 ==
'2'
4212 || c2 ==
'3' || c2 ==
'4' || c2 ==
'5'
4213 || c2 ==
'6' || c2 ==
'7')
4214 is >> std::oct >> value >> std::dec;
4215 else if (c2 ==
'8' || c2 ==
'9')
4247 if ((is.rdstate () & std::ios::failbit) && value != T ())
4248 is.
clear (is.rdstate () & ~
std::ios::failbit);
4252 if (! (is.rdstate () & std::ios::failbit))
4258 template <
typename T>
4268 is.width (fmt.
width);
4271 std::istringstream ss (tmp);
4289 return is >> valptr;
4294 octave_scan<> (std::istream&
is,
const scanf_format_elt& fmt,
double* valptr)
4296 double& ref = *valptr;
4304 int c1 = std::istream::traits_type::eof ();
4306 while (is && (c1 = is.get ()) != std::istream::traits_type::eof ()
4310 if (c1 != std::istream::traits_type::eof ())
4314 ref = octave_read_value<double> (
is);
4327 template <
typename T>
4339 if (idx == max_size && ! discard)
4344 mval.
resize (nr, max_size / nr, 0.0);
4346 mval.
resize (max_size, 1, 0.0);
4354 data[idx++] = *(valptr);
4359 do_scanf_conv (std::istream&,
const scanf_format_elt&,
double*,
4363 #define DO_WHITESPACE_CONVERSION() \
4366 int c = std::istream::traits_type::eof (); \
4368 while (is && (c = is.get ()) != std::istream::traits_type::eof () \
4372 if (c != std::istream::traits_type::eof ()) \
4377 #define DO_LITERAL_CONVERSION() \
4380 int c = std::istream::traits_type::eof (); \
4382 int n = strlen (fmt); \
4385 while (i < n && is && (c = is.get ()) != std::istream::traits_type::eof ()) \
4387 if (c == static_cast<unsigned char> (fmt[i])) \
4400 is.setstate (std::ios::failbit); \
4404 #define DO_PCT_CONVERSION() \
4407 int c = is.get (); \
4409 if (c != std::istream::traits_type::eof ()) \
4414 is.setstate (std::ios::failbit); \
4418 is.setstate (std::ios::failbit); \
4422 #define BEGIN_C_CONVERSION() \
4423 is.unsetf (std::ios::skipws); \
4425 int width = elt->width ? elt->width : 1; \
4427 std::string tmp (width, '\0'); \
4429 int c = std::istream::traits_type::eof (); \
4432 while (is && n < width \
4433 && (c = is.get ()) != std::istream::traits_type::eof ()) \
4434 tmp[n++] = static_cast<char> (c); \
4436 if (n > 0 && c == std::istream::traits_type::eof ()) \
4443 #define BEGIN_S_CONVERSION() \
4444 int width = elt->width; \
4452 tmp = std::string (width, '\0'); \
4454 int c = std::istream::traits_type::eof (); \
4458 while (is && (c = is.get ()) != std::istream::traits_type::eof ()) \
4460 if (! isspace (c)) \
4462 tmp[n++] = static_cast<char> (c); \
4467 while (is && n < width \
4468 && (c = is.get ()) != std::istream::traits_type::eof ()) \
4476 tmp[n++] = static_cast<char> (c); \
4479 if (n > 0 && c == std::istream::traits_type::eof ()) \
4486 is >> std::ws >> tmp; \
4492 #define BEGIN_CHAR_CLASS_CONVERSION() \
4493 int width = elt->width; \
4500 width = std::numeric_limits<int>::max (); \
4502 std::ostringstream buf; \
4504 std::string char_class = elt->char_class; \
4506 int c = std::istream::traits_type::eof (); \
4508 if (elt->type == '[') \
4510 int chars_read = 0; \
4511 while (is && chars_read++ < width \
4512 && (c = is.get ()) != std::istream::traits_type::eof () \
4513 && char_class.find (c) != std::string::npos) \
4514 buf << static_cast<char> (c); \
4518 int chars_read = 0; \
4519 while (is && chars_read++ < width \
4520 && (c = is.get ()) != std::istream::traits_type::eof () \
4521 && char_class.find (c) == std::string::npos) \
4522 buf << static_cast<char> (c); \
4525 if (width == std::numeric_limits<int>::max () \
4526 && c != std::istream::traits_type::eof ()) \
4532 is.setstate (std::ios::failbit); \
4533 else if (c == std::istream::traits_type::eof ()) \
4539 #define FINISH_CHARACTER_CONVERSION() \
4542 width = tmp.length (); \
4550 conversion_count++; \
4554 if (data_index == max_size) \
4558 if (all_char_conv) \
4560 if (one_elt_size_spec) \
4561 mval.resize (1, max_size, 0.0); \
4563 mval.resize (nr, max_size / nr, 0.0); \
4565 panic_impossible (); \
4568 mval.resize (nr, max_size / nr, 0.0); \
4570 mval.resize (max_size, 1, 0.0); \
4572 data = mval.fortran_vec (); \
4575 data[data_index++] = tmp[i++]; \
4585 bool one_elt_size_spec,
4589 if (octave::application::interactive () &&
file_number () == 0)
4590 ::error (
"%s: unable to read from stdin while running interactively",
4595 conversion_count = 0;
4601 if (nr == 0 || nc == 0)
4603 if (one_elt_size_spec)
4606 return Matrix (nr, nc, 0.0);
4625 if (one_elt_size_spec)
4628 mval.
resize (1, max_size, 0.0);
4637 mval.
resize (nr, nc, 0.0);
4638 max_size = max_conv = nr * nc;
4642 mval.
resize (nr, 32, 0.0);
4654 mval.
resize (nr, nc, 0.0);
4656 max_conv = max_size;
4661 mval.
resize (nr, 32, 0.0);
4668 mval.
resize (32, 1, 0.0);
4676 std::istream& is = *isp;
4678 const scanf_format_elt *elt = fmt_list.
first ();
4680 std::ios::fmtflags flags = is.flags ();
4695 || elt->
type ==
'%')
4696 && max_conv > 0 && conversion_count == max_conv))
4703 if (all_char_conv && one_elt_size_spec)
4706 final_nc = data_index;
4711 final_nc = (data_index - 1) / nr + 1;
4716 else if (data_index == max_size)
4722 if (one_elt_size_spec)
4723 mval.
resize (1, max_size, 0.0);
4725 mval.
resize (nr, max_size / nr, 0.0);
4730 mval.
resize (nr, max_size / nr, 0.0);
4732 mval.
resize (max_size, 1, 0.0);
4737 const char *fmt = elt->
text;
4763 data_index, conversion_count,
4764 nr, max_size, discard);
4772 data_index, conversion_count,
4773 nr, max_size, discard);
4781 data_index, conversion_count,
4782 nr, max_size, discard);
4789 case 'o':
case 'u':
case 'x':
4797 data_index, conversion_count,
4798 nr, max_size, discard);
4806 data_index, conversion_count,
4807 nr, max_size, discard);
4815 data_index, conversion_count,
4816 nr, max_size, discard);
4823 case 'e':
case 'f':
case 'g':
4828 data_index, conversion_count,
4829 nr, max_size, discard);
4860 error (
"%s: unsupported format specifier", who.c_str ());
4864 error (
"%s: internal format error", who.c_str ());
4876 if (one_elt_size_spec)
4879 final_nc = data_index;
4881 else if (data_index > nr)
4884 final_nc = (data_index - 1) / nr + 1;
4888 final_nr = data_index;
4894 if (data_index > nr)
4897 final_nc = (data_index - 1) / nr + 1;
4901 final_nr = data_index;
4907 final_nr = data_index;
4913 if (is.rdstate () & std::ios::failbit)
4914 is.clear (is.rdstate () & (~
std::ios::failbit));
4917 if (octave::application::interactive ()
4918 && ! octave::application::forced_interactive ()
4919 &&
name () ==
"stdin")
4925 do_gets (-1, err,
false, who);
4933 error (
"%s: internal format error", who.c_str ());
4937 if (nconv == 0 && ++trips == num_fmt_elts)
4939 if (all_char_conv && one_elt_size_spec)
4942 final_nc = data_index;
4947 final_nc = (data_index - 1) / nr + 1;
4958 elt = fmt_list.
next (nconv > 0
4960 || conversion_count < max_conv));
4967 mval.
resize (final_nr, final_nc, 0.0);
4972 retval = retval.convert_to_str (
false,
true);
4985 conversion_count = 0;
4996 ::
error (
"%s: invalid format specified", who.c_str ());
5001 bool one_elt_size_spec;
5003 get_size (size, nr, nc, one_elt_size_spec, who);
5005 retval =
do_scanf (fmt_list, nr, nc, one_elt_size_spec,
5006 conversion_count, who);
5023 std::istream& is = *isp;
5025 std::ios::fmtflags flags = is.flags ();
5029 const char *fmt = elt->
text;
5066 case 'o':
case 'u':
case 'x':
5080 case 'e':
case 'f':
case 'g':
5134 error (
"%s: unsupported format specifier", who.c_str ());
5138 error (
"%s: internal format error", who.c_str ());
5143 if (
ok () && is.fail ())
5145 error (
"%s: read error", who.c_str ());
5149 if (octave::application::interactive ()
5150 && ! octave::application::forced_interactive ()
5151 &&
name () ==
"stdin")
5155 do_gets (-1, err,
false, who);
5173 std::istream& is = *isp;
5180 ::error (
"%s: invalid format specified", who.c_str ());
5188 const scanf_format_elt *elt = fmt_list.
first ();
5210 elt = fmt_list.
next (nconv > 0);
5214 retval(nconv) = num_values;
5222 if (
ok () && len > nconv)
5226 elt = fmt_list.
next ();
5243 if (octave::application::interactive () &&
file_number () == 0)
5244 ::error (
"%s: unable to read from stdin while running interactively",
5257 retval = scanner.
scan (*isp, fmt, ntimes, options, read_count);
5294 :
values (args), val_idx (0), elt_idx (0),
5313 int int_value (
void);
5315 operator bool ()
const {
return (curr_state == ok); }
5371 retval = sval.substr (
elt_idx);
5384 for (; idx <
n_elts; idx++)
5386 double dval =
val(idx);
5399 sval[
i] =
val(elt_idx++);
5411 if (type ==
'c' && ! retval.
is_string ())
5416 retval =
static_cast<char> (dval);
5436 if (
elt_idx == 0 && (type ==
's' || type ==
'c'))
5470 template <
typename T>
5492 ::error (
"%s: internal error handling format", who.c_str ());
5505 ::error (
"%s: internal error handling format", who.c_str ());
5509 bool left = flags.find (
'-') != std::string::npos;
5511 size_t len = arg.length ();
5513 size_t fw = nsa > 0 ? sa_1 : (elt->
fw == -1 ? len : elt->
fw);
5514 size_t prec = nsa > 1 ? sa_2 : (elt->
prec == -1 ? len : elt->
prec);
5516 os << std::setw (fw)
5518 << (prec < len ? arg.substr (0, prec) :
arg);
5520 return len > fw ? len : fw;
5545 if (ival.
value () <= limit)
5574 return ov_is_ge_zero.
is_true ();
5594 tfmt.replace (tfmt.rfind (elt->
type), 1,
"g");
5602 int nsa,
int sa_1,
int sa_2,
5608 const char *fmt = elt->
text;
5615 std::string::size_type i1, i2;
5617 tfmt.replace ((i1 = tfmt.rfind (elt->
type)), 1, 1,
's');
5619 if ((i2 = tfmt.rfind (
'.')) != std::string::npos && i2 < i1)
5621 tfmt.erase (i2, i1-i2);
5622 if (elt->
prec == -2)
5629 if (elt->
flags.find (
'+') != std::string::npos)
5630 tval = (dval < 0 ?
"-Inf" :
"+Inf");
5632 tval = (dval < 0 ?
"-Inf" :
"Inf");
5636 if (elt->
flags.find (
'+') != std::string::npos)
5642 retval +=
do_printf_conv (os, tfmt.c_str (), nsa, sa_1, sa_2, tval, who);
5647 =
sizeof (long) ==
sizeof (int64_t) ?
"l" :
"ll";
5653 case 'd':
case 'i':
case 'c':
5660 tfmt.replace (tfmt.rfind (type), 1, llmod +
type);
5663 tval.
value (), who);
5672 sa_1, sa_2, dval, who);
5676 case 'o':
case 'x':
case 'X':
case 'u':
5683 tfmt.replace (tfmt.rfind (type), 1, llmod +
type);
5686 tval.
value (), who);
5695 sa_1, sa_2, dval, who);
5699 case 'f':
case 'e':
case 'E':
5711 error (
"%s: invalid format specifier", who.c_str ());
5735 std::ostream& os = *osp;
5746 ::error (
"%s: internal error handling format", who.c_str ());
5749 int nsa = (elt->
fw == -2) + (elt->
prec == -2);
5772 if (elt->
type ==
'%')
5777 else if (elt->
args == 0 && elt->
text)
5782 else if (elt->
type ==
's' || elt->
type ==
'c')
5815 error (
"%s: write error", who.c_str ());
5819 elt = fmt_list.
next (nconv > 0 && ! val_cache.
exhausted ());
5837 ::
error (
"%s: invalid format specified", who.c_str ());
5853 std::ostream& os = *osp;
5858 error (
"%s: write error", who.c_str ());
5872 error (
"%s: write error", who.c_str ());
5884 err_num =
fail ? -1 : 0;
5955 retval =
rep->
getl (max_len, err, who);
5974 if (conv_err || max_len < 0)
5977 ::error (
"%s: invalid maximum length specified", who.c_str ());
5981 return getl (max_len, err, who);
5990 retval =
rep->
gets (max_len, err, who);
6009 if (conv_err || max_len < 0)
6012 ::error (
"%s: invalid maximum length specified", who.c_str ());
6016 return gets (max_len, err, who);
6025 retval =
rep->
skipl (count, err, who);
6049 if (conv_err || count < 0)
6052 ::error (
"%s: invalid number of lines specified", who.c_str ());
6057 return skipl (count, err, who);
6070 off_t orig_pos =
rep->
tell ();
6089 status =
rep->
seek (offset, origin);
6094 off_t desired_pos =
rep->
tell ();
6098 if (desired_pos > eof_pos || desired_pos < 0)
6129 off_t xoffset = val.
value ();
6139 if (xorigin ==
"bof")
6141 else if (xorigin ==
"cof")
6143 else if (xorigin ==
"eof")
6156 else if (xorigin == 0)
6158 else if (xorigin == 1)
6166 ::error (
"fseek: invalid value for origin");
6168 retval =
seek (xoffset, origin);
6172 error (
"fseek: failed to seek to requested position");
6214 template <
typename T>
6228 template <
typename T>
6242 template <
typename SRC_T,
typename DST_T>
6248 bool do_float_fmt_conv,
bool do_NA_conv,
6251 typedef typename DST_T::element_type dst_elt_type;
6255 dst_elt_type *conv_data = conv.fortran_vec ();
6259 for (std::list<void *>::const_iterator it = input_buf_list.begin ();
6260 it != input_buf_list.end (); it++)
6262 SRC_T *data =
static_cast<SRC_T *
> (*it);
6264 if (swap || do_float_fmt_conv)
6272 swap_bytes<sizeof (SRC_T)> (&data[
i]);
6273 else if (do_float_fmt_conv)
6278 dst_elt_type
tmp (data[i]);
6292 swap_bytes<sizeof (SRC_T)> (&data[
i]);
6293 else if (do_float_fmt_conv)
6298 conv_data[j] = data[
i];
6309 dst_elt_type
tmp (data[
i]);
6321 conv_data[j] = data[
i];
6328 input_buf_list.clear ();
6331 conv_data[
i] = dst_elt_type (0);
6339 bool swap,
bool do_float_fmt_conv,
bool do_NA_conv,
6342 #define TABLE_ELT(T, U, V, W) \
6343 conv_fptr_table[oct_data_conv::T][oct_data_conv::U] = convert_and_copy<V, W>
6345 #define FILL_TABLE_ROW(T, V) \
6346 TABLE_ELT (T, dt_int8, V, int8NDArray); \
6347 TABLE_ELT (T, dt_uint8, V, uint8NDArray); \
6348 TABLE_ELT (T, dt_int16, V, int16NDArray); \
6349 TABLE_ELT (T, dt_uint16, V, uint16NDArray); \
6350 TABLE_ELT (T, dt_int32, V, int32NDArray); \
6351 TABLE_ELT (T, dt_uint32, V, uint32NDArray); \
6352 TABLE_ELT (T, dt_int64, V, int64NDArray); \
6353 TABLE_ELT (T, dt_uint64, V, uint64NDArray); \
6354 TABLE_ELT (T, dt_single, V, FloatNDArray); \
6355 TABLE_ELT (T, dt_double, V, NDArray); \
6356 TABLE_ELT (T, dt_char, V, charNDArray); \
6357 TABLE_ELT (T, dt_schar, V, charNDArray); \
6358 TABLE_ELT (T, dt_uchar, V, charNDArray); \
6359 TABLE_ELT (T, dt_logical, V, boolNDArray);
6372 static bool initialized =
false;
6381 for (
int j = 0; j < 14; j++)
6382 conv_fptr_table[
i][j] = 0;
6418 switch (output_type)
6437 retval =
fptr (input_buf_list, input_buf_elts, elts_read,
6438 nr, nc, swap, do_float_fmt_conv, do_NA_conv, ffmt);
6443 ::error (
"read: invalid type specification");
6461 bool one_elt_size_spec =
false;
6473 size_t char_count = 0;
6475 ptrdiff_t tmp_count = 0;
6479 get_size (size, nr, nc, one_elt_size_spec,
"fread");
6481 catch (
const octave::execution_exception&)
6488 if (one_elt_size_spec)
6511 if (nr == 0 || nc == 0)
6520 bool read_to_eof = elts_to_read < 0;
6527 input_buf_elts = 1024 * 1024;
6529 input_buf_elts = elts_to_read;
6532 input_buf_elts = block_size;
6537 ptrdiff_t input_buf_size
6538 =
static_cast<ptrdiff_t
> (input_buf_elts) * input_elt_size;
6540 assert (input_buf_size >= 0);
6547 error (
"fread: invalid input stream");
6550 std::istream& is = *isp;
6552 std::list <void *> input_buf_list;
6554 while (is && ! is.eof ()
6555 && (read_to_eof || tmp_count < elts_to_read))
6561 if (remaining_elts < input_buf_elts)
6562 input_buf_size = remaining_elts * input_elt_size;
6565 char *input_buf =
new char [input_buf_size];
6567 is.read (input_buf, input_buf_size);
6569 size_t gcount = is.gcount ();
6571 char_count += gcount;
6577 input_buf_list.push_back (input_buf);
6579 if (is && skip != 0 && nel == block_size)
6584 off_t orig_pos =
tell ();
6588 off_t eof_pos =
tell ();
6594 off_t remaining = eof_pos - orig_pos;
6596 if (remaining < skip)
6610 nc = tmp_count / nr;
6612 if (tmp_count % nr != 0)
6618 else if (tmp_count == 0)
6623 else if (tmp_count != nr * nc)
6625 if (tmp_count % nr != 0)
6626 nc = tmp_count / nr + 1;
6628 nc = tmp_count / nr;
6635 error (
"fread: number of elements read exceeds max index size");
6639 retval =
finalize_read (input_buf_list, input_buf_elts, count,
6640 nr, nc, input_type, output_type, ffmt);
6664 error (
"fwrite: write error");
6672 template <
typename T,
typename V>
6676 const T *tt_data =
static_cast<const T *
> (data);
6678 V *vt_data =
static_cast<V *
> (conv_data);
6681 vt_data[
i] = tt_data[
i];
6684 template <
typename T,
typename V>
6689 typedef typename V::val_type val_type;
6691 val_type *vt_data =
static_cast<val_type *
> (conv_data);
6698 vt_data[
i] = val.value ();
6701 swap_bytes<sizeof (val_type)> (&vt_data[
i]);
6705 template <
typename T>
6712 template <
typename T>
6719 template <
typename T>
6738 switch (output_type)
6741 convert_chars<ult_elt_type, char> (data, conv_data, n_elts);
6745 convert_chars<ult_elt_type, signed char> (data, conv_data, n_elts);
6749 convert_chars<ult_elt_type, unsigned char> (data, conv_data, n_elts);
6753 convert_ints<T, octave_int8> (data, conv_data, n_elts,
swap);
6757 convert_ints<T, octave_uint8> (data, conv_data, n_elts,
swap);
6761 convert_ints<T, octave_int16> (data, conv_data, n_elts,
swap);
6765 convert_ints<T, octave_uint16> (data, conv_data, n_elts,
swap);
6769 convert_ints<T, octave_int32> (data, conv_data, n_elts,
swap);
6773 convert_ints<T, octave_uint32> (data, conv_data, n_elts,
swap);
6777 convert_ints<T, octave_int64> (data, conv_data, n_elts,
swap);
6781 convert_ints<T, octave_uint64> (data, conv_data, n_elts,
swap);
6786 float *vt_data =
static_cast<float *
> (conv_data);
6790 vt_data[
i] = data[
i];
6792 if (do_float_conversion)
6800 double *vt_data =
static_cast<double *
> (conv_data);
6804 vt_data[
i] = data[
i];
6806 if (do_float_conversion)
6813 ::error (
"write: invalid type specification");
6822 bool status =
false;
6828 std::ostream& os = *osp;
6832 os.write (static_cast<const char *> (data), nbytes);
6845 bool status =
false;
6852 std::ostream& os = *osp;
6856 off_t orig_pos =
tell ();
6860 off_t eof_pos =
tell ();
6865 size_t remaining = eof_pos - orig_pos;
6867 if (remaining < skip)
6872 unsigned char zero = 0;
6873 for (
size_t j = 0; j < skip - remaining; j++)
6874 os.write (reinterpret_cast<const char *> (&zero), 1);
6885 template <
typename T>
6899 bool do_data_conversion = (swap || ! is_equivalent_type<T> (output_type)
6907 chunk_size = block_size;
6908 else if (do_data_conversion)
6909 chunk_size = 1024 * 1024;
6915 const T *pdata = data.
data ();
6927 if (chunk_size > remaining_nel)
6928 chunk_size = remaining_nel;
6930 bool status =
false;
6932 if (do_data_conversion)
6939 status =
convert_data (&pdata[i], conv_data, chunk_size,
6940 output_type, flt_fmt);
6946 status =
write_bytes (pdata,
sizeof (T) * chunk_size);
6957 #define INSTANTIATE_WRITE(T) \
6960 octave_stream::write (const Array<T>& data, octave_idx_type block_size, \
6961 oct_data_conv::data_type output_type, \
6962 octave_idx_type skip, \
6963 octave::mach_info::float_format flt_fmt)
6982 #if defined (OCTAVE_HAVE_OVERLOAD_CHAR_INT8_TYPES)
6995 retval =
rep->
scanf (fmt, size, count, who);
7013 retval =
scanf (sfmt, size, count, who);
7018 error (who +
": format must be a string");
7047 retval =
oscanf (sfmt, who);
7052 error (who +
": format must be a string");
7093 retval =
printf (sfmt, args, who);
7098 error (who +
": format must be a string");
7125 retval =
puts (s, who);
7130 error (who +
": argument must be a string");
7153 retval =
rep->
error (clear, err_num);
7195 std::ios::openmode in_mode =
static_cast<std::ios::openmode
> (
mode);
7197 if (in_mode == std::ios::in)
7199 else if (in_mode == std::ios::out
7202 else if (in_mode == (std::ios::out | std::ios::app))
7204 else if (in_mode == (std::ios::in | std::ios::out))
7208 else if (in_mode == (std::ios::in | std::ios::out | std::ios::ate))
7210 else if (in_mode == (std::ios::in | std::ios::binary))
7212 else if (in_mode == (std::ios::out | std::ios::binary)
7215 else if (in_mode == (std::ios::out | std::ios::app | std::ios::binary))
7217 else if (in_mode == (std::ios::in | std::ios::out | std::ios::binary))
7220 | std::ios::binary))
7222 else if (in_mode == (std::ios::in | std::ios::out | std::ios::ate
7223 | std::ios::binary))
7245 ::error (
"unable to create stream list object!");
7325 if (stream_number == -1)
7326 return stream_number;
7341 if (
list.size () >=
list.max_size ())
7342 ::
error (
"could not create file id");
7344 list[stream_number] = os;
7346 return stream_number;
7349 OCTAVE_NORETURN
static
7354 ::
error (
"invalid stream number = %d", fid);
7356 ::error (
"%s: invalid stream number = %d", who.c_str (), fid);
7371 ostrl_map::const_iterator iter =
list.find (fid);
7373 if (iter ==
list.end ())
7376 retval = iter->second;
7399 ostrl_map::iterator iter =
list.find (fid);
7401 if (iter ==
list.end ())
7448 for (ostrl_map::iterator iter =
list.begin (); iter !=
list.end (); )
7450 int fid = iter->first;
7460 std::transform (name.begin (), name.end (), name.begin (), tolower);
7463 if (name.find (
"gnuplot") != std::string::npos)
7474 list.erase (iter++);
7486 ::
error (
"invalid file id = %d", fid);
7505 ::error (
"file id must be a file object or integer value");
7513 std::ostringstream buf;
7516 <<
" number mode arch name\n"
7517 <<
" ------ ---- ---- ----\n";
7519 for (ostrl_map::const_iterator
p =
list.begin ();
p !=
list.end ();
p++)
7525 << std::setw (4) <<
p->first <<
" "
7527 << std::resetiosflags (std::ios::adjustfield)
7535 << os.
name () <<
"\n";
7550 for (ostrl_map::const_iterator
p =
list.begin ();
p !=
list.end ();
p++)
7553 if (
p->first > 2 &&
p->second)
7554 retval(0,num_open++) =
p->first;
7557 retval.
resize ((num_open > 0), num_open);
7571 for (ostrl_map::const_iterator
p =
list.begin ();
p !=
list.end ();
p++)
7578 if (os && os.
name () ==
nm)
7593 ::error (
"file id must be a file object, std::string, or integer value");
void warning_with_id(const char *id, const char *fmt,...)
int scan_caret(delimited_stream &is, const std::string &pattern, std::string &val) const
octave_value(* conv_fptr)(std::list< void * > &input_buf_list, octave_idx_type input_buf_elts, octave_idx_type elts_read, octave_idx_type nr, octave_idx_type nc, bool swap, bool do_float_fmt_conv, bool do_NA_conv, octave::mach_info::float_format from_flt_fmt)
bool is_object(void) const
void invalid_operation(const std::string &who, const char *rw)
std::list< octave_value > out_buf(void) const
octave_int64 xint64_scalar_value(const char *fmt,...) const
bool multiple_delims_as_one
bool skip_bytes(size_t n_elts)
bool is_empty(void) const
static OCTAVE_NORETURN void err_invalid_file_id(int fid, const std::string &who)
#define DO_LITERAL_CONVERSION()
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
#define DO_PCT_CONVERSION()
Octave interface to the compression and uncompression libraries.
void scan_cstring(delimited_stream &is, const textscan_format_elt &fmt, std::string &val) const
static std::string expand_char_class(const std::string &s)
bool is_real_type(void) const
std::list< octave_value > output_container
bool isspace(unsigned int ch) const
void scan_one(delimited_stream &is, const textscan_format_elt &fmt, octave_value &ov, Array< octave_idx_type > row)
~textscan_format_list(void)
double __lo_ieee_replace_old_NA(double x)
void scan_string(delimited_stream &is, const textscan_format_elt &fmt, std::string &val) const
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value reshape(const dim_vector &dv) const
void parse_options(const octave_value_list &args, textscan_format_list &fmt_list)
octave_value do_cat_op(const octave_value &v1, const octave_value &v2, const Array< octave_idx_type > &ra_idx)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
virtual off_t tell(void)=0
void setstate(std::ios_base::iostate m)
octave_idx_type buffer_size
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, octave::mach_info::float_format flt_fmt)
octave::mach_info::float_format float_format(void) const
int do_remove(int fid, const std::string &who="")
static string_vector get_info(int fid)
octave_idx_type numel(void) const
Number of elements in the array.
void seekg(char *old_idx)
identity matrix If supplied two scalar respectively For allows like xample val
static octave_idx_type nn
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
std::string read_until(delimited_stream &is, const Cell &delimiters, const std::string &ends) const
octave_idx_type length(void) const
OCTINTERP_API std::string undo_string_escapes(const std::string &s)
static octave_stream_list * instance
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
std::string gets(octave_idx_type max_len, bool &err, const std::string &who)
bool is_scalar_type(void) const
int seek(off_t offset, int origin)
void do_clear(bool flush=true)
bool is_defined(void) const
textscan(const std::string &who_arg="textscan")
static double pown(double x, unsigned int n)
virtual std::istream * input_stream(void)
static std::string switch_to_g_format(const printf_format_elt *elt)
void clear(std::ios_base::iostate m=(std::ios_base::eofbit &~std::ios_base::eofbit))
octave_int< T > mod(const octave_int< T > &x, const octave_int< T > &y)
static char * strsave(const char *s)
int finish_conversion(const std::string &s, size_t &i, size_t n, unsigned int &width, int &prec, int &bitwidth, octave_value &val_type, bool discard, char &type)
void add_elt_to_list(unsigned int width, int prec, int bitwidth, octave_value val_type, bool discard, char type, const std::string &char_class=std::string())
void error(const char *fmt,...)
textscan_format_list(const std::string &fmt=std::string(), const std::string &who="textscan")
octave_value get_next_value(char type=0)
static bool instance_ok(void)
virtual std::string name(void) const =0
octave_value scanf(const std::string &fmt, const Array< double > &size, octave_idx_type &count, const std::string &who)
textscan_format_elt(const textscan_format_elt &e)
size_type size(const size_type d) const
Size of the specified dimension.
off_t skipl(off_t count, bool &err, const std::string &who)
printf_value_cache(const octave_value_list &args, const std::string &who)
octave::mach_info::float_format flt_fmt
virtual bool fast_elem_insert(octave_idx_type n, const octave_value &x)
octave_value do_scanf(scanf_format_list &fmt_list, octave_idx_type nr, octave_idx_type nc, bool one_elt_size_spec, octave_idx_type &count, const std::string &who)
octave_value isinf(void) const
bool whitespace_delim(void) const
bool is_delim(unsigned char ch) const
double scalar_value(bool frc_str_conv=false) const
#define BEGIN_S_CONVERSION()
#define DO_WHITESPACE_CONVERSION()
int do_get_file_number(const octave_value &fid) const
const octave_value_list values
in this the arguments are accumulated from left to right
std::istream * input_stream(void)
when function syntax is used
static size_t do_printf_string(std::ostream &os, const printf_format_elt *elt, int nsa, int sa_1, int sa_2, const std::string &arg, const std::string &who)
static bool ok_for_signed_int_conv(const octave_value &val)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
std::streampos buf_in_file
virtual std::ostream * output_stream(void)
cell array If invoked with two or more scalar integer or a vector of integer values
int printf(const std::string &fmt, const octave_value_list &args, const std::string &who)
std::deque< textscan_format_elt * > fmt_elts
const textscan_format_elt * current(void) const
void scan_qstring(delimited_stream &is, const textscan_format_elt &fmt, std::string &val)
void do_double_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt)
static int insert(octave_stream &os)
static Matrix null(const Matrix &A, octave_idx_type &rank)
std::istream & octave_scan_1(std::istream &is, const scanf_format_elt &fmt, T *valptr)
std::string parse_char_class(const std::string &pattern) const
std::istream & octave_scan(std::istream &is, const scanf_format_elt &fmt, T *valptr)
int skip_delim(delimited_stream &is)
int scan_bracket(delimited_stream &is, const std::string &pattern, std::string &val) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
int write(octave_stream &os, int block_size, oct_data_conv::data_type output_type, int skip, octave::mach_info::float_format flt_fmt) const
int read_format_once(delimited_stream &isp, textscan_format_list &fmt_list, std::list< octave_value > &retval, Array< octave_idx_type > row, int &done_after)
static bool words_big_endian(void)
octave_idx_type numel(const octave_value_list &idx)
static int convert_to_valid_int(const octave_value &tc, int &conv_err)
octave::mach_info::float_format float_format(void) const
std::string string_value(bool force=false) const
int skip_whitespace(delimited_stream &is, bool EOLstop=false)
int do_numeric_printf_conv(std::ostream &os, const printf_format_elt *elt, int nsa, int sa_1, int sa_2, const octave_value &val, const std::string &who)
nd deftypefn *octave_map m
bool write_bytes(const void *data, size_t n_elts)
std::complex< double > w(std::complex< double > z, double relerr=0)
octave_value finalize_read(std::list< void * > &input_buf_list, octave_idx_type input_buf_elts, octave_idx_type elts_read, octave_idx_type nr, octave_idx_type nc, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, octave::mach_info::float_format ffmt)
static void convert_chars(const void *data, void *conv_data, octave_idx_type n_elts)
bool is_string(void) const
std::string do_gets(octave_idx_type max_len, bool &err, bool strip_newline, const std::string &who)
const T * data(void) const
int do_printf_conv(std::ostream &os, const char *fmt, int nsa, int sa_1, int sa_2, T arg, const std::string &who)
octave_value do_scan(std::istream &isp, textscan_format_list &fmt_list, octave_idx_type ntimes)
octave_value do_textscan(const std::string &fmt, octave_idx_type ntimes, const octave_value_list &options, const std::string &who, octave_idx_type &count)
bool do_oscanf(const scanf_format_elt *elt, octave_value &, const std::string &who)
int puts(const std::string &s, const std::string &who)
static void clear(bool flush=true)
void scan_complex(delimited_stream &is, const textscan_format_elt &fmt, Complex &val) const
static int remove(int fid, const std::string &who="")
#define panic_impossible()
int do_printf(printf_format_list &fmt_list, const octave_value_list &args, const std::string &who)
int puts(const std::string &s, const std::string &who)
const textscan_format_elt * first(void)
std::string error(bool clear, int &err_num)
static void parse_options(octave::regexp::opts &options, const octave_value_list &args, const std::string &who, int skip, bool &extra_args)
void process_conversion(const std::string &s, size_t &i, size_t n)
static octave_stream lookup(int fid, const std::string &who="")
std::ostream * output_stream(void)
virtual int file_number(void) const
textscan_format_elt(const std::string &txt, int w=0, int p=-1, int bw=0, bool dis=false, char typ= '\0', const std::string &ch_class=std::string())
static void cleanup_instance(void)
octave_value_list oscanf(const std::string &fmt, const std::string &who)
octave_idx_type length(void) const
static bool ok_for_unsigned_int_conv(const octave_value &val)
Array< std::string > param
static std::string float_format_as_string(float_format)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
OCTINTERP_API size_t octave_format(std::ostream &os, const char *fmt,...)
octave_value textscan(const std::string &fmt, octave_idx_type ntimes, const octave_value_list &options, const std::string &who, octave_idx_type &count)
octave_value scanf(const std::string &fmt, const Array< double > &size, octave_idx_type &count, const std::string &who)
T::size_type strlen(const typename T::value_type *str)
std::ios_base::iostate rdstate(void)
void err_wrong_type_arg(const char *name, const char *s)
With real return the complex result
~printf_value_cache(void)
std::string error(bool clear, int &err_num)
const textscan_format_elt * next(bool cycle=true)
bool stream_ok(bool clear=true) const
static uint32_t state[624]
bool is_old_NA< double >(double val)
static bool is_nan_or_inf(const octave_value &val)
int read_first_row(delimited_stream &is, textscan &ts)
static float_format native_float_format(void)
void warning(const char *fmt,...)
void recover_from_exception(void)
octave_value read(const Array< double > &size, octave_idx_type block_size, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, octave_idx_type skip, octave::mach_info::float_format flt_fmt, octave_idx_type &count)
int do_insert(octave_stream &os)
octave_idx_type num_conversions(void) const
charNDArray max(char d, const charNDArray &m)
octave_stream(octave_base_stream *bs=0)
octave_idx_type length(void) const
Number of elements in the array.
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
T::size_type numel(const T &str)
bool is_NaN_or_NA(const Complex &x)
bool is_sq_string(void) const
static octave_value convert_and_copy(std::list< void * > &input_buf_list, octave_idx_type input_buf_elts, octave_idx_type elts_read, octave_idx_type nr, octave_idx_type nc, bool swap, bool do_float_fmt_conv, bool do_NA_conv, octave::mach_info::float_format from_flt_fmt)
NDArray array_value(bool frc_str_conv=false) const
octave_value_list oscanf(const std::string &fmt, const std::string &who)
octave_value scan(std::istream &isp, const std::string &fmt, octave_idx_type ntimes, const octave_value_list &options, octave_idx_type &read_count)
bool is_valid(void) const
octave_stream do_lookup(int fid, const std::string &who="") const
octave_stream & operator=(const octave_stream &)
OCTINTERP_API std::string do_string_escapes(const std::string &s)
=val(i)}if ode{val(i)}occurs in table i
octave_idx_type nint_big(double x)
delimited_stream(std::istream &is, const std::string &delimiters, int longest_lookahead, octave_idx_type bsize=4096)
is longer than or if then or only for unique occurrences of the complete pattern(false).The default is true.If a cell array of strings ar
static octave_idx_type get_size(double d, const std::string &who)
std::string getl(octave_idx_type max_len, bool &err, const std::string &who)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by nd tex zero divided by nd ifnottex and any operation involving another NaN value(5+NaN).Note that NaN always compares not equal to NaN(NaN!
static std::string list_open_files(void)
static octave_value open_file_numbers(void)
issues an error eealso double
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
int __lo_ieee_is_old_NA(double x)
double replace_old_NA< double >(double val)
octave_refcount< octave_idx_type > count
#define BEGIN_C_CONVERSION()
octave_int64 int64_scalar_value(void) const
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
string_vector do_get_info(int fid) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
int lookahead(delimited_stream &is, const Cell &targets, int max_len, bool case_sensitive=true) const
bool is_uint64_type(void) const
ostrl_map::const_iterator lookup_cache
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
#define FILL_TABLE_ROW(T, V)
ColumnVector transform(const Matrix &m, double x, double y, double z)
void do_float_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt)
octave_uint64 uint64_scalar_value(void) const
octave_value fast_elem_extract(octave_idx_type n) const
int getline(std::string &dest, char delim)
void progress_benchmark(void)
std::complex< float > FloatComplex
OCTAVE_EXPORT octave_value_list error nd deftypefn *const octave_scalar_map err
void do_scanf_conv(std::istream &is, const scanf_format_elt &fmt, T valptr, Matrix &mval, double *data, octave_idx_type &idx, octave_idx_type &conversion_count, octave_idx_type nr, octave_idx_type max_size, bool discard)
#define FINISH_CHARACTER_CONVERSION()
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
std::complex< double > Complex
static T replace_old_NA(T val)
const T * fortran_vec(void) const
bool strncmp(const T &str_a, const T &str_b, const typename T::size_type n)
True if the first N characters are the same.
std::string name(void) const
std::string gets(octave_idx_type max_len, bool &err, const std::string &who)
static bool convert_data(const T *data, void *conv_data, octave_idx_type n_elts, oct_data_conv::data_type output_type, octave::mach_info::float_format flt_fmt)
virtual bool eof(void) const =0
void invalid_operation(const std::string &who, const char *rw)
int printf(const std::string &fmt, const octave_value_list &args, const std::string &who)
octave_base_value * internal_rep(void) const
double double_value(bool frc_str_conv=false) const
write the output to stdout if nargout is
static Cell init_inf_nan(void)
bool match_literal(delimited_stream &isp, const textscan_format_elt &elem)
Vector representing the dimensions (size) of an Array.
virtual int seek(off_t offset, int origin)=0
std::string getl(octave_idx_type max_len, bool &err, const std::string &who)
static int get_file_number(const octave_value &fid)
static size_t data_type_size(data_type dt)
octave_value isnan(void) const
std::ios_base::iostate flags
static void clear(octave::dynamic_library &oct_file)
static std::string mode_as_string(int mode)
std::string do_list_open_files(void) const
#define BEGIN_CHAR_CLASS_CONVERSION()
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
char * read(char *buffer, int size, char *&new_start)
std::string whitespace_table
#define INSTANTIATE_WRITE(T)
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
static void convert_ints(const T *data, void *conv_data, octave_idx_type n_elts, bool swap)
charNDArray min(char d, const charNDArray &m)
octave_value do_binary_op(octave_value::binary_op op, const octave_value &v1, const octave_value &v2)
octave_value do_open_file_numbers(void) const
off_t skipl(off_t count, bool &err, const std::string &who)
double read_double(delimited_stream &is, const textscan_format_elt &fmt) const
bool is_integer_type(void) const