Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / MessageReporter.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: MessageReporter.h /main/1 1996/07/29 16:57:36 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef MessageReporter_INCLUDED
28 #define MessageReporter_INCLUDED 1
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 #include "types.h"
35 #include "MessageBuilder.h"
36 #include "Boolean.h"
37 #include "OutputCharStream.h"
38 #include "Message.h"
39 #include "Location.h"
40 #include "StringC.h"
41
42 #ifdef SP_NAMESPACE
43 namespace SP_NAMESPACE {
44 #endif
45
46 class SP_API MessageReporter : private MessageBuilder, public Messenger {
47 public:
48   enum Option {
49     openElements = 01,
50     openEntities = 02,
51     messageNumbers = 04
52     };
53   // The OutputCharStream will be deleted by the MessageReporter
54   MessageReporter(OutputCharStream *);
55   ~MessageReporter();
56   void setMessageStream(OutputCharStream *);
57   OutputCharStream *releaseMessageStream();
58   void dispatchMessage(const Message &);
59   void dispatchMessage(Message &);
60   virtual Boolean getMessageText(const MessageFragment &, StringC &);
61   void addOption(Option);
62   void setProgramName(const StringC &);
63   void formatMessage(const MessageFragment &,
64                      const Vector<CopyOwner<MessageArg> > &args);
65 private:
66   MessageReporter(const MessageReporter &); // undefined
67   void operator=(const MessageReporter &);  // undefined
68   
69   void appendNumber(unsigned long);
70   void appendOrdinal(unsigned long);
71   void appendChars(const Char *, size_t);
72   void appendOther(const OtherMessageArg *);
73   void appendFragment(const MessageFragment &);
74   const ExternalInfo *locationHeader(const Location &loc, Offset &off);
75   void printLocation(const ExternalInfo *info, Offset off);
76   OutputCharStream &os();
77
78   OutputCharStream *os_;
79   unsigned options_;
80   StringC programName_;
81 };
82
83 inline
84 OutputCharStream &MessageReporter::os()
85 {
86   return *os_;
87 }
88
89 inline
90 void MessageReporter::setProgramName(const StringC &programName)
91 {
92   programName_ = programName;
93 }
94
95 inline
96 OutputCharStream *MessageReporter::releaseMessageStream()
97 {
98   OutputCharStream *tem = os_;
99   os_ = 0;
100   return tem;
101 }
102
103 #ifdef SP_NAMESPACE
104 }
105 #endif
106
107 #endif /* not MessageReporter_INCLUDED */