OutputState.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: OutputState.h /main/1 1996/07/29 16:59:49 cde-hp $ */
  24. // Copyright (c) 1994 James Clark
  25. // See the file COPYING for copying permission.
  26. #ifndef OutputState_INCLUDED
  27. #define OutputState_INCLUDED 1
  28. #ifdef __GNUG__
  29. #pragma interface
  30. #endif
  31. #include "Location.h"
  32. #include "IList.h"
  33. #include "Link.h"
  34. #include "Boolean.h"
  35. #include "types.h"
  36. #include "EventsWanted.h"
  37. #ifdef SP_NAMESPACE
  38. namespace SP_NAMESPACE {
  39. #endif
  40. struct OutputStateLevel : public Link {
  41. OutputStateLevel();
  42. Boolean hasPendingRe() const;
  43. char state; // should be OutputState::State
  44. unsigned long reSerial;
  45. Location reLocation;
  46. };
  47. class EventHandler;
  48. class Allocator;
  49. class OutputState {
  50. public:
  51. OutputState();
  52. void init();
  53. void handleRe(EventHandler &, Allocator &, const EventsWanted &,
  54. Char, const Location &);
  55. void noteRs(EventHandler &, Allocator &, const EventsWanted &);
  56. void noteMarkup(EventHandler &, Allocator &, const EventsWanted &);
  57. void noteData(EventHandler &, Allocator &, const EventsWanted &);
  58. void noteStartElement(Boolean included,
  59. EventHandler &, Allocator &, const EventsWanted &);
  60. void noteEndElement(Boolean included,
  61. EventHandler &, Allocator &, const EventsWanted &);
  62. private:
  63. OutputState(const OutputState &); // undefined
  64. void operator=(const OutputState &); // undefined
  65. enum State {
  66. afterStartTag,
  67. afterRsOrRe,
  68. afterData,
  69. pendingAfterRsOrRe,
  70. pendingAfterMarkup
  71. };
  72. IList<OutputStateLevel> stack_;
  73. OutputStateLevel &top();
  74. Char re_;
  75. unsigned long nextSerial_;
  76. friend struct OutputStateLevel;
  77. };
  78. inline
  79. Boolean OutputStateLevel::hasPendingRe() const
  80. {
  81. return int(state) >= int(OutputState::pendingAfterRsOrRe);
  82. }
  83. inline
  84. OutputStateLevel &OutputState::top()
  85. {
  86. return *stack_.head();
  87. }
  88. #ifdef SP_NAMESPACE
  89. }
  90. #endif
  91. #endif /* not OutputState_INCLUDED */