summaryrefslogtreecommitdiff
path: root/ACEXML/parser/parser/Parser.i
blob: 5b6f072fba0a01610c364cd74545b9d41b2def8d (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
//=============================================================================
/**
 *  @file    Parser.i
 *
 *  $Id$
 *
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
 */
//=============================================================================

ACEXML_INLINE ACEXML_ContentHandler *
ACEXML_Parser::getContentHandler (void) const
{
  return this->content_handler_;
}

ACEXML_INLINE ACEXML_DTDHandler *
ACEXML_Parser::getDTDHandler (void) const
{
  return this->dtd_handler_;
}

ACEXML_INLINE ACEXML_EntityResolver *
ACEXML_Parser::getEntityResolver (void) const
{
  return this->entity_resolver_;
}

ACEXML_INLINE ACEXML_ErrorHandler *
ACEXML_Parser::getErrorHandler (void) const
{
  return this->error_handler_;
}

ACEXML_INLINE void
ACEXML_Parser::setContentHandler (ACEXML_ContentHandler *handler)
{
  this->content_handler_ = handler;
}

ACEXML_INLINE void
ACEXML_Parser::setDTDHandler (ACEXML_DTDHandler *handler)
{
  this->dtd_handler_ = handler;
}

ACEXML_INLINE void
ACEXML_Parser::setEntityResolver (ACEXML_EntityResolver *resolver)
{
  this->entity_resolver_ = resolver;
}

ACEXML_INLINE void
ACEXML_Parser::setErrorHandler (ACEXML_ErrorHandler *handler)
{
  this->error_handler_ = handler;
}

ACEXML_INLINE int
ACEXML_Parser::is_whitespace (ACEXML_Char c)
{
  switch (c)
    {
    case 0xa:
    case 0x20:
    case 0x9:
    case 0xd:
      return 1;
    default:
      return 0;
    }
}


ACEXML_INLINE int
ACEXML_Parser::is_whitespace_or_equal (ACEXML_Char c)
{
  return (is_whitespace (c) || c == '=') ? 1 : 0;
}

ACEXML_INLINE int
ACEXML_Parser::is_nonname (ACEXML_Char c)
{
  // Handle this separately as doing so avoids code duplication and enables
  // setting of line and column numbers in one place.
  if (is_whitespace_or_equal (c))
    return 1;

  switch (c)
    {
    case '/':
    case '?':
    case '>':
    case '<':
    case ')':
    case '(':
    case '+':
    case '*':
    case '\'':
    case '"':
    case ',':
    case '|':
      return 1;
    default:
      return 0;
    }
}

ACEXML_INLINE ACEXML_Char
ACEXML_Parser::get (void)
{
  // Using an extra level of indirection so we can
  // manage document location in the future.

  if (this->instream_ != 0)
    {
      ACEXML_Char ch;
      this->instream_->get (ch);
      this->locator_.incrColumnNumber();
      if (ch == 0x0A) {
        this->locator_.incrLineNumber();
        this->locator_.setColumnNumber (0);
      }
      return ch;
    }
  return 0;
}

ACEXML_INLINE ACEXML_Char
ACEXML_Parser::peek (void)
{
  // Using an extra level of indirection so we can
  // manage document location in the future.

  if (this->instream_ != 0)
    return this->instream_->peek ();
  return 0;

}