summaryrefslogtreecommitdiff
path: root/ACEXML/parser/debug_validator/Element_Tree.h
blob: a4efdbf1318c23739c400a84e8ea15895d298d74 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Element_Tree.h
 *
 *  $Id$
 *
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
 */
//=============================================================================
#ifndef _ACEXML_ELEMENT_TREE_H_
#define _ACEXML_ELEMENT_TREE_H_

#include /**/ "ace/pre.h"
#include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ACEXML/common/XML_Types.h"

/**
 * @class ACEXML_Element_Tree_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
 *
 * @brief An abstract base class for describing DTD child element definition.
 *
 * @sa ACEXML_Element_Tree_Name_Node, ACEXML_Element_Tree_List_Node
 */
class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Node
{
public:

  /// Default constructor.
  ACEXML_Element_Tree_Node ();

  /// Destructor
  virtual ~ACEXML_Element_Tree_Node ();

  /// Accessor for next element in chain
  ACEXML_Element_Tree_Node *next ();
  void next (ACEXML_Element_Tree_Node *n);

  /// Displaying the content.
  virtual void dump () = 0;

  ACE_ALLOC_HOOK_DECLARE;

protected:
  ACEXML_Element_Tree_Node *next_;
};

/**
 * @class ACEXML_Element_Tree_Name_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
 *
 * @brief An abstract base class for describing a name node in a DTD child
 * element definition.
 *
 * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_List_Node
 */
class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Name_Node
  : public ACEXML_Element_Tree_Node
{
public:
  /// Constructor.
  ACEXML_Element_Tree_Name_Node (const ACEXML_Char *name,
                                 int release = 1);

  /// Change the name of this node.
  void set (const ACEXML_Char *name,
            int release = 1);

  virtual void dump ();

  ACE_ALLOC_HOOK_DECLARE;
protected:
  ACEXML_String name_;
};

class ACEXML_Element_Tree_List_Stack;

/**
 * @class ACEXML_Element_Tree_List_Node Element_Tree.h "parser/debug_validator/Element_Tree.h"
 *
 * @brief An abstract base class for describing a node list in a DTD child
 * element definition.
 *
 * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_Name_Node
 */
class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Node
  : public ACEXML_Element_Tree_Node
{
public:
  friend class ACEXML_Element_Tree_List_Stack;

  typedef enum {
    SEQUENCE,
    CHOICE
  } LIST_TYPE;

  /// Default constructor.
  ACEXML_Element_Tree_List_Node (void);

  /// Destructor.
  virtual ~ACEXML_Element_Tree_List_Node (void);

  /// Insert a new ACEXML_Element_Tree_Node into the list.
  int insert (ACEXML_Element_Tree_Node *node);

  /// Get/set the type of list.
  LIST_TYPE get (void);
  int set (LIST_TYPE type);

  virtual void dump ();

  ACE_ALLOC_HOOK_DECLARE;
protected:
  LIST_TYPE type_;

  ACEXML_Element_Tree_Node *head_;

  ACEXML_Element_Tree_Node *tail_;

  ACEXML_Element_Tree_List_Node *pop_next_;
};

/**
 * @class ACEXML_Element_Tree_List_Stack Element_Tree.h "parser/debug_validator/Element_Tree.h"
 *
 * @brief A class for managing a stack of ACEXML_Element_Tree_List_Node's.
 *
 * @sa ACEXML_Element_Tree_List_Node
 */
class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Stack
{
public:
  ACEXML_Element_Tree_List_Stack ();

  void push (ACEXML_Element_Tree_List_Node *n);

  ACEXML_Element_Tree_List_Node *pop (void);

  ACEXML_Element_Tree_List_Node *top (void);

  int empty (void);

  ACE_ALLOC_HOOK_DECLARE;

protected:
  ACEXML_Element_Tree_List_Node *top_;
};

#if defined (__ACEXML_INLINE__)
# include "ACEXML/parser/debug_validator/Element_Tree.i"
#endif /* __ACEXML_INLINE__ */

#include /**/ "ace/post.h"

#endif /* _ACEXML_ELEMENT_TREE_H_ */