GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
utils.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2015 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_utils_h)
24 #define octave_utils_h 1
25 
26 #include <cstdarg>
27 
28 #include <iosfwd>
29 #include <string>
30 #include <list>
31 
32 #include "dMatrix.h"
33 #include "lo-utils.h"
34 
35 #include "cutils.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 extern OCTINTERP_API int empty_arg (const char *name, octave_idx_type nr,
58  octave_idx_type nc);
59 
60 extern OCTINTERP_API std::string
61 search_path_for_file (const std::string&, const string_vector&);
62 
64 search_path_for_all_files (const std::string&, const string_vector&);
65 
66 extern OCTINTERP_API std::string
67 file_in_path (const std::string&, const std::string&);
68 
69 extern OCTINTERP_API std::string
70 find_data_file_in_load_path (const std::string& fcn,
71  const std::string& file,
72  bool require_regular_file = false);
73 
74 extern OCTINTERP_API std::string contents_file_in_path (const std::string&);
75 
76 extern OCTINTERP_API std::string fcn_file_in_path (const std::string&);
77 extern OCTINTERP_API std::string oct_file_in_path (const std::string&);
78 extern OCTINTERP_API std::string mex_file_in_path (const std::string&);
79 
80 extern OCTINTERP_API std::string do_string_escapes (const std::string& s);
81 
82 extern OCTINTERP_API const char *undo_string_escape (char c);
83 
84 extern OCTINTERP_API std::string undo_string_escapes (const std::string& s);
85 
86 extern OCTINTERP_API void
87 check_dimensions (dim_vector& dim, const char *warnfor);
88 
89 extern OCTINTERP_API void
90 get_dimensions (const octave_value& a, const char *warn_for,
91  dim_vector& dim);
92 
93 extern OCTINTERP_API void
94 get_dimensions (const octave_value& a, const octave_value& b,
95  const char *warn_for, octave_idx_type& nr,
96  octave_idx_type& nc);
97 
98 extern OCTINTERP_API void
99 get_dimensions (const octave_value& a,const char *warn_for,
101 
103 dims_to_numel (const dim_vector& dims, const octave_value_list& idx);
104 
105 extern OCTINTERP_API Matrix
107 
110 
111 extern OCTINTERP_API size_t
112 octave_format (std::ostream& os, const char *fmt, ...);
113 
114 extern OCTINTERP_API size_t
115 octave_vformat (std::ostream& os, const char *fmt, va_list args);
116 
117 extern OCTINTERP_API std::string
118 octave_vasprintf (const char *fmt, va_list args);
119 
120 extern OCTINTERP_API std::string octave_asprintf (const char *fmt, ...);
121 
122 extern OCTINTERP_API void octave_sleep (double seconds);
123 
124 extern OCTINTERP_API
127  const char *fun_name, const octave_value_list& args,
128  int nargout);
129 
130 extern OCTINTERP_API
133  const char *fun_name, const octave_value_list& args);
134 
135 class
137 {
138 public:
139 
141  : stream (s), oflags (s.flags ()), oprecision (s.precision ()),
142  owidth (s.width ()), ofill (s.fill ())
143  { }
144 
146 
147 private:
148 
149  std::ios& stream;
150  std::ios::fmtflags oflags;
151  std::streamsize oprecision;
152  int owidth;
153  char ofill;
154 };
155 
156 #endif
OCTINTERP_API void octave_sleep(double seconds)
Definition: utils.cc:1344
OCTINTERP_API std::string oct_file_in_path(const std::string &)
Definition: utils.cc:561
std::streamsize oprecision
Definition: utils.h:151
OCTINTERP_API size_t octave_vformat(std::ostream &os, const char *fmt, va_list args)
Definition: utils.cc:1301
void fill(const std::string &val)
OCTINTERP_API std::string undo_string_escapes(const std::string &s)
Definition: utils.cc:802
OCTINTERP_API bool valid_identifier(const char *s)
Definition: utils.cc:77
OCTINTERP_API std::string fcn_file_in_path(const std::string &)
Definition: utils.cc:504
OCTINTERP_API int empty_arg(const char *name, octave_idx_type nr, octave_idx_type nc)
Definition: utils.cc:246
OCTINTERP_API octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx)
Definition: utils.cc:1221
STL namespace.
OCTINTERP_API std::string file_in_path(const std::string &, const std::string &)
Definition: utils.cc:452
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
OCTINTERP_API std::string contents_file_in_path(const std::string &)
Definition: utils.cc:539
F77_RET_T const double const double * f
#define OCTINTERP_API
Definition: mexproto.h:66
OCTINTERP_API std::string octave_asprintf(const char *fmt,...)
Definition: utils.cc:1329
OCTINTERP_API std::string octave_vasprintf(const char *fmt, va_list args)
Definition: utils.cc:1311
OCTINTERP_API std::string search_path_for_file(const std::string &, const string_vector &)
Definition: utils.cc:254
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:139
OCTINTERP_API bool same_file(const std::string &f, const std::string &g)
Definition: utils.cc:133
Definition: dMatrix.h:35
OCTINTERP_API size_t octave_format(std::ostream &os, const char *fmt,...)
Definition: utils.cc:1286
std::ios::fmtflags oflags
Definition: utils.h:150
OCTINTERP_API void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
Definition: utils.cc:1141
OCTINTERP_API string_vector search_path_for_all_files(const std::string &, const string_vector &)
Definition: utils.cc:264
OCTINTERP_API FloatMatrix float_identity_matrix(octave_idx_type nr, octave_idx_type nc)
Definition: utils.cc:1270
OCTINTERP_API std::string find_data_file_in_load_path(const std::string &fcn, const std::string &file, bool require_regular_file=false)
Definition: utils.cc:463
OCTINTERP_API const char * undo_string_escape(char c)
Definition: utils.cc:754
OCTINTERP_API std::string do_string_escapes(const std::string &s)
Definition: utils.cc:618
octave_preserve_stream_state(std::ios &s)
Definition: utils.h:140
OCTINTERP_API Matrix identity_matrix(octave_idx_type nr, octave_idx_type nc)
Definition: utils.cc:1254
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)
Definition: utils.cc:1437
OCTINTERP_API std::string mex_file_in_path(const std::string &)
Definition: utils.cc:590
OCTINTERP_API void check_dimensions(dim_vector &dim, const char *warnfor)
Definition: utils.cc:1121
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:155