2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Location.h /main/1 1996/07/29 16:56:22 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef Location_INCLUDED
28 #define Location_INCLUDED 1
44 namespace SP_NAMESPACE {
49 class InputSourceOrigin;
57 class SP_API Origin : public Resource {
60 virtual const EntityOrigin *asEntityOrigin() const;
61 virtual const InputSourceOrigin *asInputSourceOrigin() const;
62 virtual const Location &parent() const = 0;
63 virtual Index refLength() const;
64 virtual Boolean origChars(const Char *&) const;
65 virtual Boolean inBracketedTextOpenDelim() const;
66 virtual Boolean inBracketedTextCloseDelim() const;
67 virtual Boolean isNumericCharRef(const Markup *&markup) const;
68 virtual Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const;
69 virtual const EntityDecl *entityDecl() const;
72 class SP_API Location {
75 Location(Origin *, Index);
76 Location(ConstPtr<Origin>, Index);
77 void operator+=(Index i) { index_ += i; }
78 void operator-=(Index i) { index_ -= i; }
79 Index index() const { return index_; }
80 const ConstPtr<Origin> &origin() const { return origin_; }
81 void clear() { origin_.clear(); }
82 void swap(Location &to) {
83 origin_.swap(to.origin_);
84 Index tem = to.index_;
89 ConstPtr<Origin> origin_;
93 class SP_API ExternalInfo {
96 virtual ~ExternalInfo();
99 class SP_API NamedCharRef {
107 NamedCharRef(Index, RefEndType, const StringC &);
108 Index refStartIndex() const;
109 RefEndType refEndType() const;
110 const StringC &origName() const;
111 void set(Index, RefEndType, const Char *, size_t);
113 Index refStartIndex_;
114 RefEndType refEndType_;
118 struct SP_API InputSourceOriginNamedCharRef {
119 InputSourceOriginNamedCharRef() { }
120 ~InputSourceOriginNamedCharRef() { }
121 Index replacementIndex;
122 size_t origNameOffset;
124 NamedCharRef::RefEndType refEndType;
127 class SP_API InputSourceOrigin : public Origin {
130 InputSourceOrigin(const Location &refLocation);
131 const Location &parent() const;
132 const ExternalInfo *externalInfo() const;
133 Offset startOffset(Index ind) const;
134 void noteCharRef(Index replacementIndex, const NamedCharRef &);
135 Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const;
136 void setExternalInfo(ExternalInfo *);
137 virtual Boolean defLocation(Offset off, Location &) const;
138 virtual InputSourceOrigin *copy() const;
139 const InputSourceOrigin *asInputSourceOrigin() const;
140 virtual const StringC *entityName() const;
142 InputSourceOrigin(const InputSourceOrigin &); // undefined
143 void operator=(const InputSourceOrigin &); // undefined
144 size_t nPrecedingCharRefs(Index ind) const;
145 Vector<InputSourceOriginNamedCharRef> charRefs_;
146 StringC charRefOrigNames_;
147 Owner<ExternalInfo> externalInfo_; // 0 for internal entities
148 Location refLocation_; // where referenced from
151 // a delimiter specified in bracketed text
153 class SP_API BracketOrigin : public Origin {
155 enum Position { open, close };
156 BracketOrigin(const Location &, Position);
157 const Location &parent() const;
158 Boolean inBracketedTextOpenDelim() const;
159 Boolean inBracketedTextCloseDelim() const;
165 class SP_API ReplacementOrigin : public Origin {
167 ReplacementOrigin(const Location &, Char origChar);
168 const Location &parent() const;
169 Boolean origChars(const Char *&) const;
175 class SP_API MultiReplacementOrigin : public Origin {
177 MultiReplacementOrigin(const Location &, StringC &origChars);
178 const Location &parent() const;
179 Boolean origChars(const Char *&) const;
186 Index NamedCharRef::refStartIndex() const
188 return refStartIndex_;
192 NamedCharRef::RefEndType NamedCharRef::refEndType() const
198 const StringC &NamedCharRef::origName() const
204 const ExternalInfo *InputSourceOrigin::externalInfo() const
206 return externalInfo_.pointer();
213 #endif /* not Location_INCLUDED */