oct-errno.h

Go to the documentation of this file.
00001 // oct-errno.h.in
00002 /*
00003 
00004 Copyright (C) 2005-2012 John W. Eaton
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #if !defined (octave_errno_h)
00025 #define octave_errno_h 1
00026 
00027 #include <cerrno>
00028 #include <map>
00029 #include <string>
00030 
00031 #include "oct-map.h"
00032 
00033 class
00034 octave_errno
00035 {
00036 protected:
00037 
00038   octave_errno (void);
00039 
00040 public:
00041 
00042   ~octave_errno (void) { }
00043 
00044   static bool instance_ok (void);
00045 
00046   static void cleanup_instance (void) { delete instance; instance = 0; }
00047 
00048   static int lookup (const std::string& name);
00049 
00050   static octave_scalar_map list (void);
00051 
00052   static int get (void) { return errno; }
00053 
00054   static int set (int val)
00055   {
00056     int retval = errno;
00057     errno = val;
00058     return retval;
00059   }
00060 
00061 private:
00062 
00063   std::map<std::string, int> errno_tbl;
00064 
00065   static octave_errno *instance;
00066 
00067   int do_lookup (const std::string& name);
00068 
00069   octave_scalar_map do_list (void);
00070 };
00071 
00072 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines