85 if (next_only && ch !=
'%' && ch !=
'#')
91 if (c ==
'%' || c ==
'#')
93 std::ostringstream buf;
95 while (is.get (c) && (c ==
' ' || c ==
'\t' || c ==
'%' || c ==
'#'))
101 while (is.get (c) && isalpha (c))
104 std::string tmp = buf.str ();
105 bool match = (tmp.compare (0, strlen (keyword), keyword) == 0);
109 std::ostringstream value;
110 while (is.get (c) && (c ==
' ' || c ==
'\t' || c ==
':'))
124 int len = retval.length ();
132 if (c ==
' ' || c ==
'\t')
234 #define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == t)
247 error (
"load: empty name keyword or no data found in file '%s'",
250 return std::string ();
253 if (! (name ==
".nargin." || name ==
".nargout."
256 error (
"load: bogus identifier '%s' found in file '%s'",
257 name.c_str (), filename.c_str ());
258 return std::string ();
268 size_t pos = tag.rfind (
' ');
270 if (pos != std::string::npos)
274 typ = global ? tag.substr (7) : tag;
286 error (
"load: trouble reading ascii file '%s'", filename.c_str ());
289 error (
"load: failed to extract keyword specifying value type");
293 error (
"load: reading file %s", filename.c_str ());
294 return std::string ();
313 const std::string& name,
bool mark_as_global,
319 os <<
"# name: " << name <<
"\n";
324 os <<
"# type: global " << val.
type_name () <<
"\n";
326 os <<
"# type: " << val.
type_name () <<
"\n";
331 long old_precision = os.precision ();
332 os.precision (precision);
342 os.precision (old_precision);
344 return (os && success);
349 const std::string& name)
370 os <<
"# 3-D data...\n"
371 <<
"# type: matrix\n"
372 <<
"# total rows: " << nr <<
"\n"
373 <<
"# total columns: " << nc <<
"\n";
375 long old_precision = os.precision ();
382 warning (
"ignoring last %d columns", extras);
389 os << tmp.
extract (0, i, nr-1, i+2);
401 os << tmp.
extract (0, i, nr-1, i);
407 os.precision (old_precision);
411 ::error (
"for now, I can only save real matrices in 3-D format");
415 return (os && ! fail);
418 DEFUN (save_precision, args, nargout,
420 @deftypefn {Built-in Function} {@var{val} =} save_precision ()\n\
421 @deftypefnx {Built-in Function} {@var{old_val} =} save_precision (@var{new_val})\n\
422 @deftypefnx {Built-in Function} {} save_precision (@var{new_val}, \"local\")\n\
423 Query or set the internal variable that specifies the number of\n\
424 digits to keep when saving data in text format.\n\
426 When called from inside a function with the @qcode{\"local\"} option, the\n\
427 variable is changed locally for the function and any subroutines it calls.\n\
428 The original variable value is restored when exiting the function.\n\