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