GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Typedefs | Functions | Variables
load-save.cc File Reference
#include <cfloat>
#include <cstring>
#include <cctype>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include "byte-swap.h"
#include "data-conv.h"
#include "file-ops.h"
#include "file-stat.h"
#include "glob-match.h"
#include "lo-mappers.h"
#include "mach-info.h"
#include "oct-env.h"
#include "oct-locbuf.h"
#include "oct-time.h"
#include "quit.h"
#include "str-vec.h"
#include "strftime-wrapper.h"
#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "errwarn.h"
#include "load-path.h"
#include "load-save.h"
#include "oct-hdf5.h"
#include "ovl.h"
#include "oct-map.h"
#include "ov-cell.h"
#include "pager.h"
#include "pt-exp.h"
#include "symtab.h"
#include "sysdep.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
#include "version.h"
#include "dMatrix.h"
#include "ls-hdf5.h"
#include "ls-mat-ascii.h"
#include "ls-mat4.h"
#include "ls-mat5.h"
#include "ls-oct-text.h"
#include "ls-oct-binary.h"
#include "zfstream.h"
Include dependency graph for load-save.cc:

Go to the source code of this file.

Typedefs

using format = LS_UNKNOWN
 

Functions

in the file Octave saves all
the variables in the current
scope full variable names or
pattern syntax can be used to
specify the variables to save
If the fields and variable
name 
arguments (ar{v1}, ots{}) must be specified as character strings.If called with a filename of code
 
static bool check_gzip_magic (const std::string &fname)
 
static std::string default_save_header_format (void)
 
octave_value do_load (std::istream &stream, const std::string &orig_fname, load_save_format format, octave::mach_info::float_format flt_fmt, bool list_only, bool swap, bool verbose, const string_vector &argv, int argv_idx, int argc, int nargout)
 
static void do_save (std::ostream &os, const octave_value &tc, const std::string &name, const std::string &help, bool global, load_save_format fmt, bool save_as_floats)
 
void do_save (std::ostream &os, const symbol_table::symbol_record &sr, load_save_format fmt, bool save_as_floats)
 
static void dump_octave_core (std::ostream &os, const char *fname, load_save_format fmt, bool save_as_floats)
 
void dump_octave_core (void)
 
static OCTAVE_NORETURN void err_file_open (const std::string &fcn, const std::string &file)
 
else error ("load: unable to determine file format of '%s'", orig_fname.c_str())
 
std::string find_file_to_load (const std::string &name, const std::string &orig_name)
 
OCTAVE_EXPORT octave_value_list Fload (const octave_value_list &args, int nargout) ar
 
 for (;i< argc;i++)
 
OCTAVE_EXPORT octave_value_list Fsave (const octave_value_list &args, int nargout) ar
 
static load_save_format get_file_format (std::istream &file, const std::string &filename)
 
static load_save_format get_file_format (const std::string &fname, const std::string &orig_fname, bool &use_zlib, bool quiet=false)
 
static bool glob_pattern_p (const std::string &pattern)
 
 if (argc > 1 &&!argv[1].empty()&&argv[1].at(0)!= '-')
 
 if (orig_fname=="")
 
 if (format==LS_UNKNOWN) format
 
else if (format!=LS_UNKNOWN)
 
 if (i==argc) print_usage()
 
static void install_loaded_variable (const std::string &name, const octave_value &val, bool global, const std::string &)
 
bool is_octave_data_file (const std::string &fname)
 
static bool matches_patterns (const string_vector &patterns, int pat_idx, int num_pat, const std::string &name)
 
void octave_finalize_hdf5 (void)
 
void octave_prepare_hdf5 (void)
 
static string_vector parse_save_options (const string_vector &argv, load_save_format &format, bool &append, bool &save_as_floats, bool &use_zlib)
 
static string_vector parse_save_options (const std::string &arg, load_save_format &format, bool &append, bool &save_as_floats, bool &use_zlib)
 
 parse_save_options (Vsave_default_options, format, append, save_as_floats, use_zlib)
 
int read_binary_file_header (std::istream &is, bool &swap, octave::mach_info::float_format &flt_fmt, bool quiet)
 
static size_t save_fields (std::ostream &os, const octave_scalar_map &m, const std::string &pattern, load_save_format fmt, bool save_as_floats)
 
static size_t save_vars (std::ostream &os, const std::string &pattern, load_save_format fmt, bool save_as_floats)
 
static void save_vars (const string_vector &argv, int argv_idx, int argc, std::ostream &os, load_save_format fmt, bool save_as_floats, bool write_header_info)
 
void write_header (std::ostream &os, load_save_format format)
 

Variables

bool append = false
 
from the file ar {file}. If no variables are specified then all variables found in the file will be loaded. As with ode{save}
 
int argc = args.length () + 1
 
string_vector argv = args.make_argv ("load")
 
 else
 
octave::mach_info::float_format flt_fmt = octave::mach_info::flt_fmt_unknown
 
 fname = find_file_to_load (fname, orig_fname)
 
int i = 1
 
write the output to stdout if
nargout 
is
 
bool list_only = false
 
std::string orig_fname = ""
 
in the file Octave saves all
the variables in the current
scope 
Otherwise
 
 ots {}
 
in the file Octave saves all
the variables in the current
scope full variable names or
pattern syntax can be used to
specify the variables to save
If the 
ption {-struct} modifier is used
 
return retval
 
bool save_as_floats = false
 
bool swap = false
 
bool use_zlib = false
 
static bool Vcrash_dumps_octave_core = true
 
bool verbose = false
 
static double Voctave_core_file_limit = -1.0
 
static std::string Voctave_core_file_name = "octave-workspace"
 
static std::string Voctave_core_file_options = "-binary"
 
static std::string Vsave_default_options = "-text"
 
static std::string Vsave_header_format_string = default_save_header_format ()
 

Typedef Documentation

Definition at line 1580 of file load-save.cc.

Function Documentation

in the file Octave saves all the variables in the current scope full variable names or pattern syntax can be used to specify the variables to save If the fields and variable name arguments ( ar{v1}  ,
ots{}   
)

Definition at line 1576 of file load-save.cc.

static bool check_gzip_magic ( const std::string fname)
static

Definition at line 214 of file load-save.cc.

References file, OCTAVE_LOCAL_BUFFER, and retval.

Referenced by get_file_format().

static std::string default_save_header_format ( void  )
static
octave_value do_load ( std::istream &  stream,
const std::string orig_fname,
load_save_format  format,
octave::mach_info::float_format  flt_fmt,
bool  list_only,
bool  swap,
bool  verbose,
const string_vector argv,
int  argv_idx,
int  argc,
int  nargout 
)
static void do_save ( std::ostream &  os,
const octave_value tc,
const std::string name,
const std::string help,
bool  global,
load_save_format  fmt,
bool  save_as_floats 
)
static
void do_save ( std::ostream &  os,
const symbol_table::symbol_record sr,
load_save_format  fmt,
bool  save_as_floats 
)
static void dump_octave_core ( std::ostream &  os,
const char *  fname,
load_save_format  fmt,
bool  save_as_floats 
)
static
void dump_octave_core ( void  )
static OCTAVE_NORETURN void err_file_open ( const std::string fcn,
const std::string file 
)
static

Definition at line 130 of file load-save.cc.

References error().

Referenced by get_file_format(), and if().

else error ( "load: unable to determine file format of '%s'"  ,
orig_fname.  c_str() 
)
std::string find_file_to_load ( const std::string name,
const std::string orig_name 
)
OCTAVE_EXPORT octave_value_list Fload ( const octave_value_list args,
int  nargout 
)

Definition at line 629 of file load-save.cc.

Referenced by install_load_save_fcns(), and main_window::load_workspace_callback().

for ( )
OCTAVE_EXPORT octave_value_list Fsave ( const octave_value_list args,
int  nargout 
)

Definition at line 1576 of file load-save.cc.

Referenced by install_load_save_fcns(), and main_window::save_workspace_callback().

static load_save_format get_file_format ( std::istream &  file,
const std::string filename 
)
static
static load_save_format get_file_format ( const std::string fname,
const std::string orig_fname,
bool use_zlib,
bool  quiet = false 
)
static
static bool glob_pattern_p ( const std::string pattern)
static

Definition at line 869 of file load-save.cc.

References c, and i.

if ( argc  ,
1 &&!argv.empty()&&argv.at(0)!  [1][1] = '-' 
)

Definition at line 641 of file load-save.cc.

if ( orig_fname  = = "")

Definition at line 713 of file load-save.cc.

References i, and print_usage().

if ( format  = LS_UNKNOWN)

Definition at line 762 of file load-save.cc.

References do_load(), err_file_open(), and nargout().

else if ( format!  = LS_UNKNOWN)
if ( i  = =argc)
static void install_loaded_variable ( const std::string name,
const octave_value val,
bool  global,
const std::string  
)
static
bool is_octave_data_file ( const std::string fname)

Definition at line 526 of file load-save.cc.

References get_file_format(), LS_UNKNOWN, and use_zlib.

Referenced by files_dock_widget::display_directory().

static bool matches_patterns ( const string_vector patterns,
int  pat_idx,
int  num_pat,
const std::string name 
)
static

Definition at line 161 of file load-save.cc.

References glob_match::match(), and pattern().

Referenced by do_load().

void octave_finalize_hdf5 ( void  )

Definition at line 1248 of file load-save.cc.

void octave_prepare_hdf5 ( void  )

Definition at line 1240 of file load-save.cc.

static string_vector parse_save_options ( const string_vector argv,
load_save_format format,
bool append,
bool save_as_floats,
bool use_zlib 
)
static
static string_vector parse_save_options ( const std::string arg,
load_save_format format,
bool append,
bool save_as_floats,
bool use_zlib 
)
static

Definition at line 1140 of file load-save.cc.

References string_vector::append(), argv, is, parse_save_options(), str, and string.

parse_save_options ( Vsave_default_options  ,
format  ,
append  ,
save_as_floats  ,
use_zlib   
)
int read_binary_file_header ( std::istream &  is,
bool swap,
octave::mach_info::float_format flt_fmt,
bool  quiet 
)
static size_t save_fields ( std::ostream &  os,
const octave_scalar_map m,
const std::string pattern,
load_save_format  fmt,
bool  save_as_floats 
)
static
static size_t save_vars ( std::ostream &  os,
const std::string pattern,
load_save_format  fmt,
bool  save_as_floats 
)
static

Definition at line 1001 of file load-save.cc.

References do_save(), symbol_table::glob(), p, and vars.

Referenced by octave::my_friendly_exit(), and save_vars().

static void save_vars ( const string_vector argv,
int  argv_idx,
int  argc,
std::ostream &  os,
load_save_format  fmt,
bool  save_as_floats,
bool  write_header_info 
)
static
void write_header ( std::ostream &  os,
load_save_format  format 
)

Variable Documentation

bool append = false
in the file Octave saves all the variables in the current scope full variable names or pattern syntax can be used to specify the variables to save If the fields ar {file}. If no variables are specified then all variables found in the file will be loaded. As with ode{save}

Definition at line 629 of file load-save.cc.

int argc = args.length () + 1

Definition at line 633 of file load-save.cc.

Referenced by do_who(), Fformat(), main(), parse_save_options(), read_hdf5_data(), and save_vars().

string_vector argv = args.make_argv ("load")
else
Initial value:
{
fname
Definition: load-save.cc:754
std::string orig_fname
Definition: load-save.cc:638
static std::string tilde_expand(const std::string &)
Definition: file-ops.cc:301
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
Definition: utils.cc:854

Definition at line 751 of file load-save.cc.

fname = find_file_to_load (fname, orig_fname)
int i = 1

Definition at line 637 of file load-save.cc.

Referenced by glob_pattern_p(), if(), and save_vars().

write the output to stdout if nargout is
bool list_only = false

Definition at line 653 of file load-save.cc.

std::string orig_fname = ""

Definition at line 638 of file load-save.cc.

in the file Octave saves all the variables in the current scope Otherwise

Definition at line 1576 of file load-save.cc.

ots {}

Definition at line 629 of file load-save.cc.

in the file Octave saves all the variables in the current scope full variable names or pattern syntax can be used to specify the variables to save If the ption {-struct} modifier is used

Definition at line 1576 of file load-save.cc.

return retval

Definition at line 863 of file load-save.cc.

Referenced by check_gzip_magic(), do_load(), get_file_format(), if(), and parse_save_options().

bool save_as_floats = false
bool swap = false

Definition at line 725 of file load-save.cc.

Referenced by octave_sort< T >::binarysort(), axes::properties::calc_ticks_and_lims(), convert_data(), dmsolve_extract(), octave::opengl_renderer::draw_axes_boxes(), extended_gcd(), RowVector::extract(), ColumnVector::extract(), FloatRowVector::extract(), FloatColumnVector::extract(), DiagMatrix::extract(), charMatrix::extract(), FloatDiagMatrix::extract(), ComplexRowVector::extract(), ComplexColumnVector::extract(), FloatComplexRowVector::extract(), FloatComplexColumnVector::extract(), ComplexDiagMatrix::extract(), FloatComplexDiagMatrix::extract(), Matrix::extract(), FloatMatrix::extract(), ComplexMatrix::extract(), FloatComplexMatrix::extract(), RowVector::fill(), ColumnVector::fill(), FloatRowVector::fill(), FloatColumnVector::fill(), ComplexRowVector::fill(), ComplexColumnVector::fill(), FloatComplexRowVector::fill(), FloatComplexColumnVector::fill(), Matrix::fill(), FloatMatrix::fill(), ComplexMatrix::fill(), FloatComplexMatrix::fill(), get_file_format(), Gsymrcm(), H_heapify_min(), H_insert(), octave_sparse_complex_matrix::load_binary(), octave_float_complex_matrix::load_binary(), octave_complex_matrix::load_binary(), octave_float_matrix::load_binary(), octave_matrix::load_binary(), mk_tmp_hist_file(), octave_sort< T >::nth_element(), octave_jit_paren_subsasgn_matrix_range(), octave::math::aepbalance< MT >::permuting_vector(), read_mat5_binary_element(), read_mat_binary_data(), simple_gcd(), Range::sort_internal(), octave::ft_text_renderer::text_to_pixels(), axes::properties::update_axes_layout(), figure::properties::update_paperorientation(), figure::properties::update_papersize(), figure::properties::update_papertype(), and figure::properties::update_paperunits().

bool use_zlib = false

Definition at line 756 of file load-save.cc.

Referenced by is_octave_data_file().

bool Vcrash_dumps_octave_core = true
static

Definition at line 95 of file load-save.cc.

bool verbose = false
double Voctave_core_file_limit = -1.0
static

Definition at line 99 of file load-save.cc.

Referenced by dump_octave_core().

std::string Voctave_core_file_name = "octave-workspace"
static

Definition at line 102 of file load-save.cc.

Referenced by dump_octave_core().

std::string Voctave_core_file_options = "-binary"
static

Definition at line 109 of file load-save.cc.

Referenced by dump_octave_core().

std::string Vsave_default_options = "-text"
static

Definition at line 106 of file load-save.cc.

std::string Vsave_header_format_string = default_save_header_format ()
static

Definition at line 126 of file load-save.cc.

Referenced by write_header().