Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / ExternalId.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: ExternalId.h /main/1 1996/07/29 16:51:56 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef ExternalId_INCLUDED
28 #define ExternalId_INCLUDED 1
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include "Boolean.h"
34 #include "StringC.h"
35 #include "Text.h"
36 #include "types.h"
37 #include "Message.h"
38
39 #ifdef SP_NAMESPACE
40 namespace SP_NAMESPACE {
41 #endif
42
43 class CharsetInfo;
44
45 class SP_API PublicId {
46 public:
47   enum TextClass {
48     CAPACITY,
49     CHARSET,
50     DOCUMENT,
51     DTD,
52     ELEMENTS,
53     ENTITIES,
54     LPD,
55     NONSGML,
56     NOTATION,
57     SHORTREF,
58     SUBDOC,
59     SYNTAX,
60     TEXT
61   };
62   enum OwnerType {
63     ISO,
64     registered,
65     unregistered
66     };
67   PublicId();
68
69   Boolean getOwnerType(OwnerType &) const;
70   Boolean getOwner(StringC &) const;
71   Boolean getTextClass(TextClass &) const;
72   Boolean getUnavailable(Boolean &) const;
73   Boolean getDescription(StringC &) const;
74   Boolean getLanguage(StringC &) const;
75   Boolean getDesignatingSequence(StringC &) const;
76   Boolean getDisplayVersion(StringC &) const;
77   // If it's not a valid formal public identifier, return 0
78   // and set error, otherwise return 1.
79   // charset describes the character set to use for parsing the
80   // id.
81   Boolean init(Text &, const CharsetInfo &, Char space,
82                const MessageType1 *&error);
83   const StringC &string() const;
84   const Text &text() const;
85 private:
86   static Boolean nextField(Char solidus,
87                            const Char *&next,
88                            const Char *lim,
89                            const Char *&fieldStart,
90                            size_t &fieldLength);
91   static Boolean lookupTextClass(const StringC &, const CharsetInfo &,
92                                  TextClass &);
93   static const char *const textClasses[];
94
95   PackedBoolean formal_;
96   OwnerType ownerType_;
97   StringC owner_;
98   TextClass textClass_;
99   PackedBoolean unavailable_;
100   StringC description_;
101   StringC languageOrDesignatingSequence_;
102   PackedBoolean haveDisplayVersion_;
103   StringC displayVersion_;
104   Text text_;
105 };
106
107 class SP_API ExternalId {
108 public:
109   ExternalId();
110   const StringC *systemIdString() const;
111   const StringC *publicIdString() const;
112   const StringC &effectiveSystemId() const;
113   const Text *systemIdText() const;
114   const Text *publicIdText() const;
115   const PublicId *publicId() const;
116   void setSystem(Text &);
117   void setEffectiveSystem(StringC &);
118   // If it's not a valid formal public identifier, return 0
119   // and set error, otherwise return 1.
120   // charset describes the character set to use for parsing the
121   // id.
122   Boolean setPublic(Text &, const CharsetInfo &, Char space,
123                     const MessageType1 *&error);
124   void setLocation(const Location &);
125   // location of keyword
126   const Location &location() const;
127 private:
128   PackedBoolean haveSystem_;
129   PackedBoolean havePublic_;
130   Text system_;
131   PublicId public_;
132   Location loc_;
133   StringC effectiveSystem_;
134 };
135
136 inline
137 const StringC &PublicId::string() const
138 {
139   return text_.string();
140 }
141
142 inline
143 const Text &PublicId::text() const
144 {
145   return text_;
146 }
147
148 inline
149 const StringC *ExternalId::systemIdString() const
150 {
151   return haveSystem_ ? &system_.string() : 0;
152 }
153
154 inline
155 const StringC *ExternalId::publicIdString() const
156 {
157   return havePublic_ ? &public_.string() : 0;
158 }
159
160 inline
161 const Text *ExternalId::systemIdText() const
162 {
163   return haveSystem_ ? &system_ : 0;
164 }
165
166 inline
167 const Text *ExternalId::publicIdText() const
168 {
169   return havePublic_ ? &public_.text() : 0;
170 }
171
172 inline
173 const PublicId *ExternalId::publicId() const
174 {
175   return havePublic_ ? &public_ : 0;
176 }
177
178 inline
179 const Location &ExternalId::location() const
180 {
181   return loc_;
182 }
183
184 inline
185 const StringC &ExternalId::effectiveSystemId() const
186 {
187   return effectiveSystem_;
188 }
189
190 inline
191 void ExternalId::setEffectiveSystem(StringC &str)
192 {
193   str.swap(effectiveSystem_);
194 }
195
196 #ifdef SP_NAMESPACE
197 }
198 #endif
199
200 #endif /* not ExternalId_INCLUDED */