1/* Copyright (C) 2021 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 35class Emsg; 36class Emsgqueue; 37class StringBuilder; 38 39typedef 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 49class Emsg 50{ 51public: 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 * 60 get_msg () 61 { 62 return text; 63 }; 64 65 Cmsg_warn 66 get_warn () 67 { 68 return warn; 69 }; 70 71 Emsg *next; // next message in a queue 72 73protected: 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 80class Emsgqueue 81{ 82public: 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 94protected: 95 Emsg *first; 96 Emsg *last; 97 char *qname; 98}; 99 100class DbeMessages 101{ 102public: 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 void append_msgs (Vector<Emsg*> *lst); 110}; 111 112#endif /* _EMSG_H */ 113