GNU Octave  8.1.0
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-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_variables_h)
27 #define octave_variables_h 1
28 
29 #include "octave-config.h"
30 
31 class octave_function;
33 
34 class octave_value;
35 class octave_value_list;
36 class octave_builtin;
37 class string_vector;
38 
40 
41 class tree_identifier;
42 
44 
45 #include <limits>
46 #include <string>
47 
48 #include "lo-ieee.h"
49 
50 #include "ov-builtin.h"
51 
52 // The following two functions should be removed or the return type
53 // should be changed when we remove octave_function from the interpreter
54 // interface. See the discussion about this topic here:
55 // https://octave.discourse.group/t/refactoring-octave-value-function-objects-backward-incompatible-change/971
56 
57 extern OCTINTERP_API octave_function *
58 is_valid_function (const octave_value&, const std::string& = "",
59  bool warn = false);
60 
61 extern OCTINTERP_API octave_function *
62 is_valid_function (const std::string&, const std::string& = "",
63  bool warn = false);
64 
66 
67 extern OCTINTERP_API int
68 symbol_exist (const std::string& name, const std::string& type = "any");
69 
70 extern OCTINTERP_API std::string
71 unique_symbol_name (const std::string& basename);
72 
73 extern OCTINTERP_API octave_value
74 set_internal_variable (bool& var, const octave_value_list& args,
75  int nargout, const char *nm);
76 
77 extern OCTINTERP_API octave_value
78 set_internal_variable (char& var, const octave_value_list& args,
79  int nargout, const char *nm);
80 
81 extern OCTINTERP_API octave_value
82 set_internal_variable (int& var, const octave_value_list& args,
83  int nargout, const char *nm,
84  int minval = std::numeric_limits<int>::min (),
85  int maxval = std::numeric_limits<int>::max ());
86 
87 extern OCTINTERP_API octave_value
88 set_internal_variable (double& var, const octave_value_list& args,
89  int nargout, const char *nm,
90  double minval = -octave::numeric_limits<double>::Inf (),
91  double maxval = octave::numeric_limits<double>::Inf ());
92 
93 extern OCTINTERP_API octave_value
94 set_internal_variable (std::string& var, const octave_value_list& args,
95  int nargout, const char *nm, bool empty_ok = true);
96 
97 extern OCTINTERP_API octave_value
98 set_internal_variable (std::string& var, const octave_value_list& args,
99  int nargout, const char *nm, const char **choices);
100 
101 extern OCTINTERP_API octave_value
102 set_internal_variable (int& var, const octave_value_list& args,
103  int nargout, const char *nm, const char **choices);
104 
105 extern OCTINTERP_API std::string
106 maybe_missing_function_hook (const std::string& name);
107 
109 
110 #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
111 
112 OCTAVE_DEPRECATED (7, "use 'octave::symbol_exist' instead")
113 inline int
114 symbol_exist (const std::string& name, const std::string& type = "any")
115 {
116  return octave::symbol_exist (name, type);
117 }
118 
119 OCTAVE_DEPRECATED (7, "use 'octave::unique_symbol_name' instead")
120 inline std::string
121 unique_symbol_name (const std::string& basename)
122 {
124 }
125 
126 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
127 inline octave_value
128 set_internal_variable (bool& var, const octave_value_list& args, int nargout,
129  const char *nm)
130 {
131  return octave::set_internal_variable (var, args, nargout, nm);
132 }
133 
134 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
135 inline octave_value
136 set_internal_variable (char& var, const octave_value_list& args, int nargout,
137  const char *nm)
138 {
139  return octave::set_internal_variable (var, args, nargout, nm);
140 }
141 
142 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
143 inline octave_value
144 set_internal_variable (int& var, const octave_value_list& args, int nargout,
145  const char *nm,
146  int minval = std::numeric_limits<int>::min (),
147  int maxval = std::numeric_limits<int>::max ())
148 {
149  return octave::set_internal_variable (var, args, nargout, nm, minval, maxval);
150 }
151 
152 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
153 inline octave_value
154 set_internal_variable (double& var, const octave_value_list& args, int nargout,
155  const char *nm,
156  double minval = -octave::numeric_limits<double>::Inf (),
157  double maxval = octave::numeric_limits<double>::Inf ())
158 {
159  return octave::set_internal_variable (var, args, nargout, nm, minval, maxval);
160 }
161 
162 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
163 inline octave_value
164 set_internal_variable (std::string& var, const octave_value_list& args,
165  int nargout, const char *nm, bool empty_ok = true)
166 {
167  return octave::set_internal_variable (var, args, nargout, nm, empty_ok);
168 }
169 
170 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
171 inline octave_value
172 set_internal_variable (std::string& var, const octave_value_list& args,
173  int nargout, const char *nm, const char **choices)
174 {
175  return octave::set_internal_variable (var, args, nargout, nm, choices);
176 }
177 
178 OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
179 inline octave_value
180 set_internal_variable (int& var, const octave_value_list& args, int nargout,
181  const char *nm, const char **choices)
182 {
183  return octave::set_internal_variable (var, args, nargout, nm, choices);
184 }
185 
186 OCTAVE_DEPRECATED (7, "use 'octave::maybe_missing_function_hook' instead")
187 inline std::string
188 maybe_missing_function_hook (const std::string& name)
189 {
191 }
192 
193 #endif
194 
195 // The following macros should also be considered obsolete.
196 
197 #define SET_INTERNAL_VARIABLE(NM) \
198  set_internal_variable (V ## NM, args, nargout, #NM)
199 
200 #define SET_NONEMPTY_INTERNAL_STRING_VARIABLE(NM) \
201  set_internal_variable (V ## NM, args, nargout, #NM, false)
202 
203 #define SET_INTERNAL_VARIABLE_WITH_LIMITS(NM, MINVAL, MAXVAL) \
204  set_internal_variable (V ## NM, args, nargout, #NM, MINVAL, MAXVAL)
205 
206 // in the following, CHOICES must be a C string array terminated by null.
207 #define SET_INTERNAL_VARIABLE_CHOICES(NM, CHOICES) \
208  set_internal_variable (V ## NM, args, nargout, #NM, CHOICES)
209 
210 #endif
OCTAVE_END_NAMESPACE(octave)
#define Inf
Definition: Faddeeva.cc:260
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:207
std::string name(void) const
Definition: pt-id.h:73
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
static std::string basename(const std::string &s, bool strip_path=false)
OCTINTERP_API std::string unique_symbol_name(const std::string &basename)
Definition: variables.cc:340
OCTINTERP_API std::string maybe_missing_function_hook(const std::string &name)
Definition: variables.cc:1410
OCTINTERP_API int symbol_exist(const std::string &name, const std::string &type="any")
Definition: variables.cc:328
OCTINTERP_API octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:584
OCTINTERP_API octave_function * is_valid_function(const octave_value &, const std::string &="", bool warn=false)
Definition: variables.cc:101