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 ==
':'))
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);
283 error (
"load: trouble reading ascii file '%s'", filename.c_str ());
289 const bool do_name_validation)
298 error (
"load: empty name keyword or no data found in file '%s'",
306 error (
"load: invalid identifier '%s' found in file '%s'",
307 name.c_str (), filename.c_str ());
314 error (
"load: failed to extract keyword specifying value type");
317 size_t pos = tag.rfind (
' ');
319 if (pos != std::string::npos)
323 typ = (global ? tag.substr (7) : tag);
346 error (
"load: trouble reading ascii file '%s'", filename.c_str ());
364 const std::string&
name,
bool mark_global,
368 os <<
"# name: " <<
name <<
"\n";
373 os <<
"# type: global " << val.
type_name () <<
"\n";
375 os <<
"# type: " << val.
type_name () <<
"\n";
380 long old_precision = os.precision ();
381 os.precision (precision);
391 os.precision (old_precision);
393 return (os && success);
398 const std::string&
name)
416 error (
"for now, I can only save real matrices in 3-D format");
418 os <<
"# 3-D data...\n"
419 <<
"# type: matrix\n"
420 <<
"# total rows: " << nr <<
"\n"
421 <<
"# total columns: " << nc <<
"\n";
423 long old_precision = os.precision ();
430 warning (
"ignoring last %" OCTAVE_IDX_TYPE_FORMAT
" columns", extras);
437 os << tmp.
extract (0, i, nr-1, i+2);
449 os << tmp.
extract (0, i, nr-1, i);
455 os.precision (old_precision);
457 return (
static_cast<bool> (os));
460 DEFUN (save_precision, args, nargout,
charNDArray max(char d, const charNDArray &m)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type rows(void) const
Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
octave_value lookup_type(const std::string &nm)
octave_idx_type length(void) const
octave_idx_type rows(void) const
bool save_ascii(std::ostream &os)
octave_idx_type columns(void) const
bool load_ascii(std::istream &is)
bool is_real_matrix(void) const
Matrix matrix_value(bool frc_str_conv=false) const
std::string type_name(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void error(const char *fmt,...)
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)
bool valid_identifier(const char *s)
type_info & __get_type_info__(const std::string &who)
interpreter & __get_interpreter__(const std::string &who)
T::size_type strlen(const typename T::value_type *str)
octave_value::octave_value(const Array< char > &chm, char type) return retval
#define SET_INTERNAL_VARIABLE_WITH_LIMITS(NM, MINVAL, MAXVAL)