Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef X2C_PARSE_HXX
21 : : #define X2C_PARSE_HXX
22 : :
23 : :
24 : :
25 : : // USED SERVICES
26 : : // BASE CLASSES
27 : : // COMPONENTS
28 : : #include "filebuff.hxx"
29 : : #include "../support/sistr.hxx"
30 : : #include "../support/list.hxx"
31 : : // PARAMETERS
32 : :
33 : :
34 : : class XmlElement;
35 : : class ListElement;
36 : :
37 : : class X2CParser
38 : : {
39 : : public:
40 : : typedef XmlElement * (*F_CREATE)(const Simstr &);
41 : :
42 : : X2CParser(
43 : : XmlElement & o_rDocumentData );
44 : : ~X2CParser();
45 : :
46 : : bool LoadFile(
47 : : const char * i_sFilename );
48 : : void Parse();
49 : : bool Parse(
50 : : const char * i_sFilename );
51 : :
52 : :
53 : 0 : const char * PureText() const { return aFile.operator const char*(); }
54 : :
55 : : void Parse_Sequence(
56 : : DynamicList<XmlElement> &
57 : : o_rElements,
58 : : const Simstr & i_sElementName );
59 : : void Parse_FreeChoice(
60 : : DynamicList<XmlElement> &
61 : : o_rElements );
62 : : void Parse_List(
63 : : ListElement & o_rListElem );
64 : : void Parse_Text(
65 : : Simstr & o_sText,
66 : : const Simstr & i_sElementName,
67 : : bool i_bReverseName );
68 : : void Parse_MultipleText(
69 : : List<Simstr> & o_rTexts,
70 : : const Simstr & i_sElementName,
71 : : bool i_bReverseName );
72 : : void Parse_SglAttr(
73 : : Simstr & o_sAttrValue,
74 : : const Simstr & i_sElementName,
75 : : const Simstr & i_sAttrName );
76 : : void Parse_MultipleAttr(
77 : : List<Simstr> & o_rAttrValues,
78 : : const Simstr & i_sElementName,
79 : : const List<Simstr> &
80 : : i_rAttrNames );
81 : :
82 : : private:
83 : : void Parse_XmlDeclaration();
84 : : void Parse_Doctype();
85 : :
86 : : void Get_Attribute(
87 : : Simstr & o_rAttrValue,
88 : : Simstr & o_rAttrName );
89 : : bool IsText(
90 : : const char * i_sComparedText );
91 : : bool IsBeginTag(
92 : : const char * i_sTagName );
93 : : bool IsEndTag(
94 : : const char * i_sTagName );
95 : : void Goto(
96 : : char i_cNext );
97 : : void Goto_And_Pass(
98 : : char i_cNext );
99 : : void Move(
100 : : int i_nForward );
101 : : void Pass_White();
102 : : void GetTextTill(
103 : : Simstr & o_rText,
104 : : char i_cEnd,
105 : : bool i_bReverseName = false );
106 : : /// @return false in case of empty tag with no attributes.
107 : : bool CheckAndPassBeginTag(
108 : : const char * i_sElementName );
109 : : void CheckAndPassEndTag(
110 : : const char * i_sElementName );
111 : : /// @precond IsBeginTag() == true.
112 : : bool IsAbsoluteEmpty() const;
113 : :
114 : :
115 : : void SyntaxError(
116 : : const char * i_sText );
117 : : void TestCurChar();
118 : :
119 : : // DATA
120 : : Simstr sFileName;
121 : : unsigned nFileLine;
122 : :
123 : : Buffer aFile;
124 : : XmlElement * pDocumentData;
125 : :
126 : : char sWord[8192];
127 : : const char * text;
128 : : };
129 : :
130 : :
131 : :
132 : : // IMPLEMENTATION
133 : :
134 : : #endif
135 : :
136 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|