xref: /aoo41x/main/idl/inc/database.hxx (revision 67e470da)
1*f3ea6674SAndrew Rist /**************************************************************
2*f3ea6674SAndrew Rist  *
3*f3ea6674SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f3ea6674SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f3ea6674SAndrew Rist  * distributed with this work for additional information
6*f3ea6674SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f3ea6674SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f3ea6674SAndrew Rist  * "License"); you may not use this file except in compliance
9*f3ea6674SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f3ea6674SAndrew Rist  *
11*f3ea6674SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f3ea6674SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f3ea6674SAndrew Rist  * software distributed under the License is distributed on an
15*f3ea6674SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f3ea6674SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f3ea6674SAndrew Rist  * specific language governing permissions and limitations
18*f3ea6674SAndrew Rist  * under the License.
19*f3ea6674SAndrew Rist  *
20*f3ea6674SAndrew Rist  *************************************************************/
21*f3ea6674SAndrew Rist 
22*f3ea6674SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DATABASE_HXX
25cdf0e10cSrcweir #define _DATABASE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <module.hxx>
28cdf0e10cSrcweir #include <hash.hxx>
29cdf0e10cSrcweir #include <lex.hxx>
30cdf0e10cSrcweir #include <tools/pstm.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /*************************************************************************
33cdf0e10cSrcweir *************************************************************************/
34cdf0e10cSrcweir 
35cdf0e10cSrcweir class SvCommand;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifdef IDL_COMPILER
38cdf0e10cSrcweir /******************** class SvIdlError ***********************************/
39cdf0e10cSrcweir class SvIdlError
40cdf0e10cSrcweir {
41cdf0e10cSrcweir     ByteString  aText;
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir     sal_uInt32  nLine, nColumn;
44cdf0e10cSrcweir 
SvIdlError()45cdf0e10cSrcweir             SvIdlError() : nLine(0), nColumn(0) {}
SvIdlError(sal_uInt32 nL,sal_uInt32 nC)46cdf0e10cSrcweir             SvIdlError( sal_uInt32 nL, sal_uInt32 nC )
47cdf0e10cSrcweir                 : nLine(nL), nColumn(nC) {}
48cdf0e10cSrcweir 
GetText() const49cdf0e10cSrcweir     const ByteString &  GetText() const { return aText; }
SetText(const ByteString & rT)50cdf0e10cSrcweir     void            SetText( const ByteString & rT ) { aText = rT; }
IsError() const51cdf0e10cSrcweir     sal_Bool            IsError() const { return nLine != 0; }
Clear()52cdf0e10cSrcweir     void            Clear() { nLine = nColumn = 0; }
operator =(const SvIdlError & rRef)53cdf0e10cSrcweir 	SvIdlError &	operator = ( const SvIdlError & rRef )
54cdf0e10cSrcweir 	{ aText   = rRef.aText;
55cdf0e10cSrcweir 	  nLine   = rRef.nLine;
56cdf0e10cSrcweir 	  nColumn = rRef.nColumn;
57cdf0e10cSrcweir 	  return *this;
58cdf0e10cSrcweir 	}
59cdf0e10cSrcweir };
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir 
62cdf0e10cSrcweir /******************** class SvIdlDataBase ********************************/
63cdf0e10cSrcweir class SvIdlDataBase
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	sal_Bool  						bExport;
66cdf0e10cSrcweir     String                      aExportFile;
67cdf0e10cSrcweir 	sal_uInt32					nUniqueId;
68cdf0e10cSrcweir     sal_uInt32                  nVerbosity;
69cdf0e10cSrcweir     String                      aDataBaseFile;
70cdf0e10cSrcweir     SvFileStream *              pStm;
71cdf0e10cSrcweir     sal_Bool                        bIsModified;
72cdf0e10cSrcweir     SvPersistStream             aPersStream;
73cdf0e10cSrcweir     StringList                  aIdFileList;
74cdf0e10cSrcweir     SvStringHashTable *         pIdTable;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     SvMetaTypeMemberList        aTypeList;
77cdf0e10cSrcweir     SvMetaClassMemberList       aClassList;
78cdf0e10cSrcweir     SvMetaModuleMemberList      aModuleList;
79cdf0e10cSrcweir 	SvMetaAttributeMemberList	aAttrList;
80cdf0e10cSrcweir     SvMetaTypeMemberList        aTmpTypeList; // nicht Persistent
81cdf0e10cSrcweir 
82cdf0e10cSrcweir protected:
83cdf0e10cSrcweir #ifdef IDL_COMPILER
84cdf0e10cSrcweir 	ByteString						aModulePrefix;
85cdf0e10cSrcweir     SvMetaObjectMemberStack     aContextStack;
86cdf0e10cSrcweir     String                      aPath;
87cdf0e10cSrcweir     SvIdlError                  aError;
WriteReset()88cdf0e10cSrcweir 	void						WriteReset()
89cdf0e10cSrcweir 								{
90cdf0e10cSrcweir 									aUsedTypes.Clear();
91cdf0e10cSrcweir 									aIFaceName.Erase();
92cdf0e10cSrcweir 								}
93cdf0e10cSrcweir #endif
94cdf0e10cSrcweir public:
95cdf0e10cSrcweir                 explicit SvIdlDataBase( const SvCommand& rCmd );
96cdf0e10cSrcweir                 ~SvIdlDataBase();
97cdf0e10cSrcweir     static sal_Bool IsBinaryFormat( SvStream & rInStm );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     void        Load( SvStream & rInStm );
100cdf0e10cSrcweir     void        Save( SvStream & rInStm, sal_uInt32 nContextFlags );
101cdf0e10cSrcweir 
GetAttrList()102cdf0e10cSrcweir     SvMetaAttributeMemberList&  GetAttrList() { return aAttrList; }
GetIdTable()103cdf0e10cSrcweir     SvStringHashTable *       GetIdTable() { return pIdTable; }
104cdf0e10cSrcweir     SvMetaTypeMemberList &    GetTypeList();
GetClassList()105cdf0e10cSrcweir     SvMetaClassMemberList &   GetClassList()  { return aClassList; }
GetModuleList()106cdf0e10cSrcweir     SvMetaModuleMemberList &  GetModuleList() { return aModuleList; }
107cdf0e10cSrcweir     SvMetaModule *            GetModule( const ByteString & rName );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	// Liste der benutzten Typen beim Schreiben
110cdf0e10cSrcweir     SvMetaTypeMemberList	aUsedTypes;
111cdf0e10cSrcweir 	ByteString					aIFaceName;
112cdf0e10cSrcweir 	SvNumberIdentifier		aStructSlotId;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir #ifdef IDL_COMPILER
115cdf0e10cSrcweir     void                    StartNewFile( const String& rName );
SetExportFile(const String & rName)116cdf0e10cSrcweir     void                    SetExportFile( const String& rName )
117cdf0e10cSrcweir 							{ aExportFile = rName; }
118cdf0e10cSrcweir 	void					AppendAttr( SvMetaAttribute *pSlot );
GetActModulePrefix() const119cdf0e10cSrcweir 	const ByteString&			GetActModulePrefix() const { return aModulePrefix; }
GetError() const120cdf0e10cSrcweir 	const SvIdlError &		GetError() const { return aError; }
SetError(const SvIdlError & r)121cdf0e10cSrcweir 	void					SetError( const SvIdlError & r )
122cdf0e10cSrcweir 							{ aError = r; }
123cdf0e10cSrcweir 
GetPath() const124cdf0e10cSrcweir     const String &            GetPath() const { return aPath; }
GetStack()125cdf0e10cSrcweir     SvMetaObjectMemberStack & GetStack()      { return aContextStack; }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	void					Write( const ByteString & rText );
128cdf0e10cSrcweir 	void 					WriteError( const ByteString & rErrWrn,
129cdf0e10cSrcweir 									const ByteString & rFileName,
130cdf0e10cSrcweir 									const ByteString & rErrorText,
131cdf0e10cSrcweir 									sal_uLong nRow = 0, sal_uLong nColumn = 0 ) const;
132cdf0e10cSrcweir     void                    WriteError( SvTokenStream & rInStm );
133cdf0e10cSrcweir     void                    SetError( const ByteString & rError, SvToken * pTok );
134cdf0e10cSrcweir     void                    Push( SvMetaObject * pObj );
Pop(sal_Bool bOk,SvTokenStream & rInStm,sal_uInt32 nTokPos)135cdf0e10cSrcweir     sal_Bool                    Pop( sal_Bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos )
136cdf0e10cSrcweir                             {
137cdf0e10cSrcweir                                 GetStack().Pop();
138cdf0e10cSrcweir                                 if( bOk )
139cdf0e10cSrcweir                                     aError.Clear();
140cdf0e10cSrcweir                                 else
141cdf0e10cSrcweir                                     rInStm.Seek( nTokPos );
142cdf0e10cSrcweir                                 return bOk;
143cdf0e10cSrcweir                             }
GetUniqueId()144cdf0e10cSrcweir 	sal_uInt32				GetUniqueId() { return ++nUniqueId; }
145cdf0e10cSrcweir     sal_Bool                    FindId( const ByteString & rIdName, sal_uLong * pVal );
146cdf0e10cSrcweir     sal_Bool                    InsertId( const ByteString & rIdName, sal_uLong nVal );
147cdf0e10cSrcweir     sal_Bool                    ReadIdFile( const String & rFileName );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	SvMetaType *			FindType( const ByteString & rName );
150cdf0e10cSrcweir 	static SvMetaType *		FindType( const SvMetaType *, SvMetaTypeMemberList & );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     SvMetaType *            ReadKnownType( SvTokenStream & rInStm );
153cdf0e10cSrcweir     SvMetaAttribute *       ReadKnownAttr( SvTokenStream & rInStm,
154cdf0e10cSrcweir 											SvMetaType * pType = NULL );
155cdf0e10cSrcweir     SvMetaAttribute *       SearchKnownAttr( const SvNumberIdentifier& );
156cdf0e10cSrcweir     SvMetaClass *           ReadKnownClass( SvTokenStream & rInStm );
157cdf0e10cSrcweir #endif
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #ifdef IDL_COMPILER
161cdf0e10cSrcweir class SvIdlWorkingBase : public SvIdlDataBase
162cdf0e10cSrcweir {
163cdf0e10cSrcweir public:
164cdf0e10cSrcweir                 explicit SvIdlWorkingBase( const SvCommand& rCmd );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     sal_Bool        ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath );
167cdf0e10cSrcweir     sal_Bool        WriteSvIdl( SvStream & );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     sal_Bool        WriteSfx( SvStream & );
170cdf0e10cSrcweir 	sal_Bool		WriteHelpIds( SvStream & );
171cdf0e10cSrcweir     sal_Bool        WriteSfxItem( SvStream & );
172cdf0e10cSrcweir 	sal_Bool 		WriteCSV( SvStream& );
173cdf0e10cSrcweir 	sal_Bool		WriteDocumentation( SvStream& );
174cdf0e10cSrcweir };
175cdf0e10cSrcweir #endif
176cdf0e10cSrcweir 
177cdf0e10cSrcweir #endif // _DATABASE_HXX
178cdf0e10cSrcweir 
179