xref: /aoo4110/main/configmgr/source/xcsparser.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CONFIGMGR_SOURCE_XCSPARSER_HXX
25 #define INCLUDED_CONFIGMGR_SOURCE_XCSPARSER_HXX
26 
27 #include "sal/config.h"
28 
29 #include <stack>
30 
31 #include "rtl/ref.hxx"
32 #include "rtl/ustring.hxx"
33 #include "xmlreader/xmlreader.hxx"
34 
35 #include "node.hxx"
36 #include "parser.hxx"
37 #include "valueparser.hxx"
38 
39 namespace xmlreader { struct Span; }
40 
41 namespace configmgr {
42 
43 class SetNode;
44 struct Data;
45 
46 class XcsParser: public Parser {
47 public:
48     XcsParser(int layer, Data & data);
49 
50 private:
51     virtual ~XcsParser();
52 
53     virtual xmlreader::XmlReader::Text getTextMode();
54 
55     virtual bool startElement(
56         xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name);
57 
58     virtual void endElement(xmlreader::XmlReader const & reader);
59 
60     virtual void characters(xmlreader::Span const & text);
61 
62     void handleComponentSchema(xmlreader::XmlReader & reader);
63 
64     void handleNodeRef(xmlreader::XmlReader & reader);
65 
66     void handleProp(xmlreader::XmlReader & reader);
67 
68     void handlePropValue(
69         xmlreader::XmlReader & reader, rtl::Reference< Node > const & property);
70 
71     void handleGroup(xmlreader::XmlReader & reader, bool isTemplate);
72 
73     void handleSet(xmlreader::XmlReader & reader, bool isTemplate);
74 
75     void handleSetItem(xmlreader::XmlReader & reader, SetNode * set);
76 
77     enum State {
78         STATE_START, STATE_COMPONENT_SCHEMA, STATE_TEMPLATES,
79         STATE_TEMPLATES_DONE, STATE_COMPONENT, STATE_COMPONENT_DONE };
80 
81     struct Element {
82         rtl::Reference< Node > node;
83         rtl::OUString name;
84 
Elementconfigmgr::XcsParser::Element85         inline Element(
86             rtl::Reference< Node > const & theNode,
87             rtl::OUString const & theName):
88             node(theNode), name(theName) {}
89     };
90 
91     typedef std::stack< Element > ElementStack;
92 
93     ValueParser valueParser_;
94     Data & data_;
95     rtl::OUString componentName_;
96     State state_;
97     long ignoring_;
98     ElementStack elements_;
99 };
100 
101 }
102 
103 #endif
104