Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / docparser.C
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.C /main/4 1996/08/21 15:51:05 drk $
24 #include "Debug.h"
25 #include "DocParser.h"
26 #include "Element.h"
27 #include "PathTable.h"
28 #include "Renderer.h"
29 #include "Resolver.h"
30 #include "StyleSheet.h"
31 #include "StyleSheetExceptions.h"
32 #include "VariableTable.h"
33 #include <iostream>
34 using namespace std;
35
36 Renderer *gRenderer = 0;
37 class TestRenderer : public Renderer
38 {
39 public:
40
41   // inherited virtuals
42
43   void Begin()  {} ;
44   void End()    {} ;
45
46   FeatureSet *initialize();
47   unsigned int BeginElement(const Element       &element,
48                             const FeatureSet    &featureset,
49                             const FeatureSet    &complete,
50                             const FeatureSet    &parentComplete);
51
52   void data(const char *data, unsigned int size);
53
54   void EndElement(const Symbol &element_name);
55 };
56
57 FeatureSet *
58 TestRenderer::initialize()
59 {
60   return new FeatureSet;
61 }
62 unsigned int
63 TestRenderer::BeginElement(const Element &element,
64                            const FeatureSet    &localset,
65                            const FeatureSet    &complete,
66                            const FeatureSet    &/* parentComplete */)
67 {
68   ON_DEBUG(cerr << "TestRenderer::BeginElement()" << endl);
69
70   ON_DEBUG(cerr << localset<< endl);
71   ON_DEBUG(cerr << complete << endl);
72
73   if (localset.lookup(gSymTab->intern("ignore")))
74     return 1 ; // ignore 
75
76   cout << element << endl;
77
78   return 0 ; // do not ignore 
79 }
80 void
81 TestRenderer::data(const char * data, unsigned int /* size */)
82 {
83   ON_DEBUG(cerr << "TestRenderer::data()" << endl);
84   cout << data ;
85 }
86 void
87 TestRenderer::EndElement(const Symbol &name)
88 {
89   ON_DEBUG(cerr << "TestRenderer::EndElement(" << name << ')' << endl);
90   cout << "</" << name << '>';
91 }
92 void
93 styleerror(char *errorstr)
94 {
95   cerr << errorstr ;
96 }
97
98 // extern FILE *stylein;
99 extern int styleparse();
100
101 extern PathTable       *gPathTab;
102 extern VariableTable   *gVariableTable ;
103
104 extern istream *g_stylein;
105
106 main(int argc, char **argv)
107 {
108   INIT_EXCEPTIONS();
109
110   StyleSheet ss ;
111
112   ifstream stylestream(argv[1]);
113   g_stylein = &stylestream;
114   g_stylein->unsetf(ios::skipws);
115   styleparse();
116
117   try
118     {
119       TestRenderer      renderer ;
120       Resolver resolver(*gPathTab, renderer);
121       DocParser docparser(resolver);
122       docparser.parse(cin);
123     }
124   catch_any()
125     {
126       cerr << "docparser.C: exception thrown" << endl;
127       rethrow;
128     }
129   end_try;
130
131   cout << endl;
132   
133   exit (0);
134 }