update dev300-m58
[ooovba.git] / idl / inc / database.hxx
blob3a3e033e9152ad4b16e10fce12f82f14a4800746
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: database.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DATABASE_HXX
32 #define _DATABASE_HXX
34 #include <module.hxx>
35 #include <hash.hxx>
36 #include <lex.hxx>
37 #include <tools/pstm.hxx>
39 /*************************************************************************
40 *************************************************************************/
42 #ifdef IDL_COMPILER
43 /******************** class SvIdlError ***********************************/
44 class SvIdlError
46 ByteString aText;
47 public:
48 UINT32 nLine, nColumn;
50 SvIdlError() : nLine(0), nColumn(0) {}
51 SvIdlError( UINT32 nL, UINT32 nC )
52 : nLine(nL), nColumn(nC) {}
54 const ByteString & GetText() const { return aText; }
55 void SetText( const ByteString & rT ) { aText = rT; }
56 BOOL IsError() const { return nLine != 0; }
57 void Clear() { nLine = nColumn = 0; }
58 SvIdlError & operator = ( const SvIdlError & rRef )
59 { aText = rRef.aText;
60 nLine = rRef.nLine;
61 nColumn = rRef.nColumn;
62 return *this;
65 #endif
67 /******************** class SvIdlDataBase ********************************/
68 class SvIdlDataBase
70 BOOL bExport;
71 String aExportFile;
72 sal_uInt32 nUniqueId;
73 String aDataBaseFile;
74 SvFileStream * pStm;
75 BOOL bIsModified;
76 SvPersistStream aPersStream;
77 StringList aIdFileList;
78 SvStringHashTable * pIdTable;
80 SvMetaTypeMemberList aTypeList;
81 SvMetaClassMemberList aClassList;
82 SvMetaModuleMemberList aModuleList;
83 SvMetaAttributeMemberList aAttrList;
84 SvMetaTypeMemberList aTmpTypeList; // nicht Persistent
86 protected:
87 #ifdef IDL_COMPILER
88 ByteString aModulePrefix;
89 SvMetaObjectMemberStack aContextStack;
90 String aPath;
91 SvIdlError aError;
92 void WriteReset()
94 aUsedTypes.Clear();
95 aIFaceName.Erase();
97 #endif
98 public:
99 SvIdlDataBase();
100 ~SvIdlDataBase();
101 static BOOL IsBinaryFormat( SvStream & rInStm );
103 void Load( SvStream & rInStm );
104 void Save( SvStream & rInStm, UINT32 nContextFlags );
106 SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
107 SvStringHashTable * GetIdTable() { return pIdTable; }
108 SvMetaTypeMemberList & GetTypeList();
109 SvMetaClassMemberList & GetClassList() { return aClassList; }
110 SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
111 SvMetaModule * GetModule( const ByteString & rName );
113 // Liste der benutzten Typen beim Schreiben
114 SvMetaTypeMemberList aUsedTypes;
115 ByteString aIFaceName;
116 SvNumberIdentifier aStructSlotId;
118 #ifdef IDL_COMPILER
119 void StartNewFile( const String& rName );
120 void SetExportFile( const String& rName )
121 { aExportFile = rName; }
122 void AppendAttr( SvMetaAttribute *pSlot );
123 const ByteString& GetActModulePrefix() const { return aModulePrefix; }
124 const SvIdlError & GetError() const { return aError; }
125 void SetError( const SvIdlError & r )
126 { aError = r; }
128 const String & GetPath() const { return aPath; }
129 SvMetaObjectMemberStack & GetStack() { return aContextStack; }
131 void Write( const ByteString & rText );
132 void WriteError( const ByteString & rErrWrn,
133 const ByteString & rFileName,
134 const ByteString & rErrorText,
135 ULONG nRow = 0, ULONG nColumn = 0 ) const;
136 void WriteError( SvTokenStream & rInStm );
137 void SetError( const ByteString & rError, SvToken * pTok );
138 void Push( SvMetaObject * pObj );
139 BOOL Pop( BOOL bOk, SvTokenStream & rInStm, UINT32 nTokPos )
141 GetStack().Pop();
142 if( bOk )
143 aError.Clear();
144 else
145 rInStm.Seek( nTokPos );
146 return bOk;
148 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
149 BOOL FindId( const ByteString & rIdName, ULONG * pVal );
150 BOOL InsertId( const ByteString & rIdName, ULONG nVal );
151 BOOL ReadIdFile( const String & rFileName );
153 SvMetaType * FindType( const ByteString & rName );
154 static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
156 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
157 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
158 SvMetaType * pType = NULL );
159 SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
160 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
161 #endif
164 #ifdef IDL_COMPILER
165 class SvIdlWorkingBase : public SvIdlDataBase
167 public:
168 SvIdlWorkingBase();
170 BOOL ReadSvIdl( SvTokenStream &, BOOL bImported, const String & rPath );
171 BOOL WriteSvIdl( SvStream & );
173 BOOL WriteSfx( SvStream & );
174 BOOL WriteHelpIds( SvStream & );
175 BOOL WriteSfxItem( SvStream & );
176 BOOL WriteCSV( SvStream& );
177 BOOL WriteDocumentation( SvStream& );
179 #endif
181 #endif // _DATABASE_HXX