Simplify a bit
[LibreOffice.git] / idl / inc / database.hxx
blob74c7c22e81b8d01373227abe20714b5e8d4c0987
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 #pragma once
22 #include "module.hxx"
23 #include "hash.hxx"
24 #include "lex.hxx"
25 #include <rtl/string.hxx>
27 #include <rtl/ustring.hxx>
28 #include <set>
29 #include <string_view>
30 #include <exception>
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 bool IsError() const { return nLine != 0; }
49 class SvParseException final : public std::exception
51 public:
52 SvIdlError aError;
53 SvParseException( SvTokenStream const & rInStm, const OString& rError );
54 SvParseException( const OString& rError, SvToken const & rTok );
59 class SvIdlDataBase
61 bool bExport;
62 OUString aExportFile;
63 sal_uInt32 nUniqueId;
64 sal_uInt32 nVerbosity;
65 std::vector<OUString> aIdFileList;
66 std::unique_ptr<SvStringHashTable> pIdTable;
68 SvRefMemberList<SvMetaType *> aTypeList;
69 SvRefMemberList<SvMetaClass *> aClassList;
70 SvRefMemberList<SvMetaModule *> aModuleList;
71 SvRefMemberList<SvMetaSlot *> aSlotList;
72 SvRefMemberList<SvMetaObject *> aContextStack;
74 protected:
75 ::std::set< OUString > m_DepFiles;
76 OUString aPath;
77 SvIdlError aError;
78 void WriteReset()
80 aUsedTypes.clear();
82 public:
83 OUString sSlotMapFile;
85 explicit SvIdlDataBase( const SvCommand& rCmd );
86 ~SvIdlDataBase();
88 SvRefMemberList<SvMetaType *>& GetTypeList();
89 SvRefMemberList<SvMetaClass *>& GetClassList() { return aClassList; }
90 SvRefMemberList<SvMetaModule *>& GetModuleList() { return aModuleList; }
92 // list of used types while writing
93 SvRefMemberList<SvMetaType *> aUsedTypes;
95 void StartNewFile( std::u16string_view rName );
96 void SetExportFile( const OUString& rName )
97 { aExportFile = rName; }
98 void AppendSlot( SvMetaSlot *pSlot );
99 const SvIdlError & GetError() const { return aError; }
100 void SetError( const SvIdlError & r )
101 { aError = r; }
103 const OUString & GetPath() const { return aPath; }
104 void SetPath(const OUString &s) { aPath = s; }
105 SvRefMemberList<SvMetaObject *>& GetStack() { return aContextStack; }
107 void Write(const OString& rText) const;
108 void WriteError( SvTokenStream & rInStm );
109 void SetError( const OString& rError, SvToken const & rTok );
110 void SetAndWriteError( SvTokenStream & rInStm, const OString& rError );
111 void Push( SvMetaObject * pObj );
112 sal_uInt32 GetUniqueId() { return ++nUniqueId; }
113 bool FindId( const OString& rIdName, sal_uInt32 * pVal );
114 void InsertId( const OString& rIdName, sal_uInt32 nVal );
115 bool ReadIdFile( std::string_view rFileName );
117 SvMetaType * FindType( std::string_view rName );
118 static SvMetaType * FindType( const SvMetaType *, SvRefMemberList<SvMetaType *>& );
120 SvMetaType * ReadKnownType( SvTokenStream & rInStm );
121 SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm,
122 SvMetaType * pType );
123 SvMetaAttribute * FindKnownAttr( const SvIdentifier& );
124 SvMetaClass * ReadKnownClass( SvTokenStream & rInStm );
125 SvMetaClass * FindKnownClass( std::string_view aName );
126 void AddDepFile(OUString const& rFileName);
127 void WriteDepFile(SvFileStream & rStream, std::u16string_view rTarget);
130 class SvIdlWorkingBase : public SvIdlDataBase
132 public:
133 explicit SvIdlWorkingBase( const SvCommand& rCmd );
135 bool WriteSfx( SvStream & );
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */