Navigation

Operators and Keywords

Function List:

C++ API

variables.cc File Reference

#include <cstdio>
#include <cstring>
#include <iomanip>
#include <set>
#include <string>
#include "file-stat.h"
#include "oct-env.h"
#include "file-ops.h"
#include "glob-match.h"
#include "regex-match.h"
#include "str-vec.h"
#include <defaults.h>
#include "Cell.h"
#include "defun.h"
#include "dirfns.h"
#include "error.h"
#include "gripes.h"
#include "help.h"
#include "input.h"
#include "lex.h"
#include "load-path.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "ov.h"
#include "ov-class.h"
#include "ov-usr-fcn.h"
#include "pager.h"
#include "parse.h"
#include "symtab.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"

Include dependency graph for variables.cc:


Classes

struct  whos_parameter
class  symbol_info_list
struct  symbol_info_list::symbol_info_list::symbol_info

Defines

#define GET_IDX(LEN)   static_cast<int> ((LEN-1) * static_cast<double> (rand ()) / RAND_MAX)
#define CLEAR_OPTION_ERROR(cond)

Functions

void clear_mex_functions (void)
void clear_function (const std::string &nm)
void clear_variable (const std::string &nm)
void clear_symbol (const std::string &nm)
octave_functionis_valid_function (const std::string &fcn_name, const std::string &warn_for, bool warn)
octave_functionis_valid_function (const octave_value &arg, const std::string &warn_for, bool warn)
octave_functionextract_function (const octave_value &arg, const std::string &warn_for, const std::string &fname, const std::string &header, const std::string &trailer)
string_vector get_struct_elts (const std::string &text)
string_vector generate_struct_completions (const std::string &text, std::string &prefix, std::string &hint)
bool looks_like_struct (const std::string &text)
 DEFUN (isglobal, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isglobal (@var{name})\n\ Return 1 if @var{name} is globally visible. Otherwise, return 0. For\n\ example,\n\ \n\ @example\n\ @group\n\ global x\n\ isglobal (\"x\")\n\ @result{} 1\n\ @end group\n\ @end example\n\ @end deftypefn")
 DEFUN (is_global, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isglobal (@var{name})\n\ This function has been deprecated. Use isglobal instead.\n\ @end deftypefn")
int symbol_exist (const std::string &name, const std::string &type)
std::string unique_symbol_name (const std::string &basename)
 DEFUN (exist, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} exist (@var{name}, @var{type})\n\ Return 1 if the name exists as a variable, 2 if the name is an\n\ absolute file name, an ordinary file in Octave's @code{path}, or (after\n\ appending @samp{.m}) a function file in Octave's @code{path}, 3 if the\n\ name is a @samp{.oct} or @samp{.mex} file in Octave's @code{path},\n\ 5 if the name is a built-in function, 7 if the name is a directory, or 103\n\ if the name is a function not associated with a file (entered on\n\ the command line).\n\ \n\ Otherwise, return 0.\n\ \n\ This function also returns 2 if a regular file called @var{name}\n\ exists in Octave's search path. If you want information about\n\ other types of files, you should use some combination of the functions\n\ @code{file_in_path} and @code{stat} instead.\n\ \n\ If the optional argument @var{type} is supplied, check only for\n\ symbols of the specified type. Valid types are\n\ \n\ @table @samp\n\ @item \"var\"\n\ Check only for variables.\n\ @item \"builtin\"\n\ Check only for built-in functions.\n\ @item \"file\"\n\ Check only for files.\n\ @item \"dir\"\n\ Check only for directories.\n\ @end table\n\ @end deftypefn")
octave_value lookup_function_handle (const std::string &nm)
octave_value get_global_value (const std::string &nm, bool silent)
void set_global_value (const std::string &nm, const octave_value &val)
octave_value set_internal_variable (bool &var, const octave_value_list &args, int nargout, const char *nm)
octave_value set_internal_variable (char &var, const octave_value_list &args, int nargout, const char *nm)
octave_value set_internal_variable (int &var, const octave_value_list &args, int nargout, const char *nm, int minval, int maxval)
octave_value set_internal_variable (double &var, const octave_value_list &args, int nargout, const char *nm, double minval, double maxval)
octave_value set_internal_variable (std::string &var, const octave_value_list &args, int nargout, const char *nm, bool empty_ok)
std::string get_dims_str (const octave_value &val)
 DEFUN (who, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Command} {} who\n\ @deftypefnx {Command} {} who pattern @dots{}\n\ @deftypefnx {Command} {} who option pattern @dots{}\n\ @deftypefnx {Command} {C =} who(\"pattern\", @dots{})\n\ List currently defined variables matching the given patterns. Valid\n\ pattern syntax is the same as described for the @code{clear} command.\n\ If no patterns are supplied, all variables are listed.\n\ By default, only variables visible in the local scope are displayed.\n\ \n\ The following are valid options but may not be combined.\n\ \n\ @table @code\n\ @item global\n\ List variables in the global scope rather than the current scope.\n\ @item -regexp\n\ The patterns are considered to be regular expressions when matching the\n\ variables to display. The same pattern syntax accepted by\n\ the @code{regexp} function is used.\n\ @item -file\n\ The next argument is treated as a filename. All variables found within the\n\ specified file are listed. No patterns are accepted when reading variables\n\ from a file.\n\ @end table\n\ \n\ If called as a function, return a cell array of defined variable names\n\ matching the given patterns.\n\ @seealso{whos, regexp}\n\ @end deftypefn")
 DEFUN (whos, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Command} {} whos\n\ @deftypefnx {Command} {} whos pattern @dots{}\n\ @deftypefnx {Command} {} whos option pattern @dots{}\n\ @deftypefnx {Command} {S =} whos(\"pattern\", @dots{})\n\ Provide detailed information on currently defined variables matching the\n\ given patterns. Options and pattern syntax are the same as for the\n\ @code{who} command. Extended information about each variable is\n\ summarized in a table with the following default entries.\n\ \n\ @table @asis\n\ @item Attr\n\ Attributes of the listed variable. Possible attributes are:\n\ @table @asis\n\ @item blank\n\ Variable in local scope\n\ @item @code{g}\n\ Variable with global scope\n\ @item @code{p}\n\ Persistent variable\n\ @end table\n\ @item Name\n\ The name of the variable.\n\ @item Size\n\ The logical size of the variable. A scalar is 1x1, a vector is 1xN or Nx1,\n\ a 2-D matrix is MxN.\n\ @item Bytes\n\ The amount of memory currently used to store the variable.\n\ @item Class\n\ The class of the variable. Examples include double, single, char, uint16,\n\ cell, and struct.\n\ @end table\n\ \n\ The table can be customized to display more or less information through\n\ the function @code{whos_line_format}.\n\ \n\ If @code{whos} is called as a function, return a struct array of defined\n\ variable names matching the given patterns. Fields in the structure\n\ describing each variable are: name, size, bytes, class, global, sparse, \n\ complex, nesting, persistent.\n\ @seealso{who, whos_line_format}\n\ @end deftypefn")
void bind_ans (const octave_value &val, bool print)
void bind_internal_variable (const std::string &fname, const octave_value &val)
void mlock (void)
void munlock (const std::string &nm)
bool mislocked (const std::string &nm)
 DEFUN (mlock, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} mlock ()\n\ Lock the current function into memory so that it can't be cleared.\n\ @seealso{munlock, mislocked, persistent}\n\ @end deftypefn")
 DEFUN (munlock, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} munlock (@var{fcn})\n\ Unlock the named function. If no function is named\n\ then unlock the current function.\n\ @seealso{mlock, mislocked, persistent}\n\ @end deftypefn")
 DEFUN (mislocked, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} mislocked (@var{fcn})\n\ Return true if the named function is locked. If no function is named\n\ then return true if the current function is locked.\n\ @seealso{mlock, munlock, persistent}\n\ @end deftypefn")
 DEFUN (clear, args,,"-*- texinfo -*-\n\ @deffn {Command} clear [options] pattern @dots{}\n\ Delete the names matching the given patterns from the symbol table. The\n\ pattern may contain the following special characters:\n\ \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 @samp{[a-zA-Z]} will\n\ match all lower and upper case alphabetic characters.\n\ @end table\n\ \n\ For example, the command\n\ \n\ @example\n\ clear foo b*r\n\ @end example\n\ \n\ @noindent\n\ clears the name @code{foo} and all names that begin with the letter\n\ @code{b} and end with the letter @code{r}.\n\ \n\ If @code{clear} is called without any arguments, all user-defined\n\ variables (local and global) are cleared from the symbol table. If\n\ @code{clear} is called with at least one argument, only the visible\n\ names matching the arguments are cleared. For example, suppose you have\n\ defined a function @code{foo}, and then hidden it by performing the\n\ assignment @code{foo = 2}. Executing the command @kbd{clear foo} once\n\ will clear the variable definition and restore the definition of\n\ @code{foo} as a function. Executing @kbd{clear foo} a second time will\n\ clear the function definition.\n\ \n\ The following options are available in both long and short form\n\ @table @code\n\ @item -all, -a\n\ Clears all local and global user-defined variables and all functions\n\ from the symbol table.\n\ \n\ @item -exclusive, -x\n\ Clears the variables that don't match the following pattern.\n\ \n\ @item -functions, -f\n\ Clears the function names and the built-in symbols names.\n\ @item -global, -g\n\ Clears the global symbol names.\n\ @item -variables, -v\n\ Clears the local variable names.\n\ @item -classes, -c\n\ Clears the class structure table and clears all objects.\n\ @item -regexp, -r\n\ The arguments are treated as regular expressions as any variables that\n\ match will be cleared.\n\ @end table\n\ With the exception of @code{exclusive}, all long options can be used \n\ without the dash as well.\n\ @end deffn")
 DEFUN (whos_line_format, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} whos_line_format ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} whos_line_format (@var{new_val})\n\ Query or set the format string used by the command @code{whos}.\n\ \n\ A full format string is:\n\ \n\ @c Set example in small font to prevent overfull line\n\ @smallexample\n\ %[modifier]<command>[:width[:left-min[:balance]]];\n\ @end smallexample\n\ \n\ The following command sequences are available:\n\ \n\ @table @code\n\ @item %a\n\ Prints attributes of variables (g=global, p=persistent,\n\ f=formal parameter, a=automatic variable).\n\ @item %b\n\ Prints number of bytes occupied by variables.\n\ @item %c\n\ Prints class names of variables.\n\ @item %e\n\ Prints elements held by variables.\n\ @item %n\n\ Prints variable names.\n\ @item %s\n\ Prints dimensions of variables.\n\ @item %t\n\ Prints type names of variables.\n\ @end table\n\ \n\ Every command may also have an alignment modifier:\n\ \n\ @table @code\n\ @item l\n\ Left alignment.\n\ @item r\n\ Right alignment (default).\n\ @item c\n\ Column-aligned (only applicable to command %s).\n\ @end table\n\ \n\ The @code{width} parameter is a positive integer specifying the minimum\n\ number of columns used for printing. No maximum is needed as the field will\n\ auto-expand as required.\n\ \n\ The parameters @code{left-min} and @code{balance} are only available when the\n\ column-aligned modifier is used with the command @samp{%s}.\n\ @code{balance} specifies the column number within the field width which will\n\ be aligned between entries. Numbering starts from 0 which indicates the\n\ leftmost column. @code{left-min} specifies the minimum field width to the\n\ left of the specified balance column.\n\ \n\ The default format is\n\ @code{\" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\\n\"}.\n\ @seealso{whos}\n\ @end deftypefn")

Define Documentation

#define CLEAR_OPTION_ERROR ( cond   ) 

Value:

do \
    { \
      if (cond) \
        { \
          print_usage (); \
          return retval; \
        } \
    } \
  while (0)

#define GET_IDX ( LEN   )     static_cast<int> ((LEN-1) * static_cast<double> (rand ()) / RAND_MAX)


Function Documentation

void bind_ans ( const octave_value val,
bool  print 
)

void bind_internal_variable ( const std::string fname,
const octave_value val 
)

void clear_function ( const std::string nm  ) 

void clear_mex_functions ( void   ) 

void clear_symbol ( const std::string nm  ) 

void clear_variable ( const std::string nm  ) 

DEFUN ( whos_line_format  ,
args  ,
nargout   
)

DEFUN ( clear  ,
args   
)

DEFUN ( mislocked  ,
args   
)

DEFUN ( munlock  ,
args   
)

DEFUN ( mlock  ,
args   
)

DEFUN ( whos  ,
args  ,
nargout   
)

DEFUN ( who  ,
args  ,
nargout   
)

DEFUN ( exist  ,
args   
)

DEFUN ( is_global  ,
args   
)

DEFUN ( isglobal  ,
args   
)

octave_function* extract_function ( const octave_value arg,
const std::string warn_for,
const std::string fname,
const std::string header,
const std::string trailer 
)

string_vector generate_struct_completions ( const std::string text,
std::string prefix,
std::string hint 
)

std::string get_dims_str ( const octave_value val  ) 

octave_value get_global_value ( const std::string nm,
bool  silent 
)

string_vector get_struct_elts ( const std::string text  ) 

octave_function* is_valid_function ( const octave_value arg,
const std::string warn_for,
bool  warn 
)

octave_function* is_valid_function ( const std::string fcn_name,
const std::string warn_for,
bool  warn 
)

bool looks_like_struct ( const std::string text  ) 

octave_value lookup_function_handle ( const std::string nm  ) 

bool mislocked ( const std::string nm  ) 

void mlock ( void   ) 

void munlock ( const std::string nm  ) 

void set_global_value ( const std::string nm,
const octave_value val 
)

octave_value set_internal_variable ( std::string var,
const octave_value_list args,
int  nargout,
const char *  nm,
bool  empty_ok 
)

octave_value set_internal_variable ( double var,
const octave_value_list args,
int  nargout,
const char *  nm,
double  minval,
double  maxval 
)

octave_value set_internal_variable ( int var,
const octave_value_list args,
int  nargout,
const char *  nm,
int  minval,
int  maxval 
)

octave_value set_internal_variable ( char &  var,
const octave_value_list args,
int  nargout,
const char *  nm 
)

octave_value set_internal_variable ( bool var,
const octave_value_list args,
int  nargout,
const char *  nm 
)

int symbol_exist ( const std::string name,
const std::string type 
)

std::string unique_symbol_name ( const std::string basename  )