Navigation

Operators and Keywords

Function List:

C++ API

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-time.h"
#include "quit.h"
#include "str-vec.h"
#include "oct-locbuf.h"
#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "gripes.h"
#include "load-path.h"
#include "load-save.h"
#include "oct-obj.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-ascii.h"
#include "ls-oct-binary.h"

Include dependency graph for load-save.cc:


Defines

#define HAVE_HDF5_HELP_STRING   "\n\HDF5 load and save are not available, as this Octave executable was\n\not linked with the HDF5 library."
#define HAVE_ZLIB_HELP_STRING   "\n\This option is not available, as this Octave executable was not linked with\n\the zlib library."

Functions

int read_binary_file_header (std::istream &is, bool &swap, oct_mach_info::float_format &flt_fmt, bool quiet)
octave_value do_load (std::istream &stream, const std::string &orig_fname, load_save_format format, oct_mach_info::float_format flt_fmt, bool list_only, bool swap, bool verbose, const string_vector &argv, int argv_idx, int argc, int nargout)
std::string find_file_to_load (const std::string &name, const std::string &orig_name)
 DEFUN (load, args, nargout,"-*- texinfo -*-\n\ @deffn {Command} load file\n\ @deffnx {Command} load options file\n\ @deffnx {Command} load options file v1 v2 @dots{}\n\ @deffnx {Command} S = load(\"options\", \"file\", \"v1\", \"v2\", @dots{})\n\ Load the named variables @var{v1}, @var{v2}, @dots{}, from the file\n\ @var{file}. If no variables are specified then all variables found in the\n\ file will be loaded. As with @code{save}, the list of variables to extract\n\ can be full names or use a pattern syntax. The format of the file is\n\ automatically detected but may be overridden by supplying the appropriate\n\ option.\n\ \n\ If load is invoked using the functional form\n\ \n\ @example\n\ load (\"-option1\", @dots{}, \"file\", \"v1\", @dots{})\n\ @end example\n\ \n\ @noindent\n\ then the @var{options}, @var{file}, and variable name arguments\n\ (@var{v1}, @dots{}) must be specified as character strings.\n\ \n\ If a variable that is not marked as global is loaded from a file when a\n\ global symbol with the same name already exists, it is loaded in the\n\ global symbol table. Also, if a variable is marked as global in a file\n\ and a local symbol exists, the local symbol is moved to the global\n\ symbol table and given the value from the file.\n\ \n\ If invoked with a single output argument, Octave returns data instead\n\ of inserting variables in the symbol table. If the data file contains\n\ only numbers (TAB- or space-delimited columns), a matrix of values is\n\ returned. Otherwise, @code{load} returns a structure with members\n\ corresponding to the names of the variables in the file.\n\ \n\ The @code{load} command can read data stored in Octave's text and\n\ binary formats, and @sc{matlab}'s binary format. If compiled with zlib\n\ support, it can also load gzip-compressed files. It will automatically\n\ detect the type of file and do conversion from different floating point\n\ formats (currently only IEEE big and little endian, though other formats\n\ may be added in the future).\n\ \n\ Valid options for @code{load} are listed in the following table.\n\ \n\ @table @code\n\ @item -force\n\ This option is accepted for backward compatibility but is ignored.\n\ Octave now overwrites variables currently in memory with\n\ those of the same name found in the file.\n\ \n\ @item -ascii\n\ Force Octave to assume the file contains columns of numbers in text format\n\ without any header or other information. Data in the file will be loaded\n\ as a single numeric matrix with the name of the variable derived from the\n\ name of the file.\n\ \n\ @item -binary\n\ Force Octave to assume the file is in Octave's binary format.\n\ \n\ @item -hdf5\n\ Force Octave to assume the file is in HDF5 format.\n\ (HDF5 is a free, portable binary format developed by the National\n\ Center for Supercomputing Applications at the University of Illinois.)\n\ Note that Octave can read HDF5 files not created by itself, but may\n\ skip some datasets in formats that it cannot support.\n"HAVE_HDF5_HELP_STRING"\n\ @item -import\n\ This option is accepted for backward compatibility but is ignored.\n\ Octave can now support multi-dimensional HDF data and automatically\n\ modifies variable names if they are invalid Octave identifiers.\n\ \n\ @item -mat\n\ @itemx -mat-binary\n\ @itemx -6\n\ @itemx -v6\n\ @itemx -7\n\ @itemx -v7\n\ Force Octave to assume the file is in @sc{matlab}'s version 6 or 7 binary\n\ format.\n\ \n\ @item -mat4-binary\n\ @itemx -4\n\ @itemx -v4\n\ @itemx -V4\n\ Force Octave to assume the file is in the binary format written by\n\ @sc{matlab} version 4.\n\ \n\ @item -text\n\ Force Octave to assume the file is in Octave's text format.\n\ @end table\n\ @seealso{save, dlmwrite, csvwrite, fwrite}\n\ @end deffn")
void do_save (std::ostream &os, const symbol_table::symbol_record &sr, load_save_format fmt, bool save_as_floats)
void write_header (std::ostream &os, load_save_format format)
void dump_octave_core (void)
 DEFUN (save, args,,"-*- texinfo -*-\n\ @deffn {Command} save file\n\ @deffnx {Command} save options file\n\ @deffnx {Command} save options file @var{v1} @var{v2} @dots{}\n\ @deffnx {Command} save options file -struct @var{STRUCT} @var{f1} @var{f2} @dots{}\n\ Save the named variables @var{v1}, @var{v2}, @dots{}, in the file\n\ @var{file}. The special filename @samp{-} may be used to write\n\ output to the terminal. If no variable names are listed, Octave saves\n\ all the variables in the current scope. Otherwise, full variable names or\n\ pattern syntax can be used to specify the variables to save.\n\ If the @code{-struct} modifier is used, fields @var{f1} @var{f2} @dots{}\n\ of the scalar structure @var{STRUCT} are saved as if they were variables\n\ with corresponding names.\n\ Valid options for the @code{save} command are listed in the following table.\n\ Options that modify the output format override the format specified by \n\ @code{default_save_options}.\n\ \n\ If save is invoked using the functional form\n\ \n\ @example\n\ save (\"-option1\", @dots{}, \"file\", \"v1\", @dots{})\n\ @end example\n\ \n\ @noindent\n\ then the @var{options}, @var{file}, and variable name arguments\n\ (@var{v1}, @dots{}) must be specified as character strings.\n\ \n\ @table @code\n\ @item -ascii\n\ Save a single matrix in a text file without header or any other information.\n\ \n\ @item -binary\n\ Save the data in Octave's binary data format.\n\ \n\ @item -float-binary\n\ Save the data in Octave's binary data format but only using single\n\ precision. Only use this format if you know that all the\n\ values to be saved can be represented in single precision.\n\ \n\ @item -hdf5\n\ Save the data in HDF5 format.\n\ (HDF5 is a free, portable binary format developed by the National\n\ Center for Supercomputing Applications at the University of Illinois.)\n"HAVE_HDF5_HELP_STRING"\n\ @item -float-hdf5\n\ Save the data in HDF5 format but only using single precision.\n\ Only use this format if you know that all the\n\ values to be saved can be represented in single precision.\n\ \n\ @item -V7\n\ @itemx -v7\n\ @itemx -7\n\ @itemx -mat7-binary\n\ Save the data in @sc{matlab}'s v7 binary data format.\n"HAVE_ZLIB_HELP_STRING"\n\ @item -V6\n\ @itemx -v6\n\ @itemx -6\n\ @itemx -mat\n\ @itemx -mat-binary\n\ Save the data in @sc{matlab}'s v6 binary data format.\n\ \n\ @item -V4\n\ @itemx -v4\n\ @itemx -4\n\ @itemx -mat4-binary\n\ Save the data in the binary format written by @sc{matlab} version 4.\n\ \n\ @item -text\n\ Save the data in Octave's text data format. (default).\n\ \n\ @item -zip\n\ @itemx -z\n\ Use the gzip algorithm to compress the file. This works equally on files that\n\ are compressed with gzip outside of octave, and gzip can equally be used to\n\ convert the files for backward compatibility.\n"HAVE_ZLIB_HELP_STRING"@end table\n\ \n\ The list of variables to save may use wildcard patterns containing\n\ the following special characters:\n\ @table @code\n\ @item ?\n\ Match any single character.\n\ \n\ @item *\n\ Match zero or more characters.\n\ \n\ @item [ @var{list} ]\n\ Match the list of characters specified by @var{list}. If the first\n\ character is @code{!} or @code{^}, match all characters except those\n\ specified by @var{list}. For example, the pattern @code{[a-zA-Z]} will\n\ match all lower and upper case alphabetic characters. \n\ \n\ Wildcards may also be used in the field name specifications when using\n\ the @code{-struct} modifier (but not in the struct name itself).\n\ \n\ @end table\n\ \n\ Except when using the @sc{matlab} binary data file format or the\n\ @samp{-ascii} format, saving global\n\ variables also saves the global status of the variable. If the variable\n\ is restored at a later time using @samp{load}, it will be restored as a\n\ global variable.\n\ \n\ The command\n\ \n\ @example\n\ save -binary data a b*\n\ @end example\n\ \n\ @noindent\n\ saves the variable @samp{a} and all variables beginning with @samp{b} to\n\ the file @file{data} in Octave's binary format.\n\ @seealso{load, default_save_options, dlmread, csvread, fread}\n\ @end deffn")
 DEFUN (crash_dumps_octave_core, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} crash_dumps_octave_core ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} crash_dumps_octave_core (@var{new_val})\n\ Query or set the internal variable that controls whether Octave tries\n\ to save all current variables to the file \"octave-core\" if it\n\ crashes or receives a hangup, terminate or similar signal.\n\ @seealso{octave_core_file_limit, octave_core_file_name, octave_core_file_options}\n\ @end deftypefn")
 DEFUN (default_save_options, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} default_save_options ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} default_save_options (@var{new_val})\n\ Query or set the internal variable that specifies the default options\n\ for the @code{save} command, and defines the default format.\n\ Typical values include @code{\"-ascii\"}, @code{\"-text -zip\"}.\n\ The default value is @code{-text}.\n\ @seealso{save}\n\ @end deftypefn")
 DEFUN (octave_core_file_limit, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} octave_core_file_limit ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} octave_core_file_limit (@var{new_val})\n\ Query or set the internal variable that specifies the maximum amount\n\ of memory (in kilobytes) of the top-level workspace that Octave will\n\ attempt to save when writing data to the crash dump file (the name of\n\ the file is specified by @var{octave_core_file_name}). If\n\ @var{octave_core_file_options} flags specify a binary format,\n\ then @var{octave_core_file_limit} will be approximately the maximum\n\ size of the file. If a text file format is used, then the file could\n\ be much larger than the limit. The default value is -1 (unlimited)\n\ @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_options}\n\ @end deftypefn")
 DEFUN (octave_core_file_name, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} octave_core_file_name ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} octave_core_file_name (@var{new_val})\n\ Query or set the internal variable that specifies the name of the file\n\ used for saving data from the top-level workspace if Octave aborts.\n\ The default value is @code{\"octave-core\"}\n\ @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_options}\n\ @end deftypefn")
 DEFUN (octave_core_file_options, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} octave_core_file_options ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} octave_core_file_options (@var{new_val})\n\ Query or set the internal variable that specifies the options used for\n\ saving the workspace data if Octave aborts. The value of\n\ @code{octave_core_file_options} should follow the same format as the\n\ options for the @code{save} function. The default value is Octave's binary\n\ format.\n\ @seealso{crash_dumps_octave_core, octave_core_file_name, octave_core_file_limit}\n\ @end deftypefn")
 DEFUN (save_header_format_string, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} save_header_format_string ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} save_header_format_string (@var{new_val})\n\ Query or set the internal variable that specifies the format\n\ string used for the comment line written at the beginning of\n\ text-format data files saved by Octave. The format string is\n\ passed to @code{strftime} and should begin with the character\n\ @samp{#} and contain no newline characters. If the value of\n\ @code{save_header_format_string} is the empty string,\n\ the header comment is omitted from text-format data files. The\n\ default value is\n\ \n\ @c Set example in small font to prevent overfull line\n\ @smallexample\n\ \"# Created by Octave VERSION, %a %b %d %H:%M:%S %Y %Z <USER@@HOST>\"\n\ @end smallexample\n\ @seealso{strftime, save}\n\ @end deftypefn")

Define Documentation

#define HAVE_HDF5_HELP_STRING   "\n\HDF5 load and save are not available, as this Octave executable was\n\not linked with the HDF5 library."

#define HAVE_ZLIB_HELP_STRING   "\n\This option is not available, as this Octave executable was not linked with\n\the zlib library."


Function Documentation

DEFUN ( save_header_format_string  ,
args  ,
nargout   
)

DEFUN ( octave_core_file_options  ,
args  ,
nargout   
)

DEFUN ( octave_core_file_name  ,
args  ,
nargout   
)

DEFUN ( octave_core_file_limit  ,
args  ,
nargout   
)

DEFUN ( default_save_options  ,
args  ,
nargout   
)

DEFUN ( crash_dumps_octave_core  ,
args  ,
nargout   
)

DEFUN ( save  ,
args   
)

DEFUN ( load  ,
args  ,
nargout   
)

octave_value do_load ( std::istream &  stream,
const std::string orig_fname,
load_save_format  format,
oct_mach_info::float_format  flt_fmt,
bool  list_only,
bool  swap,
bool  verbose,
const string_vector argv,
int  argv_idx,
int  argc,
int  nargout 
)

void do_save ( std::ostream os,
const symbol_table::symbol_record sr,
load_save_format  fmt,
bool  save_as_floats 
)

void dump_octave_core ( void   ) 

std::string find_file_to_load ( const std::string name,
const std::string orig_name 
)

int read_binary_file_header ( std::istream &  is,
bool swap,
oct_mach_info::float_format flt_fmt,
bool  quiet 
)

void write_header ( std::ostream os,
load_save_format  format 
)