GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-errno.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2005-2024 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_oct_errno_h)
27 #define octave_oct_errno_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cerrno>
32 #include <map>
33 #include <string>
34 
35 #include "oct-map.h"
36 
37 class
39 {
40 protected:
41 
42  octave_errno ();
43 
44 public:
45 
46  OCTAVE_DISABLE_COPY_MOVE (octave_errno)
47 
48  ~octave_errno () = default;
49 
50  static bool instance_ok ();
51 
52  static void cleanup_instance ()
53  { delete s_instance; s_instance = nullptr; }
54 
55  static int lookup (const std::string& name);
56 
57  static octave_scalar_map list ();
58 
59  static int get () { return errno; }
60 
61  static int set (int val)
62  {
63  int retval = errno;
64  errno = val;
65  return retval;
66  }
67 
68 private:
69 
70  int do_lookup (const std::string& name);
71 
72  octave_scalar_map do_list ();
73 
74  //--------
75 
76  std::map<std::string, int> m_errno_tbl;
77 
78  static octave_errno *s_instance;
79 };
80 
81 #endif
octave_idx_type lookup(const T *x, octave_idx_type n, T y)
static int set(int val)
Definition: oct-errno.h:61
static void cleanup_instance()
Definition: oct-errno.h:52
static int get()
Definition: oct-errno.h:59
~octave_errno()=default