1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef MessageReporter_INCLUDED
6 #define MessageReporter_INCLUDED 1
7 
8 #ifdef __GNUG__
9 #pragma interface
10 #endif
11 
12 #include "types.h"
13 #include "MessageFormatter.h"
14 #include "Boolean.h"
15 #include "OutputCharStream.h"
16 #include "Message.h"
17 #include "Location.h"
18 #include "StringC.h"
19 
20 #ifdef SP_NAMESPACE
21 namespace SP_NAMESPACE {
22 #endif
23 
24 class SP_API MessageReporter : public MessageFormatter, public Messenger {
25 public:
26   enum Option {
27     openElements = 01,
28     openEntities = 02,
29     messageNumbers = 04
30     };
31   // The OutputCharStream will be deleted by the MessageReporter
32   MessageReporter(OutputCharStream *);
33   ~MessageReporter();
34   void setMessageStream(OutputCharStream *);
35   OutputCharStream *releaseMessageStream();
36   void dispatchMessage(const Message &);
dispatchMessage(Message & tmp_message)37   void dispatchMessage(Message &tmp_message) {
38         dispatchMessage((const Message &)tmp_message);
39   };
40   virtual Boolean getMessageText(const MessageFragment &, StringC &);
41   void addOption(Option);
42   void setProgramName(const StringC &);
43 private:
44   MessageReporter(const MessageReporter &); // undefined
45   void operator=(const MessageReporter &);  // undefined
46 
47   const ExternalInfo *locationHeader(const Location &, Offset &off);
48   const ExternalInfo *locationHeader(const Origin *, Index, Offset &off);
49   void printLocation(const ExternalInfo *info, Offset off);
50   OutputCharStream &os();
51 
52   OutputCharStream *os_;
53   unsigned options_;
54   StringC programName_;
55 };
56 
57 inline
os()58 OutputCharStream &MessageReporter::os()
59 {
60   return *os_;
61 }
62 
63 inline
setProgramName(const StringC & programName)64 void MessageReporter::setProgramName(const StringC &programName)
65 {
66   programName_ = programName;
67 }
68 
69 inline
releaseMessageStream()70 OutputCharStream *MessageReporter::releaseMessageStream()
71 {
72   OutputCharStream *tem = os_;
73   os_ = 0;
74   return tem;
75 }
76 
77 #ifdef SP_NAMESPACE
78 }
79 #endif
80 
81 #endif /* not MessageReporter_INCLUDED */
82