1 // Copyright (c) 1994, 1997 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef MessageFormatter_INCLUDED
6 #define MessageFormatter_INCLUDED 1
7 
8 #ifdef __GNUG__
9 #pragma interface
10 #endif
11 
12 #include "types.h"
13 #include "MessageBuilder.h"
14 #include "Boolean.h"
15 #include "Message.h"
16 #include "Location.h"
17 #include "StringC.h"
18 #include "OutputCharStream.h"
19 
20 #ifdef SP_NAMESPACE
21 namespace SP_NAMESPACE {
22 #endif
23 
24 class SP_API MessageFormatter {
25 public:
26   MessageFormatter();
27   void formatMessage(const MessageFragment &,
28 		     const Vector<CopyOwner<MessageArg> > &args,
29 		     OutputCharStream &);
30   void formatOpenElements(const Vector<OpenElementInfo> &openElementInfo,
31 			  OutputCharStream &os);
32   virtual Boolean getMessageText(const MessageFragment &, StringC &) = 0;
33   Boolean formatFragment(const MessageFragment &, OutputCharStream &);
34 private:
35   MessageFormatter(const MessageFormatter &); // undefined
36   void operator=(const MessageFormatter &);  // undefined
37 
38   class Builder : public MessageBuilder {
39   public:
Builder(MessageFormatter * formatter,OutputCharStream & os,bool b)40     Builder(MessageFormatter *formatter, OutputCharStream &os, bool b)
41       : formatter_(formatter), os_(&os), argIsCompleteMessage_(b) { }
42     void appendNumber(unsigned long);
43     void appendOrdinal(unsigned long);
44     void appendChars(const Char *, size_t);
45     void appendOther(const OtherMessageArg *);
46     void appendFragment(const MessageFragment &);
47   private:
os()48     OutputCharStream &os() { return *os_; }
49     OutputCharStream *os_;
50     MessageFormatter *formatter_;
51     bool argIsCompleteMessage_;
52   };
53 };
54 
55 #ifdef SP_NAMESPACE
56 }
57 #endif
58 
59 #endif /* not MessageFormatter_INCLUDED */
60