GNU Octave  3.8.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-2013 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 contents_file_in_path (const std::string&);
70 
71 extern OCTINTERP_API std::string fcn_file_in_path (const std::string&);
72 extern OCTINTERP_API std::string oct_file_in_path (const std::string&);
73 extern OCTINTERP_API std::string mex_file_in_path (const std::string&);
74 
75 extern OCTINTERP_API std::string do_string_escapes (const std::string& s);
76 
77 extern OCTINTERP_API const char *undo_string_escape (char c);
78 
79 extern OCTINTERP_API std::string undo_string_escapes (const std::string& s);
80 
81 extern OCTINTERP_API void
82 check_dimensions (dim_vector& dim, const char *warnfor);
83 
84 extern OCTINTERP_API void
85 get_dimensions (const octave_value& a, const char *warn_for,
86  dim_vector& dim);
87 
88 extern OCTINTERP_API void
89 get_dimensions (const octave_value& a, const octave_value& b,
90  const char *warn_for, octave_idx_type& nr,
91  octave_idx_type& nc);
92 
93 extern OCTINTERP_API void
94 get_dimensions (const octave_value& a,const char *warn_for,
96 
98 dims_to_numel (const dim_vector& dims, const octave_value_list& idx);
99 
100 extern OCTINTERP_API Matrix
102 
105 
106 extern OCTINTERP_API size_t
107 octave_format (std::ostream& os, const char *fmt, ...);
108 
109 extern OCTINTERP_API size_t
110 octave_vformat (std::ostream& os, const char *fmt, va_list args);
111 
112 extern OCTINTERP_API std::string
113 octave_vasprintf (const char *fmt, va_list args);
114 
115 extern OCTINTERP_API std::string octave_asprintf (const char *fmt, ...);
116 
117 extern OCTINTERP_API void octave_sleep (double seconds);
118 
119 extern OCTINTERP_API
122  const char *fun_name, const octave_value_list& args,
123  int nargout);
124 
125 extern OCTINTERP_API
128  const char *fun_name, const octave_value_list& args);
129 
130 class
132 {
133 public:
134 
136  : stream (s), oflags (s.flags ()), oprecision (s.precision ()),
137  owidth (s.width ()), ofill (s.fill ())
138  { }
139 
141 
142 private:
143 
144  std::ios& stream;
145  std::ios::fmtflags oflags;
146  std::streamsize oprecision;
147  int owidth;
148  char ofill;
149 };
150 
151 #endif