xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/src/Emsg.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
2    Contributed by Oracle.
3 
4    This file is part of GNU Binutils.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, 51 Franklin Street - Fifth Floor, Boston,
19    MA 02110-1301, USA.  */
20 
21 #ifndef _EMSG_H
22 #define _EMSG_H
23 
24 #include "Emsgnum.h"
25 #include "vec.h"
26 
27 //
28 // The Emsg, experiment message, has as objects I18N'd messages
29 //	in a structure suitable for attaching to and fetching
30 //	from a queue of such messages.  It is intended to
31 //	be used for collector errors, collector warnings, parser
32 //	errors, and er_archive errors that are encountered when
33 //	reading an experiment
34 
35 class Emsg;
36 class Emsgqueue;
37 class StringBuilder;
38 
39 typedef enum
40 {
41   CMSG_WARN = 0,
42   CMSG_ERROR,
43   CMSG_FATAL,
44   CMSG_COMMENT,
45   CMSG_PARSER,
46   CMSG_ARCHIVE
47 } Cmsg_warn;
48 
49 class Emsg
50 {
51 public:
52   friend class Emsgqueue;
53 
54   Emsg (Cmsg_warn w, const char *i18n_text);
55   Emsg (Cmsg_warn w, StringBuilder& sb);
56   Emsg (Cmsg_warn w, int f, const char *param);
57   ~Emsg ();
58 
59   char *
get_msg()60   get_msg ()
61   {
62     return text;
63   };
64 
65   Cmsg_warn
get_warn()66   get_warn ()
67   {
68     return warn;
69   };
70 
71   Emsg *next;       // next message in a queue
72 
73 protected:
74   Cmsg_warn warn;   // error/warning/...
75   int flavor;       // the message flavor
76   char *par;        // the input parameter string
77   char *text;       // The I18N text of the message
78 };
79 
80 class Emsgqueue
81 {
82 public:
83   Emsgqueue (char *);
84   ~Emsgqueue ();
85 
86   void append (Emsg*);
87   Emsg *append (Cmsg_warn w, char *msg);
88   Emsg *find_msg (Cmsg_warn w, char *msg);
89   void appendqueue (Emsgqueue*);
90   Emsg *fetch (void);
91   void clear (void); // empty the queue
92   void mark_clear (void); // mark the queue empty, without touching messages
93 
94 protected:
95   Emsg *first;
96   Emsg *last;
97   char *qname;
98 };
99 
100 class DbeMessages
101 {
102 public:
103   DbeMessages ();
104   ~DbeMessages ();
105   Vector<Emsg*> *msgs;
106   void remove_msg (Emsg *msg);
107   Emsg *get_error ();
108   Emsg *append_msg (Cmsg_warn w, const char *fmt, ...)
109 	__attribute__ ((format (printf, 3, 4)));
110   void append_msgs (Vector<Emsg*> *lst);
111 };
112 
113 #endif  /* _EMSG_H */
114