GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
utils.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_utils_h)
24 #define octave_utils_h 1
25 
26 #include "octave-config.h"
27 
28 #include <cstdarg>
29 
30 #include <iosfwd>
31 #include <string>
32 #include <list>
33 
34 #include "dMatrix.h"
35 #include "lo-utils.h"
36 
37 class octave_value;
38 class octave_value_list;
39 class string_vector;
40 
41 extern OCTINTERP_API bool valid_identifier (const char *s);
42 extern OCTINTERP_API bool valid_identifier (const std::string& s);
43 
44 extern OCTINTERP_API bool
45 same_file (const std::string& f, const std::string& g);
46 
47 extern OCTINTERP_API int almost_match (const std::string& std,
48  const std::string& s,
49  int min_match_len = 1,
50  int case_sens = 1);
51 
52 extern OCTINTERP_API int
53 keyword_almost_match (const char * const *std, int *min_len,
54  const std::string& s, int min_toks_to_match,
55  int max_toks);
56 
57 OCTAVE_DEPRECATED (4.2, "use 'octave_value::isempty' instead")
58 extern OCTINTERP_API int empty_arg (const char *name, octave_idx_type nr,
59  octave_idx_type nc);
60 
61 extern OCTINTERP_API std::string
62 search_path_for_file (const std::string&, const string_vector&);
63 
64 extern OCTINTERP_API string_vector
65 search_path_for_all_files (const std::string&, const string_vector&);
66 
67 extern OCTINTERP_API std::string
68 file_in_path (const std::string&, const std::string&);
69 
70 extern OCTINTERP_API std::string
71 find_data_file_in_load_path (const std::string& fcn,
72  const std::string& file,
73  bool require_regular_file = false);
74 
75 extern OCTINTERP_API std::string contents_file_in_path (const std::string&);
76 
77 extern OCTINTERP_API std::string fcn_file_in_path (const std::string&);
78 
79 OCTAVE_DEPRECATED (4.2, "use 'load_path::find_oct_file' instead")
80 extern OCTINTERP_API std::string oct_file_in_path (const std::string&);
81 
82 OCTAVE_DEPRECATED (4.2, "use 'load_path::find_mex_file' instead")
83 extern OCTINTERP_API std::string mex_file_in_path (const std::string&);
84 
85 extern OCTINTERP_API std::string do_string_escapes (const std::string& s);
86 
87 extern OCTINTERP_API const char * undo_string_escape (char c);
88 
89 extern OCTINTERP_API std::string undo_string_escapes (const std::string& s);
90 
91 extern OCTINTERP_API void
92 check_dimensions (dim_vector& dim, const char *warnfor);
93 
94 extern OCTINTERP_API void
95 get_dimensions (const octave_value& a, const char *warn_for,
96  dim_vector& dim);
97 
98 extern OCTINTERP_API void
100  const char *warn_for, octave_idx_type& nr,
101  octave_idx_type& nc);
102 
103 extern OCTINTERP_API void
104 get_dimensions (const octave_value& a,const char *warn_for,
106 
107 extern OCTINTERP_API octave_idx_type
108 dims_to_numel (const dim_vector& dims, const octave_value_list& idx);
109 
110 extern OCTINTERP_API Matrix
112 
113 extern OCTINTERP_API FloatMatrix
115 
116 extern OCTINTERP_API size_t
117 octave_format (std::ostream& os, const char *fmt, ...);
118 
119 extern OCTINTERP_API size_t
120 octave_vformat (std::ostream& os, const char *fmt, va_list args);
121 
122 extern OCTINTERP_API std::string
123 octave_vasprintf (const char *fmt, va_list args);
124 
125 extern OCTINTERP_API std::string octave_asprintf (const char *fmt, ...);
126 
127 extern OCTINTERP_API void octave_sleep (double seconds);
128 
129 extern OCTINTERP_API
132  const char *fun_name, const octave_value_list& args,
133  int nargout);
134 
135 extern OCTINTERP_API
138  const char *fun_name, const octave_value_list& args);
139 
140 #endif
OCTINTERP_API void octave_sleep(double seconds)
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
OCTINTERP_API std::string oct_file_in_path(const std::string &)
OCTINTERP_API size_t octave_vformat(std::ostream &os, const char *fmt, va_list args)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
OCTINTERP_API std::string undo_string_escapes(const std::string &s)
OCTINTERP_API bool valid_identifier(const char *s)
Definition: utils.cc:74
OCTINTERP_API std::string fcn_file_in_path(const std::string &)
OCTINTERP_API int empty_arg(const char *name, octave_idx_type nr, octave_idx_type nc)
Definition: utils.cc:239
OCTINTERP_API octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx)
STL namespace.
OCTINTERP_API std::string file_in_path(const std::string &, const std::string &)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
s
Definition: file-io.cc:2729
octave_function * fcn
Definition: ov-class.cc:1754
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
OCTINTERP_API std::string contents_file_in_path(const std::string &)
nd deftypefn *std::string name
Definition: sysdep.cc:647
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 std::string octave_asprintf(const char *fmt,...)
OCTINTERP_API std::string octave_vasprintf(const char *fmt, va_list args)
is false
Definition: cellfun.cc:400
OCTINTERP_API std::string search_path_for_file(const std::string &, const string_vector &)
Definition: utils.cc:247
OCTINTERP_API int almost_match(const std::string &std, const std::string &s, int min_match_len=1, int case_sens=1)
Definition: utils.cc:136
OCTINTERP_API bool same_file(const std::string &f, const std::string &g)
Definition: utils.cc:130
Definition: dMatrix.h:36
OCTINTERP_API size_t octave_format(std::ostream &os, const char *fmt,...)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
Definition: sub2ind.cc:255
OCTINTERP_API void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
OCTINTERP_API string_vector search_path_for_all_files(const std::string &, const string_vector &)
Definition: utils.cc:257
OCTINTERP_API FloatMatrix float_identity_matrix(octave_idx_type nr, octave_idx_type nc)
OCTINTERP_API std::string find_data_file_in_load_path(const std::string &fcn, const std::string &file, bool require_regular_file=false)
OCTINTERP_API const char * undo_string_escape(char c)
OCTINTERP_API std::string do_string_escapes(const std::string &s)
OCTINTERP_API Matrix identity_matrix(octave_idx_type nr, octave_idx_type nc)
OCTINTERP_API octave_value_list do_simple_cellfun(octave_value_list(*fun)(const octave_value_list &, int), const char *fun_name, const octave_value_list &args, int nargout)
b
Definition: cellfun.cc:400
OCTINTERP_API std::string mex_file_in_path(const std::string &)
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
OCTINTERP_API void check_dimensions(dim_vector &dim, const char *warnfor)
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
octave::stream os
Definition: file-io.cc:627
OCTINTERP_API int keyword_almost_match(const char *const *std, int *min_len, const std::string &s, int min_toks_to_match, int max_toks)
Definition: utils.cc:152