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 libraries 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: Markup.h /main/1 1996/07/29 16:56:43 cde-hp $ */
24 // Copyright (c) 1995 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef Markup_INCLUDED
28 #define Markup_INCLUDED 1
42 namespace SP_NAMESPACE {
47 struct SP_API MarkupItem {
49 MarkupItem(const MarkupItem &);
51 void operator=(const MarkupItem &);
56 ConstPtr<Origin> *origin; // type == entityStart
57 Text *text; // type == literal
58 SdText *sdText; // type == sdLiteral
87 void addDelim(Syntax::DelimGeneral);
88 void addReservedName(Syntax::ReservedName, const InputSource *);
89 void addReservedName(Syntax::ReservedName, const StringC &);
90 void addSdReservedName(Sd::ReservedName, const InputSource *);
91 void addSdReservedName(Sd::ReservedName, const Char *, size_t);
93 void addS(const InputSource *);
95 void addShortref(const InputSource *);
96 void addCommentStart();
97 void addCommentChar(Char);
98 void addName(const InputSource *);
99 void addName(const Char *, size_t);
100 void addNameToken(const InputSource *);
101 void addNumber(const InputSource *);
102 void addAttributeValue(const InputSource *);
103 void addEntityStart(const Ptr<EntityOrigin> &);
105 void addLiteral(const Text &);
106 void addSdLiteral(const SdText &);
107 void changeToAttributeValue(size_t index);
111 Vector<MarkupItem> items_;
112 friend class MarkupIter;
117 class SP_API MarkupIter {
119 MarkupIter(const Markup &);
120 Markup::Type type() const;
121 Boolean valid() const;
123 // This updates a Location.
124 void advance(Location &, const ConstPtr<Syntax> &);
125 size_t index() const;
126 const Char *charsPointer() const;
127 size_t charsLength() const;
128 const Text &text() const;
129 const EntityOrigin *entityOrigin() const; // valid for type == entityStart
130 const SdText &sdText() const;
131 Syntax::DelimGeneral delimGeneral() const;
132 Syntax::ReservedName reservedName() const;
133 Sd::ReservedName sdReservedName() const;
136 Vector<MarkupItem>::const_iterator items_;
150 size_t Markup::size() const
152 return items_.size();
156 Boolean MarkupIter::valid() const
158 return index_ < nItems_;
162 size_t MarkupIter::index() const
168 Markup::Type MarkupIter::type() const
170 return Markup::Type(items_[index_].type);
174 const EntityOrigin *MarkupIter::entityOrigin() const
176 return (*items_[index_].origin)->asEntityOrigin();
180 const Char *MarkupIter::charsPointer() const
182 return chars_ + charIndex_;
186 size_t MarkupIter::charsLength() const
188 return items_[index_].nChars;
192 const Text &MarkupIter::text() const
194 return *items_[index_].text;
198 const SdText &MarkupIter::sdText() const
200 return *items_[index_].sdText;
204 Syntax::DelimGeneral MarkupIter::delimGeneral() const
206 return Syntax::DelimGeneral(items_[index_].index);
210 Syntax::ReservedName MarkupIter::reservedName() const
212 return Syntax::ReservedName(items_[index_].index);
216 Sd::ReservedName MarkupIter::sdReservedName() const
218 return Sd::ReservedName(items_[index_].index);
225 #endif /* not Markup_INCLUDED */