fgms 0.11.8
The
FlightGear MultiPlayer Server
project
common.hxx
Go to the documentation of this file.
1 //
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License as
4 // published by the Free Software Foundation; either version 2 of the
5 // License, or (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful, but
8 // WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // General Public License for more details.
11 //
12 // You should have received a copy of the GNU General Public License
13 // along with this program; if not, write to the Free Software
14 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U$
15 //
16 // derived from libcli by David Parrish (david@dparrish.com)
17 // Copyright (C) 2011 Oliver Schroeder
18 //
19 
20 
21 #ifndef CLI_COMMON_H
22 #define CLI_COMMON_H
23 
24 #ifdef __GNUC__
25 # define UNUSED(d) d __attribute__ ((unused))
26 #else
27 # define UNUSED(d) d
28 #endif
29 
30 #include <string.h>
31 #include <stdlib.h>
32 #include <exception>
33 #include <iostream>
34 #include "debug.hxx"
35 
36 #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
37 #define free_z(p) do { if (p) { free (p); (p) = 0; } } while (0)
38 namespace LIBCLI
39 {
40 
42 {
43  OK = 0,
44  ERROR_ANY = -1,
45  QUIT = -2,
46  ERROR_ARG = -3
47 };
48 
50 {
53 };
54 
55 enum MODE
56 {
57  MODE_ANY = -1,
58  MODE_EXEC = 0,
60 };
61 
63 {
64  PRINT_PLAIN = 0x00,
66 };
67 
69 {
72 };
73 
75 {
81 };
82 
83 const int MAX_HISTORY = 256;
84 
85 class arg_error : public std::exception
86 {
87 public:
88  arg_error ( const char* r ) { reason = r; };
89  virtual const char* what() const throw()
90  {
91  return reason;
92  }
93  const char* reason;
94 };
95 
96 class mem_error : public std::exception
97 {
98 public:
99  virtual const char* what() const throw()
100  {
101  return "could not allocate memory";
102  }
103 };
104 
105 }; // namespace LIBCLI
106 
107 #endif
const char * reason
Definition: common.hxx:93
CLI_STATES
Definition: common.hxx:74
const int MAX_HISTORY
Definition: common.hxx:83
RETURN_CODES
Definition: common.hxx:41
virtual const char * what() const
Definition: common.hxx:99
PRIVLEVEL
Definition: common.hxx:49
PRINT_MODE
Definition: common.hxx:62
arg_error(const char *r)
Definition: common.hxx:88
MATCH_MODE
Definition: common.hxx:68
virtual const char * what() const
Definition: common.hxx:89