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 INCLUDED_IDL_INC_DATABASE_HXX
21 : #define INCLUDED_IDL_INC_DATABASE_HXX
22 :
23 : #include <module.hxx>
24 : #include <hash.hxx>
25 : #include <lex.hxx>
26 : #include <rtl/string.hxx>
27 : #include <tools/pstm.hxx>
28 :
29 : #include <rtl/ustring.hxx>
30 : #include <set>
31 :
32 : class SvCommand;
33 :
34 5417 : class SvIdlError
35 : {
36 : OString aText;
37 : public:
38 : sal_uInt32 nLine, nColumn;
39 :
40 141 : SvIdlError() : nLine(0), nColumn(0) {}
41 5010 : SvIdlError( sal_uInt32 nL, sal_uInt32 nC )
42 5010 : : nLine(nL), nColumn(nC) {}
43 :
44 0 : const OString& GetText() const { return aText; }
45 5819 : void SetText( const OString& rT ) { aText = rT; }
46 0 : bool IsError() const { return nLine != 0; }
47 : void Clear() { nLine = nColumn = 0; }
48 5276 : SvIdlError & operator = ( const SvIdlError & rRef )
49 5276 : { aText = rRef.aText;
50 5276 : nLine = rRef.nLine;
51 5276 : nColumn = rRef.nColumn;
52 5276 : return *this;
53 : }
54 : };
55 :
56 : class SvIdlDataBase
57 : {
58 : bool bExport;
59 : OUString aExportFile;
60 : sal_uInt32 nUniqueId;
61 : sal_uInt32 nVerbosity;
62 : StringList aIdFileList;
63 : SvStringHashTable * pIdTable;
64 :
65 : SvMetaTypeMemberList aTypeList;
66 : SvMetaClassMemberList aClassList;
67 : SvMetaModuleMemberList aModuleList;
68 : SvMetaAttributeMemberList aAttrList;
69 : SvMetaTypeMemberList aTmpTypeList; // not persistent
70 :
71 : protected:
72 : ::std::set< OUString > m_DepFiles;
73 : SvMetaObjectMemberStack aContextStack;
74 : OUString aPath;
75 : SvIdlError aError;
76 8 : void WriteReset()
77 : {
78 8 : aUsedTypes.clear();
79 8 : aIFaceName.clear();
80 8 : }
81 : public:
82 : OUString sSlotMapFile;
83 :
84 : explicit SvIdlDataBase( const SvCommand& rCmd );
85 : ~SvIdlDataBase();
86 :
87 69842 : SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
88 : SvStringHashTable * GetIdTable() { return pIdTable; }
89 : SvMetaTypeMemberList & GetTypeList();
90 190 : SvMetaClassMemberList & GetClassList() { return aClassList; }
91 32 : SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
92 : SvMetaModule * GetModule( const OString& rName );
93 :
94 : // list of used types while writing
95 : SvMetaTypeMemberList aUsedTypes;
96 : OString aIFaceName;
97 : SvNumberIdentifier aStructSlotId;
98 :
99 : void StartNewFile( const OUString& rName );
100 8 : void SetExportFile( const OUString& rName )
101 8 : { aExportFile = rName; }
102 : void AppendAttr( SvMetaAttribute *pSlot );
103 133 : const SvIdlError & GetError() const { return aError; }
104 266 : void SetError( const SvIdlError & r )
105 266 : { aError = r; }
106 :
107 318 : const OUString & GetPath() const { return aPath; }
108 3393 : SvMetaObjectMemberStack & GetStack() { return aContextStack; }
109 :
110 : void Write(const OString& rText);
111 : static void WriteError(const OString& rErrWrn,
112 : const OString& rFileName,
113 : const OString& rErrorText,
114 : sal_uLong nRow = 0, sal_uLong nColumn = 0 );
115 : void WriteError( SvTokenStream & rInStm );
116 : void SetError( const OString& rError, SvToken * pTok );
117 : void Push( SvMetaObject * pObj );
118 : bool Pop( bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos )
119 : {
120 : GetStack().Pop();
121 : if( bOk )
122 : aError.Clear();
123 : else
124 : rInStm.Seek( nTokPos );
125 : return bOk;
126 : }
127 5 : sal_uInt32 GetUniqueId() { return ++nUniqueId; }
128 : bool FindId( const OString& rIdName, sal_uLong * pVal );
129 : bool InsertId( const OString& rIdName, sal_uLong nVal );
130 : bool ReadIdFile( const OUString & rFileName );
131 :
132 : SvMetaType * FindType( const OString& rName );
133 : static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
134 :
135 : SvMetaType * ReadKnownType( SvTokenStream & rInStm );
136 : SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
137 : SvMetaType * pType = NULL );
138 : SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
139 : SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
140 : void AddDepFile(OUString const& rFileName);
141 : bool WriteDepFile(SvFileStream & rStream, OUString const& rTarget);
142 : };
143 :
144 8 : class SvIdlWorkingBase : public SvIdlDataBase
145 : {
146 : public:
147 : explicit SvIdlWorkingBase( const SvCommand& rCmd );
148 :
149 : bool ReadSvIdl( SvTokenStream &, bool bImported, const OUString & rPath );
150 :
151 : bool WriteSfx( SvStream & );
152 : };
153 :
154 : #endif // INCLUDED_IDL_INC_DATABASE_HXX
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|