File: MessageReporter.h

package info (click to toggle)
opensp 1.5.2-13
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 8,932 kB
  • ctags: 10,036
  • sloc: cpp: 65,784; ansic: 17,124; sh: 11,503; xml: 2,704; makefile: 926; perl: 561; yacc: 288; sed: 16
file content (110 lines) | stat: -rw-r--r-- 3,193 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.

#ifndef MessageReporter_INCLUDED
#define MessageReporter_INCLUDED 1

#ifdef __GNUG__
#pragma interface
#endif

#include "types.h"
#include "MessageFormatter.h"
#include "Boolean.h"
#include "OutputCharStream.h"
#include "Message.h"
#include "Location.h"
#include "StringC.h"

#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif

class SP_API MessageReporter : public MessageFormatter, public Messenger {
public:
  enum Option {
    openElements = 01,
    openEntities = 02,
    messageNumbers = 04,
    clauses = 010 
    };
  // The OutputCharStream will be deleted by the MessageReporter
  MessageReporter(OutputCharStream *);
  virtual ~MessageReporter();
  void setMessageStream(OutputCharStream *);
  OutputCharStream *releaseMessageStream();
  virtual void dispatchMessage(const Message &);
  virtual Boolean getMessageText(const MessageFragment &, StringC &);
  void addOption(Option);
  void setProgramName(const StringC &);
protected:

#ifndef _MSC_VER
  MessageReporter(const MessageReporter &); // undefined
  void operator=(const MessageReporter &);  // undefined
#endif
  
  virtual const ExternalInfo *locationHeader(const Location &, Offset &off);
  virtual const ExternalInfo *locationHeader(const Origin *, Index, Offset &off);
  virtual void printLocation(const ExternalInfo *info, Offset off);
  OutputCharStream &os();

  OutputCharStream *os_;
  unsigned options_;
  StringC programName_;
};
class SP_API XMLMessageReporter : public MessageReporter {
  long unsigned int id ;
  enum { SP_MESSAGES_NONE, SP_MESSAGES_TRADITIONAL, SP_MESSAGES_XML } msgmode ;
protected:
  virtual void printLocation(const ExternalInfo *info, Offset off);
public:
  XMLMessageReporter(OutputCharStream * o) ; //: MessageReporter(o), id(0) {}
  virtual void dispatchMessage(const Message &);
  virtual Boolean XMLformatFragment(const MessageFragment &, OutputCharStream &);
  virtual void formatMessage(const MessageFragment &,
		     const Vector<CopyOwner<MessageArg> > &args,
		     OutputCharStream &, bool noquote = 0);

  virtual void formatOpenElements(const Vector<OpenElementInfo> &openElementInfo,
			  OutputCharStream &os);
  virtual const ExternalInfo *locationHeader(const Origin *, Index, Offset &off);
  virtual void showOpenEntities(const Origin *, Index, Offset &off) ;
  virtual void showOpenEntities(const Location &loc, Offset &off) {
	showOpenEntities(loc.origin().pointer(), loc.index(), off) ;
  }
  virtual const ExternalInfo *locationHeader(const Location &loc, Offset &off) {
    if ( msgmode == SP_MESSAGES_XML )
	return locationHeader(loc.origin().pointer(), loc.index(), off) ;
    else if ( msgmode == SP_MESSAGES_TRADITIONAL )
	return MessageReporter::locationHeader(loc, off) ;
    return NULL ;
  }

} ;

inline
OutputCharStream &MessageReporter::os()
{
  return *os_;
}

inline
void MessageReporter::setProgramName(const StringC &programName)
{
  programName_ = programName;
}

inline
OutputCharStream *MessageReporter::releaseMessageStream()
{
  OutputCharStream *tem = os_;
  os_ = 0;
  return tem;
}

#ifdef SP_NAMESPACE
}
#endif

#endif /* not MessageReporter_INCLUDED */