Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / DocParser.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: DocParser.h /main/6 1996/06/11 17:06:11 cde-hal $ */
24 /*      Copyright (c) 1995 FUJITSU LIMITED      */
25 /*      All Rights Reserved                     */
26
27 #include <iostream>
28 #include <sstream>
29 using namespace std;
30
31 #include "SymTab.h"
32 #include "Exceptions.hh"
33
34 class Resolver;
35 class Attribute;
36 class AttributeList;
37
38 // parse SGML like documents
39
40 // attributes follow elements in an olias section
41
42 // <ELEMENT>
43 // <#><attr_1>value</>
44 //    <attr_2>value</>
45 //    <#olias_attr>value</>
46 // </>
47 // Element data here
48 // </ELEMENT>
49
50 class Element ;
51
52 class DocParser : public Destructable
53 {
54 public:
55   enum TagType { StartTag, EndTag, AttributeSection, OliasAttribute, NoTag };
56
57   DocParser(Resolver &);
58   virtual ~DocParser();
59   
60   // returns a boolean  
61   unsigned int  parse(istream &);
62
63   // parse without calling Begin() and End() on the renderer.
64   unsigned int  rawParse(istream &);
65
66 protected:
67   virtual void read_data(istream &, ostringstream &);
68
69 private:
70   
71   void          process(istream &, ostringstream &, const Symbol &tagname,
72                         unsigned int sibling_number,
73                         unsigned int relative_sibling_number);
74   TagType       read_tag(istream &, ostringstream &);
75   void          process_entity(istream &, ostringstream &);
76
77   void          process_attributes(istream &, ostringstream &,
78                                    AttributeList *&attrs,
79                                    AttributeList *&olias_attrs);
80   Attribute    *process_attribute(istream &, ostringstream &, const Symbol &name, TagType);
81   
82 private:
83   unsigned int  f_ignoring_element ;
84   Resolver      &f_resolver;
85 #if defined(SC3) || defined(__osf__)
86   char* const   f_buffer;
87   ostrstream    f_output;
88 #else
89   stringbuf     *f_streambuf;
90   ostringstream f_output;
91 #endif
92 };