Xalan-C++ API Reference 1.12.0
XalanLocator.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(XALANLOCATOR_HEADER_GUARD_1357924680)
19#define XALANLOCATOR_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
28#include <xercesc/sax/Locator.hpp>
29
30
31
32namespace XALAN_CPP_NAMESPACE {
33
34
35
36using xercesc::Locator;
37
38
39
40/**
41 * This class defines a base class for Locator derivations in Xalan. It was defined
42 * because Xerces made changes in their Locator class which caused turbulence.
43 */
45{
46public:
47
48 typedef Locator ParentType;
49
51
52 virtual
54
55 virtual const XMLCh*
56 getPublicId() const = 0;
57
58 virtual const XMLCh*
59 getSystemId() const = 0;
60
61 virtual XalanFileLoc
62 getLineNumber() const = 0;
63
64 virtual XalanFileLoc
65 getColumnNumber() const = 0;
66
67 /**
68 * Get the public identifier from a locator object.
69 * @param theLocator A locator object inherited from Xerces.
70 * @param theAlternateId A default name for a public identifier.
71 * @return a null terminated XalanDOMChar string.
72 */
73 static const XalanDOMChar*
75 const Locator* theLocator,
76 const XalanDOMChar* theAlternateId = getEmptyPtr())
77 {
78 return theLocator == 0 ? theAlternateId : (theLocator->getPublicId() ?
79 theLocator->getPublicId() : theAlternateId);
80 }
81
82 /**
83 * Get the system identifier from a locator object.
84 * @param theLocator A locator object inherited from Xerces.
85 * @param theAlternateId A default name for a public identifier.
86 * @return a null terminated XalanDOMChar string.
87 */
88 static const XalanDOMChar*
90 const Locator* theLocator,
91 const XalanDOMChar* theAlternateId = getEmptyPtr())
92 {
93 return theLocator == 0 ? theAlternateId : (theLocator->getSystemId() ?
94 theLocator->getSystemId() : theAlternateId);
95 }
96
97 /**
98 * Get the line number from a locator object.
99 */
100 static XalanFileLoc
102 {
103 return theLocator == 0 ? getUnknownValue() : theLocator->getLineNumber();
104 }
105
106 /**
107 * Get the column number from a locator object.
108 */
109 static XalanFileLoc
111 {
112 return theLocator == 0 ? getUnknownValue() : theLocator->getColumnNumber();
113 }
114
115 static XalanFileLoc
117 {
118 // The parser reports the maximum value of the XalanFileLoc
119 // type for an unknown value.
121 }
122
123 static XalanFileLoc
125 {
126 // The parser reports the maximum value of the XalanFileLoc
127 // type for an unknown value, but that is really non-sensical
128 // for display purposes, so we use 0 instead.
129 return static_cast<XalanFileLoc>(0);
130 }
131
132 static bool
134 {
135 return theLocation == getUnknownValue();
136 }
137
138private:
139
140 // Not defined...
142
144 operator=(const XalanLocator&);
145
146 /**
147 * Return static pointer to null XalanDOMChar.
148 * This is crafted to overcome issues with compilers/linkers that
149 * have problems initializing static integer members within a class.
150 *
151 * Replaces: static const int s_zero = 0;
152 * Reference: &s_zero;
153 */
154 static const XalanDOMChar * getEmptyPtr()
155 {
156 static const XalanDOMChar theZero = 0;
157 static const XalanDOMChar * theEmpty = &theZero;
158 return theEmpty;
159 }
160};
161
162}
163
164
165
166#endif // PREFIXRESOLVER_HEADER_GUARD_1357924680
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
This class defines a base class for Locator derivations in Xalan.
virtual XalanFileLoc getLineNumber() const =0
static XalanFileLoc getUnknownDisplayValue()
virtual const XMLCh * getSystemId() const =0
virtual XalanFileLoc getColumnNumber() const =0
static bool isUnknownValue(XalanFileLoc theLocation)
static const XalanDOMChar * getPublicId(const Locator *theLocator, const XalanDOMChar *theAlternateId=getEmptyPtr())
Get the public identifier from a locator object.
virtual const XMLCh * getPublicId() const =0
static XalanFileLoc getLineNumber(const ParentType *theLocator)
Get the line number from a locator object.
static XalanFileLoc getColumnNumber(const ParentType *theLocator)
Get the column number from a locator object.
static XalanFileLoc getUnknownValue()
static const XalanDOMChar * getSystemId(const Locator *theLocator, const XalanDOMChar *theAlternateId=getEmptyPtr())
Get the system identifier from a locator object.