MessageReporter.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 libraries 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. #ifndef MessageReporter_INCLUDED
  27. #define MessageReporter_INCLUDED 1
  28. #ifdef __GNUG__
  29. #pragma interface
  30. #endif
  31. #include "types.h"
  32. #include "MessageBuilder.h"
  33. #include "Boolean.h"
  34. #include "OutputCharStream.h"
  35. #include "Message.h"
  36. #include "Location.h"
  37. #include "StringC.h"
  38. #ifdef SP_NAMESPACE
  39. namespace SP_NAMESPACE {
  40. #endif
  41. class SP_API MessageReporter : private MessageBuilder, public Messenger {
  42. public:
  43. enum Option {
  44. openElements = 01,
  45. openEntities = 02,
  46. messageNumbers = 04
  47. };
  48. // The OutputCharStream will be deleted by the MessageReporter
  49. MessageReporter(OutputCharStream *);
  50. ~MessageReporter();
  51. void setMessageStream(OutputCharStream *);
  52. OutputCharStream *releaseMessageStream();
  53. void dispatchMessage(const Message &);
  54. void dispatchMessage(Message &);
  55. virtual Boolean getMessageText(const MessageFragment &, StringC &);
  56. void addOption(Option);
  57. void setProgramName(const StringC &);
  58. void formatMessage(const MessageFragment &,
  59. const Vector<CopyOwner<MessageArg> > &args);
  60. private:
  61. MessageReporter(const MessageReporter &); // undefined
  62. void operator=(const MessageReporter &); // undefined
  63. void appendNumber(unsigned long);
  64. void appendOrdinal(unsigned long);
  65. void appendChars(const Char *, size_t);
  66. void appendOther(const OtherMessageArg *);
  67. void appendFragment(const MessageFragment &);
  68. const ExternalInfo *locationHeader(const Location &loc, Offset &off);
  69. void printLocation(const ExternalInfo *info, Offset off);
  70. OutputCharStream &os();
  71. OutputCharStream *os_;
  72. unsigned options_;
  73. StringC programName_;
  74. };
  75. inline
  76. OutputCharStream &MessageReporter::os()
  77. {
  78. return *os_;
  79. }
  80. inline
  81. void MessageReporter::setProgramName(const StringC &programName)
  82. {
  83. programName_ = programName;
  84. }
  85. inline
  86. OutputCharStream *MessageReporter::releaseMessageStream()
  87. {
  88. OutputCharStream *tem = os_;
  89. os_ = 0;
  90. return tem;
  91. }
  92. #ifdef SP_NAMESPACE
  93. }
  94. #endif
  95. #endif /* not MessageReporter_INCLUDED */