xref: /aoo41x/main/xml2cmp/source/xcd/xmlelem.hxx (revision dd7bc091)
1*dd7bc091SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*dd7bc091SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*dd7bc091SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*dd7bc091SAndrew Rist  * distributed with this work for additional information
6*dd7bc091SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*dd7bc091SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*dd7bc091SAndrew Rist  * "License"); you may not use this file except in compliance
9*dd7bc091SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*dd7bc091SAndrew Rist  *
11*dd7bc091SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*dd7bc091SAndrew Rist  *
13*dd7bc091SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*dd7bc091SAndrew Rist  * software distributed under the License is distributed on an
15*dd7bc091SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*dd7bc091SAndrew Rist  * KIND, either express or implied.  See the License for the
17*dd7bc091SAndrew Rist  * specific language governing permissions and limitations
18*dd7bc091SAndrew Rist  * under the License.
19*dd7bc091SAndrew Rist  *
20*dd7bc091SAndrew Rist  *************************************************************/
21*dd7bc091SAndrew Rist 
22*dd7bc091SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef X2C_XMLELEM_HXX
25cdf0e10cSrcweir #define X2C_XMLELEM_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // USED SERVICES
30cdf0e10cSrcweir 	// BASE CLASSES
31cdf0e10cSrcweir 	// COMPONENTS
32cdf0e10cSrcweir #include "../support/sistr.hxx"
33cdf0e10cSrcweir #include "../support/list.hxx"
34cdf0e10cSrcweir #include "../support/syshelp.hxx"
35cdf0e10cSrcweir 	// PARAMETERS
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class X2CParser;
39cdf0e10cSrcweir class HtmlCreator;
40cdf0e10cSrcweir class Index;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class XmlElement
43cdf0e10cSrcweir {
44cdf0e10cSrcweir   public:
~XmlElement()45cdf0e10cSrcweir 	virtual				~XmlElement() {}
46cdf0e10cSrcweir 	virtual void        Parse(
47cdf0e10cSrcweir 							X2CParser &			io_rParser ) = 0;
48cdf0e10cSrcweir 	virtual void        Write2Html(
49cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const = 0;
50cdf0e10cSrcweir 	virtual void        Insert2Index(
51cdf0e10cSrcweir 							Index & 	        o_rIndex ) const;			// Default: Does nothing, but can be overwritten.
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //	virtual void        Put2Dependy() = 0;
54cdf0e10cSrcweir 
Name() const55cdf0e10cSrcweir 	const Simstr &		Name() const			{ return sName; }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir   protected:
58cdf0e10cSrcweir 						XmlElement(
59cdf0e10cSrcweir 							const char *		i_sName );
60cdf0e10cSrcweir   private:
61cdf0e10cSrcweir 	Simstr 				sName;
62cdf0e10cSrcweir };
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir class MultipleElement : public XmlElement
66cdf0e10cSrcweir {
67cdf0e10cSrcweir   public:
68cdf0e10cSrcweir 						~MultipleElement();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	virtual XmlElement *
71cdf0e10cSrcweir 						FindChild(
72cdf0e10cSrcweir 							const Simstr &		i_sChildName );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir   protected:
76cdf0e10cSrcweir 	typedef DynamicList<XmlElement>			ChildList;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 						MultipleElement(
79cdf0e10cSrcweir 							const char *		i_sName );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	void				AddChild(
82cdf0e10cSrcweir 							XmlElement &		let_drElement );
83cdf0e10cSrcweir 
Children() const84cdf0e10cSrcweir 	const ChildList &	Children() const		{ return aChildren; }
Children()85cdf0e10cSrcweir 	ChildList &			Children()				{ return aChildren; }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir   private:
88cdf0e10cSrcweir 	ChildList			aChildren;
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir class SequenceElement : public MultipleElement
92cdf0e10cSrcweir {
93cdf0e10cSrcweir   public:
94cdf0e10cSrcweir 	virtual void        Parse(
95cdf0e10cSrcweir 							X2CParser &			io_rParser );
96cdf0e10cSrcweir 	virtual void        Write2Html(
97cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir   protected:
100cdf0e10cSrcweir 						SequenceElement(
101cdf0e10cSrcweir 							const char *		i_sName,
102cdf0e10cSrcweir 							unsigned            i_nIndexNameElement = 0 );
103cdf0e10cSrcweir   private:
104cdf0e10cSrcweir 	unsigned			nIndexNameElement;
105cdf0e10cSrcweir };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir class FreeChoiceElement : public MultipleElement
108cdf0e10cSrcweir {
109cdf0e10cSrcweir   public:
110cdf0e10cSrcweir 						FreeChoiceElement();
111cdf0e10cSrcweir 	using				MultipleElement::AddChild;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	virtual void        Parse(
114cdf0e10cSrcweir 							X2CParser &			io_rParser );
115cdf0e10cSrcweir 	virtual void        Write2Html(
116cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
119cdf0e10cSrcweir class ListElement : public MultipleElement
120cdf0e10cSrcweir {
121cdf0e10cSrcweir   public:
122cdf0e10cSrcweir 	typedef XmlElement * (*F_CREATE)(const Simstr &);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 						ListElement(
125cdf0e10cSrcweir 							const char *		i_sElementsName,
126cdf0e10cSrcweir 							F_CREATE            i_fCreateNewElement );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	virtual void        Parse(
129cdf0e10cSrcweir 							X2CParser &			io_rParser );
130cdf0e10cSrcweir 	virtual void        Write2Html(
131cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
132cdf0e10cSrcweir 	virtual XmlElement *
133cdf0e10cSrcweir     					Create_and_Add_NewElement();
134cdf0e10cSrcweir   private:
135cdf0e10cSrcweir 	F_CREATE			fCreateNewElement;
136cdf0e10cSrcweir };
137cdf0e10cSrcweir 
138cdf0e10cSrcweir class TextElement : public XmlElement
139cdf0e10cSrcweir {
140cdf0e10cSrcweir   public:
LinkType() const141cdf0e10cSrcweir 	E_LinkType			LinkType() const		{ return eLinkType; }
IsReversedName() const142cdf0e10cSrcweir 	bool			    IsReversedName() const	{ return bReverseName; }
143cdf0e10cSrcweir   protected:
144cdf0e10cSrcweir 						TextElement(
145cdf0e10cSrcweir 							const char *		i_sName,
146cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
147cdf0e10cSrcweir 							bool				i_bReverseName );
148cdf0e10cSrcweir   private:
149cdf0e10cSrcweir 	E_LinkType			eLinkType;
150cdf0e10cSrcweir 	bool				bReverseName;
151cdf0e10cSrcweir };
152cdf0e10cSrcweir 
153cdf0e10cSrcweir class SglTextElement : public TextElement
154cdf0e10cSrcweir {
155cdf0e10cSrcweir   public:
156cdf0e10cSrcweir 						SglTextElement(
157cdf0e10cSrcweir 							const char *		i_sName,
158cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
159cdf0e10cSrcweir 							bool				i_bReverseName );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	virtual void        Parse(
162cdf0e10cSrcweir 							X2CParser &			io_rParser );
163cdf0e10cSrcweir 	virtual void        Write2Html(
164cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
165cdf0e10cSrcweir 	virtual const Simstr &
Data() const166cdf0e10cSrcweir 						Data() const			{ return sContent; }
167cdf0e10cSrcweir   private:
168cdf0e10cSrcweir 	Simstr				sContent;
169cdf0e10cSrcweir };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir class MultipleTextElement : public TextElement
172cdf0e10cSrcweir {
173cdf0e10cSrcweir   public:
174cdf0e10cSrcweir 						MultipleTextElement(
175cdf0e10cSrcweir 							const char *		i_sName,
176cdf0e10cSrcweir 							E_LinkType			i_eLinkType,
177cdf0e10cSrcweir 							bool				i_bReverseName );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	virtual void        Parse(
180cdf0e10cSrcweir 							X2CParser &			io_rParser );
181cdf0e10cSrcweir 	virtual void        Write2Html(
182cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
183cdf0e10cSrcweir 	virtual const Simstr &
184cdf0e10cSrcweir 						Data(
185cdf0e10cSrcweir 							unsigned 			i_nNr ) const;
Size() const186cdf0e10cSrcweir 	virtual unsigned	Size() const			{ return aContent.size(); }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir   private:
189cdf0e10cSrcweir 	List<Simstr>		aContent;
190cdf0e10cSrcweir };
191cdf0e10cSrcweir 
192cdf0e10cSrcweir class EmptyElement : public XmlElement
193cdf0e10cSrcweir {
194cdf0e10cSrcweir   protected:
195cdf0e10cSrcweir 						EmptyElement(
196cdf0e10cSrcweir 							const char *		i_sName );
197cdf0e10cSrcweir };
198cdf0e10cSrcweir 
199cdf0e10cSrcweir class SglAttrElement : public EmptyElement
200cdf0e10cSrcweir {
201cdf0e10cSrcweir   public:
202cdf0e10cSrcweir 						SglAttrElement(
203cdf0e10cSrcweir 							const char *		i_sName,
204cdf0e10cSrcweir 							const char *		i_sAttrName );
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	virtual void        Parse(
207cdf0e10cSrcweir 							X2CParser &			io_rParser );
208cdf0e10cSrcweir 	virtual void        Write2Html(
209cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
210cdf0e10cSrcweir   private:
211cdf0e10cSrcweir 	Simstr				sAttrName;
212cdf0e10cSrcweir 	Simstr				sAttrValue;
213cdf0e10cSrcweir };
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 
216cdf0e10cSrcweir class MultipleAttrElement : public EmptyElement
217cdf0e10cSrcweir {
218cdf0e10cSrcweir   public:
219cdf0e10cSrcweir 						MultipleAttrElement(
220cdf0e10cSrcweir 							const char *		i_sName,
221cdf0e10cSrcweir 							const char **		i_sAttrNames,
222cdf0e10cSrcweir 							unsigned			i_nSize );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	virtual void        Parse(
225cdf0e10cSrcweir 							X2CParser &			io_rParser );
226cdf0e10cSrcweir 	virtual void        Write2Html(
227cdf0e10cSrcweir 							HtmlCreator &		io_rHC ) const;
228cdf0e10cSrcweir   private:
229cdf0e10cSrcweir 	List<Simstr>		aAttrNames;
230cdf0e10cSrcweir 	List<Simstr>		aAttrValues;
231cdf0e10cSrcweir };
232cdf0e10cSrcweir 
233cdf0e10cSrcweir // IMPLEMENTATION
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 
236cdf0e10cSrcweir #endif
237cdf0e10cSrcweir 
238