26 #if defined (HAVE_CONFIG_H)
89 if (next_only && ch !=
'%' && ch !=
'#')
95 if (c ==
'%' || c ==
'#')
97 std::ostringstream buf;
99 while (is.get (c) && (c ==
' ' || c ==
'\t' || c ==
'%' || c ==
'#'))
105 while (is.get (c) && isalpha (c))
108 std::string tmp = buf.str ();
109 bool match = (tmp.substr (0,
strlen (keyword)) == keyword);
113 std::ostringstream value;
114 while (is.get (c) && (c ==
' ' || c ==
'\t' || c ==
':'))
128 int len = retval.length ();
136 if (c ==
' ' || c ==
'\t')
237 #define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == (t))
247 for (
int i = 0; i < nargs; i++)
271 args(0) = std::string (buf);
282 error (
"load: trouble reading ascii file '%s'", filename.c_str ());
288 const bool do_name_validation)
297 error (
"load: empty name keyword or no data found in file '%s'",
305 error (
"load: invalid identifier '%s' found in file '%s'",
306 name.c_str (), filename.c_str ());
313 error (
"load: failed to extract keyword specifying value type");
316 std::size_t pos = tag.rfind (
' ');
318 if (pos != std::string::npos)
322 typ = (global ? tag.substr (7) : tag);
344 error (
"load: trouble reading ascii file '%s'", filename.c_str ());
362 const std::string& name,
bool mark_global,
366 os <<
"# name: " << name <<
"\n";
371 os <<
"# type: global " << val.
type_name () <<
"\n";
373 os <<
"# type: " << val.
type_name () <<
"\n";
378 long old_precision = os.precision ();
379 os.precision (precision);
389 os.precision (old_precision);
391 return (os && success);
396 const std::string& name)
414 error (
"for now, I can only save real matrices in 3-D format");
416 os <<
"# 3-D data...\n"
417 <<
"# type: matrix\n"
418 <<
"# total rows: " << nr <<
"\n"
419 <<
"# total columns: " << nc <<
"\n";
421 long old_precision = os.precision ();
428 warning (
"ignoring last %" OCTAVE_IDX_TYPE_FORMAT
" columns", extras);
435 os << tmp.
extract (0, i, nr-1, i+2);
447 os << tmp.
extract (0, i, nr-1, i);
453 os.precision (old_precision);
455 return (
static_cast<bool> (os));
460 DEFUN (save_precision, args, nargout,
482 "save_precision", -1,
charNDArray max(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTAVE_API Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
octave_idx_type length(void) const
OCTINTERP_API bool load_ascii(std::istream &is)
octave_idx_type rows(void) const
bool save_ascii(std::ostream &os)
octave_idx_type columns(void) const
bool is_real_matrix(void) const
Matrix matrix_value(bool frc_str_conv=false) const
std::string type_name(void) const
octave_value lookup_type(const std::string &nm)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void error(const char *fmt,...)
interpreter & __get_interpreter__(void)
type_info & __get_type_info__(void)
void skip_until_newline(std::istream &is, bool keep_newline)
std::string read_until_newline(std::istream &is, bool keep_newline)
void skip_preceeding_newline(std::istream &is)
static int Vsave_precision
std::string read_text_data(std::istream &is, const std::string &filename, bool &global, octave_value &tc, octave_idx_type count, const bool do_name_validation)
bool save_text_data_for_plotting(std::ostream &os, const octave_value &t, const std::string &name)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
bool save_text_data(std::ostream &os, const octave_value &val_arg, const std::string &name, bool mark_global, int precision)
bool save_three_d(std::ostream &os, const octave_value &tc, bool parametric)
#define SUBSTRING_COMPARE_EQ(s, pos, n, t)
static octave_value load_inline_fcn(std::istream &is, const std::string &filename)
T::size_type strlen(const typename T::value_type *str)
bool valid_identifier(const char *s)
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)