123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $XConsortium: SGMLApplication.h /main/1 1996/07/29 17:03:14 cde-hp $ */
- // Copyright (c) 1995 James Clark
- // See the file COPYING for copying permission.
- #ifndef SGMLApplication_INCLUDED
- #define SGMLApplication_INCLUDED 1
- #ifdef __GNUG__
- #pragma interface
- #endif
- #include <stddef.h>
- #ifndef SP_API
- #define SP_API /* as nothing */
- #endif
- class SP_API SGMLApplication {
- public:
- #ifdef SP_MULTI_BYTE
- typedef unsigned short Char;
- #else
- typedef unsigned char Char;
- #endif
- // A Position represents a position in an OpenEntity.
- // The meaning of a Position depends on the
- // particular implementation of OpenEntity.
- // It might be a line number or it might be
- // an offset in the entity. The only thing
- // that can be done with Position is to use
- // it with an OpenEntityPtr to get a Location.
- typedef unsigned long Position;
- struct CharString {
- const Char *ptr;
- size_t len;
- };
- struct ExternalId {
- bool haveSystemId;
- bool havePublicId;
- bool haveGeneratedSystemId;
- CharString systemId; // valid only if haveSystemId is true
- CharString publicId; // valid only if havePublicId is true
- CharString generatedSystemId; // valid if haveGeneratedSystemId is true
- };
- struct Notation {
- CharString name;
- ExternalId externalId;
- };
- struct Attribute;
- struct Entity {
- CharString name;
- enum DataType { sgml, cdata, sdata, ndata, subdoc, pi };
- enum DeclType { general, parameter, doctype, linktype };
- DataType dataType;
- DeclType declType;
- bool isInternal;
- // Following valid if isInternal is true
- CharString text;
- // Following valid if isInternal is false
- ExternalId externalId;
- size_t nAttributes;
- const Attribute *attributes;
- Notation notation;
- };
- struct Attribute {
- CharString name;
- enum Type {
- invalid,
- implied,
- cdata,
- tokenized
- };
- Type type;
- enum Defaulted {
- specified, // not defaulted
- definition, // defaulted from definition
- current // defaulted from current value
- };
- Defaulted defaulted; // non-ESIS; valid only if type != implied
- struct CdataChunk {
- bool isSdata;
- CharString data;
- CharString entityName; // non-ESIS; optional for SDATA chunks
- };
- // Following valid if type == cdata
- size_t nCdataChunks;
- const CdataChunk *cdataChunks; // valid if type == cdata
- // Following valid if type == tokenized
- CharString tokens; // separated by spaces
- bool isId; // non-ESIS (probably)
- bool isGroup; // non-ESIS
- size_t nEntities;
- const Entity *entities;
- // length of notation.name will be 0 if no notation
- Notation notation;
- };
- struct PiEvent {
- Position pos;
- CharString data;
- CharString entityName; // non-ESIS; optional for PI entities
- };
- struct StartElementEvent {
- Position pos;
- enum ContentType {
- empty, // declared EMPTY or with CONREF attribute
- cdata,
- rcdata,
- mixed,
- element
- };
- CharString gi;
- ContentType contentType; // non-ESIS
- bool included; // non-ESIS
- size_t nAttributes;
- const Attribute *attributes;
- };
-
- struct EndElementEvent {
- Position pos;
- CharString gi;
- };
- struct DataEvent {
- Position pos;
- CharString data;
- };
- struct SdataEvent {
- Position pos;
- CharString text;
- CharString entityName; // non-ESIS; optional
- };
- struct ExternalDataEntityRefEvent {
- Position pos;
- Entity entity;
- };
- struct SubdocEntityRefEvent {
- Position pos;
- Entity entity;
- };
- struct ErrorEvent {
- Position pos;
- enum Type {
- info, // not an error
- warning, // not an error
- quantity,
- idref,
- capacity,
- otherError
- };
- Type type;
- CharString message;
- };
- struct AppinfoEvent {
- Position pos;
- bool none;
- CharString string;
- };
- struct StartDtdEvent {
- Position pos;
- CharString name;
- bool haveExternalId;
- ExternalId externalId;
- };
- struct EndDtdEvent {
- Position pos;
- CharString name;
- };
- struct EndPrologEvent {
- Position pos;
- };
- // non-ESIS
- struct GeneralEntityEvent {
- // no position
- Entity entity;
- };
- // non-ESIS
- struct CommentDeclEvent {
- Position pos;
- size_t nComments;
- const CharString *comments;
- const CharString *seps;
- };
- // non-ESIS
- struct MarkedSectionStartEvent {
- Position pos;
- enum Status {
- include,
- rcdata,
- cdata,
- ignore
- };
- Status status;
- struct Param {
- enum Type {
- temp,
- include,
- rcdata,
- cdata,
- ignore,
- entityRef
- };
- Type type;
- CharString entityName;
- };
- size_t nParams;
- const Param *params;
- };
- // non-ESIS
- struct MarkedSectionEndEvent {
- Position pos;
- enum Status {
- include,
- rcdata,
- cdata,
- ignore
- };
- Status status;
- };
- struct IgnoredCharsEvent {
- Position pos;
- CharString data;
- };
- class OpenEntityPtr;
- struct SP_API Location {
- Location();
- Location(const OpenEntityPtr &, Position);
- void init();
- unsigned long lineNumber;
- unsigned long columnNumber;
- unsigned long byteOffset;
- unsigned long entityOffset;
- CharString entityName;
- CharString filename;
- const void *other;
- };
- class OpenEntity;
- class SP_API OpenEntityPtr {
- public:
- OpenEntityPtr();
- OpenEntityPtr(const OpenEntityPtr &);
- void operator=(const OpenEntityPtr &);
- void operator=(OpenEntity *);
- ~OpenEntityPtr();
- const OpenEntity *operator->() const;
- operator int() const;
- private:
- OpenEntity *ptr_;
- };
- class SP_API OpenEntity {
- public:
- OpenEntity();
- virtual ~OpenEntity();
- virtual Location location(Position) const = 0;
- private:
- OpenEntity(const OpenEntity &); // undefined
- void operator=(const OpenEntity &); // undefined
- unsigned count_;
- friend class OpenEntityPtr;
- };
- virtual ~SGMLApplication();
- virtual void appinfo(const AppinfoEvent &);
- virtual void startDtd(const StartDtdEvent &);
- virtual void endDtd(const EndDtdEvent &);
- virtual void endProlog(const EndPrologEvent &);
- virtual void startElement(const StartElementEvent &);
- virtual void endElement(const EndElementEvent &);
- virtual void data(const DataEvent &);
- virtual void sdata(const SdataEvent &);
- virtual void pi(const PiEvent &);
- virtual void externalDataEntityRef(const ExternalDataEntityRefEvent &);
- virtual void subdocEntityRef(const SubdocEntityRefEvent &);
- virtual void commentDecl(const CommentDeclEvent &);
- virtual void markedSectionStart(const MarkedSectionStartEvent &);
- virtual void markedSectionEnd(const MarkedSectionEndEvent &);
- virtual void ignoredChars(const IgnoredCharsEvent &);
- virtual void generalEntity(const GeneralEntityEvent &);
- virtual void error(const ErrorEvent &);
- virtual void openEntityChange(const OpenEntityPtr &);
- };
- inline
- const SGMLApplication::OpenEntity *
- SGMLApplication::OpenEntityPtr::operator->() const
- {
- return ptr_;
- }
- inline
- void SGMLApplication::OpenEntityPtr::operator=(const OpenEntityPtr &ptr)
- {
- *this = ptr.ptr_;
- }
- inline
- SGMLApplication::OpenEntityPtr::operator int() const
- {
- return ptr_ != 0;
- }
- #endif /* not SGMLApplication_INCLUDED */
|