Bump version to 4.1-6
[LibreOffice.git] / idl / inc / database.hxx
blob1702ed77618ff84a8accc972085002554cdf1bdf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _DATABASE_HXX
21 #define _DATABASE_HXX
23 #include <module.hxx>
24 #include <hash.hxx>
25 #include <lex.hxx>
26 #include <rtl/string.hxx>
27 #include <tools/pstm.hxx>
29 #include <rtl/ustring.hxx>
30 #include <set>
32 class SvCommand;
34 class SvIdlError
36 OString aText;
37 public:
38 sal_uInt32 nLine, nColumn;
40 SvIdlError() : nLine(0), nColumn(0) {}
41 SvIdlError( sal_uInt32 nL, sal_uInt32 nC )
42 : nLine(nL), nColumn(nC) {}
44 const OString& GetText() const { return aText; }
45 void SetText( const OString& rT ) { aText = rT; }
46 sal_Bool IsError() const { return nLine != 0; }
47 void Clear() { nLine = nColumn = 0; }
48 SvIdlError & operator = ( const SvIdlError & rRef )
49 { aText = rRef.aText;
50 nLine = rRef.nLine;
51 nColumn = rRef.nColumn;
52 return *this;
56 class SvIdlDataBase
58 sal_Bool bExport;
59 String aExportFile;
60 sal_uInt32 nUniqueId;
61 sal_uInt32 nVerbosity;
62 String aDataBaseFile;
63 SvPersistStream aPersStream;
64 StringList aIdFileList;
65 SvStringHashTable * pIdTable;
67 SvMetaTypeMemberList aTypeList;
68 SvMetaClassMemberList aClassList;
69 SvMetaModuleMemberList aModuleList;
70 SvMetaAttributeMemberList aAttrList;
71 SvMetaTypeMemberList aTmpTypeList; // not persistent
73 protected:
74 ::std::set< OUString > m_DepFiles;
75 SvMetaObjectMemberStack aContextStack;
76 String aPath;
77 SvIdlError aError;
78 void WriteReset()
80 aUsedTypes.clear();
81 aIFaceName = OString();
83 public:
84 explicit SvIdlDataBase( const SvCommand& rCmd );
85 ~SvIdlDataBase();
86 static sal_Bool IsBinaryFormat( SvStream & rInStm );
88 void Load( SvStream & rInStm );
89 void Save( SvStream & rInStm, sal_uInt32 nContextFlags );
91 SvMetaAttributeMemberList& GetAttrList() { return aAttrList; }
92 SvStringHashTable * GetIdTable() { return pIdTable; }
93 SvMetaTypeMemberList & GetTypeList();
94 SvMetaClassMemberList & GetClassList() { return aClassList; }
95 SvMetaModuleMemberList & GetModuleList() { return aModuleList; }
96 SvMetaModule * GetModule( const OString& rName );
98 // list of used types while writing
99 SvMetaTypeMemberList aUsedTypes;
100 OString aIFaceName;
101 SvNumberIdentifier aStructSlotId;
103 void StartNewFile( const String& rName );
104 void SetExportFile( const String& rName )
105 { aExportFile = rName; }
106 void AppendAttr( SvMetaAttribute *pSlot );
107 const SvIdlError & GetError() const { return aError; }
108 void SetError( const SvIdlError & r )
109 { aError = r; }
111 const String & GetPath() const { return aPath; }
112 SvMetaObjectMemberStack & GetStack() { return aContextStack; }
114 void Write(const OString& rText);
115 void WriteError(const OString& rErrWrn,
116 const OString& rFileName,
117 const OString& rErrorText,
118 sal_uLong nRow = 0, sal_uLong nColumn = 0 ) const;
119 void WriteError( SvTokenStream & rInStm );
120 void SetError( const OString& rError, SvToken * pTok );
121 void Push( SvMetaObject * pObj );
122 sal_Bool Pop( sal_Bool bOk, SvTokenStream & rInStm, sal_uInt32 nTokPos )
124 GetStack().Pop();
125 if( bOk )
126 aError.Clear();
127 else
128 rInStm.Seek( nTokPos );
129 return bOk;
131 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
132 sal_Bool FindId( const OString& rIdName, sal_uLong * pVal );
133 sal_Bool InsertId( const OString& rIdName, sal_uLong nVal );
134 sal_Bool ReadIdFile( const String & rFileName );
136 SvMetaType * FindType( const OString& rName );
137 static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & );
139 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
140 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
141 SvMetaType * pType = NULL );
142 SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& );
143 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
144 void AddDepFile(String const& rFileName);
145 bool WriteDepFile(SvFileStream & rStream, OUString const& rTarget);
148 class SvIdlWorkingBase : public SvIdlDataBase
150 public:
151 explicit SvIdlWorkingBase( const SvCommand& rCmd );
153 sal_Bool ReadSvIdl( SvTokenStream &, sal_Bool bImported, const String & rPath );
154 sal_Bool WriteSvIdl( SvStream & );
156 sal_Bool WriteSfx( SvStream & );
157 sal_Bool WriteHelpIds( SvStream & );
158 sal_Bool WriteSfxItem( SvStream & );
159 sal_Bool WriteCSV( SvStream& );
160 sal_Bool WriteDocumentation( SvStream& );
163 #endif // _DATABASE_HXX
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */