GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
variables.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_variables_h)
24 #define octave_variables_h 1
25 
26 #include "octave-config.h"
27 
28 class octave_function;
30 
31 class octave_value;
32 class octave_value_list;
33 class octave_builtin;
34 class string_vector;
35 
36 namespace octave
37 {
38  class tree_identifier;
39 }
40 
41 #include <limits>
42 #include <string>
43 
44 #include "lo-ieee.h"
45 
46 #include "ov-builtin.h"
47 
48 extern OCTINTERP_API octave_function *
49 is_valid_function (const octave_value&, const std::string& = "",
50  bool warn = false);
51 
52 extern OCTINTERP_API octave_function *
53 is_valid_function (const std::string&, const std::string& = "",
54  bool warn = false);
55 
56 extern OCTINTERP_API octave_function *
57 extract_function (const octave_value& arg, const std::string& warn_for,
58  const std::string& fname, const std::string& header,
59  const std::string& trailer);
60 
61 extern OCTINTERP_API string_vector
63 
64 extern OCTINTERP_API string_vector
66  std::string& hint);
67 
68 extern OCTINTERP_API bool
69 looks_like_struct (const std::string& text, char prev_char);
70 
71 extern OCTINTERP_API int
72 symbol_exist (const std::string& name, const std::string& type = "any");
73 
74 extern OCTINTERP_API std::string
76 
77 extern OCTINTERP_API octave_value
78 set_internal_variable (bool& var, const octave_value_list& args,
79  int nargout, const char *nm);
80 
81 extern OCTINTERP_API octave_value
82 set_internal_variable (char& var, const octave_value_list& args,
83  int nargout, const char *nm);
84 
85 extern OCTINTERP_API octave_value
87  int nargout, const char *nm,
88  int minval = std::numeric_limits<int>::min (),
89  int maxval = std::numeric_limits<int>::max ());
90 
91 extern OCTINTERP_API octave_value
92 set_internal_variable (double& var, const octave_value_list& args,
93  int nargout, const char *nm,
94  double minval = -octave::numeric_limits<double>::Inf (),
95  double maxval = octave::numeric_limits<double>::Inf ());
96 
97 extern OCTINTERP_API octave_value
99  int nargout, const char *nm, bool empty_ok = true);
100 
101 extern OCTINTERP_API octave_value
103  int nargout, const char *nm, const char **choices);
104 
105 extern OCTINTERP_API octave_value
106 set_internal_variable (int& var, const octave_value_list& args,
107  int nargout, const char *nm, const char **choices);
108 
109 #define SET_INTERNAL_VARIABLE(NM) \
110  set_internal_variable (V ## NM, args, nargout, #NM)
111 
112 #define SET_NONEMPTY_INTERNAL_STRING_VARIABLE(NM) \
113  set_internal_variable (V ## NM, args, nargout, #NM, false)
114 
115 #define SET_INTERNAL_VARIABLE_WITH_LIMITS(NM, MINVAL, MAXVAL) \
116  set_internal_variable (V ## NM, args, nargout, #NM, MINVAL, MAXVAL)
117 
118 // in the following, CHOICES must be a C string array terminated by null.
119 #define SET_INTERNAL_VARIABLE_CHOICES(NM, CHOICES) \
120  set_internal_variable (V ## NM, args, nargout, #NM, CHOICES)
121 
122 extern OCTINTERP_API void maybe_missing_function_hook (const std::string& name);
123 
124 OCTAVE_DEPRECATED (4.4, "use 'interpreter::mlock' instead")
125 extern OCTINTERP_API void mlock (void);
126 
127 OCTAVE_DEPRECATED (4.4, "use 'interpreter::munlock' instead")
128 extern OCTINTERP_API void munlock (const std::string&);
129 
130 OCTAVE_DEPRECATED (4.4, "use 'interpreter::mislocked' instead")
131 extern OCTINTERP_API bool mislocked (const std::string&);
132 
133 OCTAVE_DEPRECATED (4.4, "use 'tree_evaluator::bind_ans' instead")
134 extern OCTINTERP_API void bind_ans (const octave_value& val, bool print);
135 
136 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::clear_mex_functions' instead")
137 extern OCTINTERP_API void clear_mex_functions (void);
138 
139 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::clear_function' instead")
140 extern OCTINTERP_API void clear_function (const std::string& nm);
141 
142 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::clear_variable' instead")
143 extern OCTINTERP_API void clear_variable (const std::string& nm);
144 
145 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::clear_symbol' instead")
146 extern OCTINTERP_API void clear_symbol (const std::string& nm);
147 
148 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::varval' instead")
149 extern OCTINTERP_API octave_value
150 lookup_function_handle (const std::string& nm);
151 
152 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::global_varval' instead")
153 extern OCTINTERP_API octave_value
154 get_global_value (const std::string& nm, bool silent = false);
155 
156 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::global_assign' instead")
157 extern OCTINTERP_API void
158 set_global_value (const std::string& nm, const octave_value& val);
159 
160 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::top_level_varval' instead")
161 extern OCTINTERP_API octave_value
162 get_top_level_value (const std::string& nm, bool silent = false);
163 
164 OCTAVE_DEPRECATED (4.4, "use 'symbol_table::top_level_assign' instead")
165 extern OCTINTERP_API void
166 set_top_level_value (const std::string& nm, const octave_value& val);
167 
168 #endif
OCTINTERP_API void clear_function(const std::string &nm)
OCTINTERP_API void set_top_level_value(const std::string &nm, const octave_value &val)
OCTINTERP_API void clear_symbol(const std::string &nm)
OCTINTERP_API int symbol_exist(const std::string &name, const std::string &type="any")
Definition: variables.cc:486
OCTINTERP_API string_vector generate_struct_completions(const std::string &text, std::string &prefix, std::string &hint)
Definition: variables.cc:218
fname
Definition: load-save.cc:767
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
OCTINTERP_API void clear_variable(const std::string &nm)
OCTINTERP_API std::string unique_symbol_name(const std::string &basename)
Definition: variables.cc:498
STL namespace.
OCTINTERP_API void maybe_missing_function_hook(const std::string &name)
Definition: variables.cc:2216
static std::string basename(const std::string &s, bool strip_path=false)
var
Definition: givens.cc:88
octave_value arg
Definition: pr-output.cc:3244
OCTINTERP_API octave_value get_top_level_value(const std::string &nm, bool silent=false)
OCTINTERP_API bool looks_like_struct(const std::string &text, char prev_char)
Definition: variables.cc:290
nd deftypefn *std::string name
Definition: sysdep.cc:647
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:975
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:997
OCTINTERP_API bool mislocked(const std::string &)
OCTINTERP_API 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)
Definition: variables.cc:125
OCTINTERP_API octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
is false
Definition: cellfun.cc:400
OCTINTERP_API octave_function * is_valid_function(const octave_value &, const std::string &="", bool warn=false)
Definition: variables.cc:103
OCTINTERP_API octave_value lookup_function_handle(const std::string &nm)
OCTINTERP_API void munlock(const std::string &)
OCTINTERP_API void bind_ans(const octave_value &val, bool print)
idx type
Definition: ov.cc:3114
OCTINTERP_API void set_global_value(const std::string &nm, const octave_value &val)
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:227
#define Inf
Definition: Faddeeva.cc:247
OCTINTERP_API octave_value get_global_value(const std::string &nm, bool silent=false)
OCTINTERP_API string_vector get_struct_elts(const std::string &text)
Definition: variables.cc:164
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:888
OCTINTERP_API void clear_mex_functions(void)
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:204
OCTINTERP_API void mlock(void)