dtcm: Coverity 174711
[oweals/cde.git] / cde / programs / nsgmls / ExtendEntityManager.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 libraries 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: ExtendEntityManager.h /main/1 1996/07/29 16:51:47 cde-hp $ */
24 // Copyright (c) 1994, 1995 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef ExtendEntityManager_INCLUDED
28 #define ExtendEntityManager_INCLUDED 1
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 #include "EntityManager.h"
35 #include "CharsetInfo.h"
36 #include "types.h"
37 #include "Boolean.h"
38 #include "StringC.h"
39 #include "types.h"
40 #include "Vector.h"
41 #include "Location.h"
42
43 #ifdef SP_NAMESPACE
44 namespace SP_NAMESPACE {
45 #endif
46
47 class StorageManager;
48 class InputCodingSystem;
49 class Messenger;
50
51 struct SP_API StorageObjectSpec {
52   StorageObjectSpec();
53   StorageManager *storageManager;
54   const char *codingSystemName;
55   const InputCodingSystem *codingSystem;
56   StringC specId;               // specified id
57   StringC baseId;               // id that specified id is relative to
58   StringC id;                   // actual id used (filled in after opening)
59   enum Records {
60     find,
61     cr,
62     lf,
63     crlf,
64     asis
65     };
66   Records records;
67   PackedBoolean notrack;
68   PackedBoolean zapEof;         // zap a final Ctrl-Z
69   PackedBoolean search;
70 };
71
72 struct SP_API ParsedSystemIdMap {
73   enum Type {
74     catalogDocument,
75     catalogPublic
76   };
77   Type type;
78   StringC publicId;
79 };
80
81 struct SP_API ParsedSystemId : public Vector<StorageObjectSpec> {
82   ParsedSystemId();
83   void unparse(const CharsetInfo &charset, StringC &result) const;
84   Vector<ParsedSystemIdMap> maps;
85 };
86
87 struct SP_API StorageObjectLocation {
88   const StorageObjectSpec *storageObjectSpec;
89   unsigned long lineNumber;
90   unsigned long columnNumber;
91   unsigned long byteIndex;
92   unsigned long storageObjectOffset;
93 };
94
95 class SP_API ExtendEntityManager : public EntityManager {
96 public:
97   class SP_API CatalogManager {
98   public:
99     virtual ~CatalogManager();
100     virtual ConstPtr<EntityCatalog>
101       makeCatalog(StringC &systemId,
102                   const CharsetInfo &charset,
103                   ExtendEntityManager *,
104                   Messenger &) const = 0;
105     virtual Boolean mapCatalog(ParsedSystemId &systemId,
106                                ExtendEntityManager *em,
107                                Messenger &mgr) const = 0;
108   };
109   virtual void registerStorageManager(StorageManager *) = 0;
110   virtual void registerCodingSystem(const char *, const InputCodingSystem *)
111     = 0;
112   virtual void setCatalogManager(CatalogManager *) = 0;
113   virtual InputSource *openIfExists(const StringC &sysid,
114                                     const CharsetInfo &,
115                                     InputSourceOrigin *,
116                                     Boolean mayRewind,
117                                     Messenger &) = 0;
118   virtual Boolean expandSystemId(const StringC &,
119                                  const Location &,
120                                  Boolean isNdata,
121                                  const CharsetInfo &,
122                                  const StringC *mapCatalogPublic,
123                                  Messenger &,
124                                  StringC &) = 0;
125   virtual Boolean mergeSystemIds(const Vector<StringC> &sysids,
126                                  Boolean mapCatalogDocument,
127                                  const CharsetInfo &,
128                                  Messenger &mgr,
129                                  StringC &) const = 0;
130   virtual Boolean parseSystemId(const StringC &str,
131                                 const CharsetInfo &idCharset,
132                                 Boolean isNdata,
133                                 const StorageObjectSpec *defSpec,
134                                 Messenger &mgr,
135                                 ParsedSystemId &parsedSysid) const = 0;
136   static Boolean externalize(const ExternalInfo *,
137                              Offset,
138                              StorageObjectLocation &);
139   static const ParsedSystemId *
140     externalInfoParsedSystemId(const ExternalInfo *);
141   static ExtendEntityManager *make(StorageManager *,
142                                    const InputCodingSystem *);
143 };
144
145 #ifdef SP_NAMESPACE
146 }
147 #endif
148
149 #endif /* not ExtendEntityManager_INCLUDED */