GNU Octave 7.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-2022 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
31class octave_function;
33
34class octave_value;
36class octave_builtin;
37class string_vector;
38
39namespace octave
40{
41 class tree_identifier;
42}
43
44#include <limits>
45#include <string>
46
47#include "lo-ieee.h"
48
49#include "ov-builtin.h"
50
51// The following two functions should be removed or the return type
52// should be changed when we remove octave_function from the interpreter
53// interface. See the discussion about this topic here:
54// https://octave.discourse.group/t/refactoring-octave-value-function-objects-backward-incompatible-change/971
55
56extern OCTINTERP_API octave_function *
57is_valid_function (const octave_value&, const std::string& = "",
58 bool warn = false);
59
60extern OCTINTERP_API octave_function *
61is_valid_function (const std::string&, const std::string& = "",
62 bool warn = false);
63
64OCTAVE_NAMESPACE_BEGIN
65
66extern OCTINTERP_API int
67symbol_exist (const std::string& name, const std::string& type = "any");
68
69extern OCTINTERP_API std::string
70unique_symbol_name (const std::string& basename);
71
72extern OCTINTERP_API octave_value
73set_internal_variable (bool& var, const octave_value_list& args,
74 int nargout, const char *nm);
75
76extern OCTINTERP_API octave_value
77set_internal_variable (char& var, const octave_value_list& args,
78 int nargout, const char *nm);
79
80extern OCTINTERP_API octave_value
81set_internal_variable (int& var, const octave_value_list& args,
82 int nargout, const char *nm,
83 int minval = std::numeric_limits<int>::min (),
84 int maxval = std::numeric_limits<int>::max ());
85
86extern OCTINTERP_API octave_value
87set_internal_variable (double& var, const octave_value_list& args,
88 int nargout, const char *nm,
89 double minval = -octave::numeric_limits<double>::Inf (),
90 double maxval = octave::numeric_limits<double>::Inf ());
91
92extern OCTINTERP_API octave_value
93set_internal_variable (std::string& var, const octave_value_list& args,
94 int nargout, const char *nm, bool empty_ok = true);
95
96extern OCTINTERP_API octave_value
97set_internal_variable (std::string& var, const octave_value_list& args,
98 int nargout, const char *nm, const char **choices);
99
100extern OCTINTERP_API octave_value
101set_internal_variable (int& var, const octave_value_list& args,
102 int nargout, const char *nm, const char **choices);
103
104extern OCTINTERP_API std::string
105maybe_missing_function_hook (const std::string& name);
106
107OCTAVE_NAMESPACE_END
108
109#if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
110
111OCTAVE_DEPRECATED (7, "use 'octave::symbol_exist' instead")
112inline int
113symbol_exist (const std::string& name, const std::string& type = "any")
114{
115 return octave::symbol_exist (name, type);
116}
117
118OCTAVE_DEPRECATED (7, "use 'octave::unique_symbol_name' instead")
119inline std::string
120unique_symbol_name (const std::string& basename)
121{
123}
124
125OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
126inline octave_value
127set_internal_variable (bool& var, const octave_value_list& args, int nargout, const char *nm)
128{
129 return octave::set_internal_variable (var, args, nargout, nm);
130}
131
132OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
133inline octave_value
134set_internal_variable (char& var, const octave_value_list& args, int nargout, const char *nm)
135{
136 return octave::set_internal_variable (var, args, nargout, nm);
137}
138
139OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
140inline octave_value
141set_internal_variable (int& var, const octave_value_list& args, int nargout, const char *nm,
142 int minval = std::numeric_limits<int>::min (), int maxval = std::numeric_limits<int>::max ())
143{
144 return octave::set_internal_variable (var, args, nargout, nm, minval, maxval);
145}
146
147OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
148inline octave_value
149set_internal_variable (double& var, const octave_value_list& args, int nargout, const char *nm,
150 double minval = -octave::numeric_limits<double>::Inf (),
151 double maxval = octave::numeric_limits<double>::Inf ())
152{
153 return octave::set_internal_variable (var, args, nargout, nm, minval, maxval);
154}
155
156OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
157inline octave_value
158set_internal_variable (std::string& var, const octave_value_list& args, int nargout, const char *nm,
159 bool empty_ok = true)
160{
161 return octave::set_internal_variable (var, args, nargout, nm, empty_ok);
162}
163
164OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
165inline octave_value
166set_internal_variable (std::string& var, const octave_value_list& args, int nargout, const char *nm,
167 const char **choices)
168{
169 return octave::set_internal_variable (var, args, nargout, nm, choices);
170}
171
172OCTAVE_DEPRECATED (7, "use 'octave::set_internal_variable' instead")
173inline octave_value
174set_internal_variable (int& var, const octave_value_list& args, int nargout, const char *nm,
175 const char **choices)
176{
177 return octave::set_internal_variable (var, args, nargout, nm, choices);
178}
179
180OCTAVE_DEPRECATED (7, "use 'octave::maybe_missing_function_hook' instead")
181inline std::string
182maybe_missing_function_hook (const std::string& name)
183{
185}
186
187OCTAVE_DEPRECATED (6, "use 'octave::get_function_handle' instead")
188extern OCTINTERP_API octave_function *
189extract_function (const octave_value& arg, const std::string& warn_for,
190 const std::string& fname, const std::string& header,
191 const std::string& trailer);
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
#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
QString name
static std::string basename(const std::string &s, bool strip_path=false)
STL namespace.
OCTAVE_NAMESPACE_END 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:1532
OCTAVE_NAMESPACE_BEGIN OCTINTERP_API int symbol_exist(const std::string &name, const std::string &type="any")
Definition: variables.cc:329
OCTINTERP_API octave_function * is_valid_function(const octave_value &, const std::string &="", bool warn=false)
Definition: variables.cc:102
OCTINTERP_API std::string unique_symbol_name(const std::string &basename)
Definition: variables.cc:341
OCTINTERP_API std::string maybe_missing_function_hook(const std::string &name)
Definition: variables.cc:1413
OCTINTERP_API octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:587