Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / basic / codecompletecache.hxx
blob2c6c0873fcb0f750d7910588a98ed72dde193e97
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 INCLUDED_BASIC_CODECOMPLETECACHE_HXX
21 #define INCLUDED_BASIC_CODECOMPLETECACHE_HXX
23 #include <config_options.h>
24 #include <basic/basicdllapi.h>
25 #include <rtl/ustring.hxx>
26 #include <unordered_map>
28 typedef std::unordered_map< OUString, OUString > CodeCompleteVarTypes;
29 /* variable name, type */
30 typedef std::unordered_map< OUString, CodeCompleteVarTypes > CodeCompleteVarScopes;
31 /* procedure, CodeCompleteVarTypes */
33 class BASIC_DLLPUBLIC CodeCompleteOptions
36 * class to store basic code completion
37 * options
38 * */
39 private:
40 bool bIsCodeCompleteOn;
41 bool bIsProcedureAutoCompleteOn;
42 bool bIsAutoCloseQuotesOn;
43 bool bIsAutoCloseParenthesisOn;
44 bool bIsAutoCorrectOn;
45 bool bExtendedTypeDeclarationOn;
47 public:
48 CodeCompleteOptions();
50 static bool IsCodeCompleteOn();
51 static void SetCodeCompleteOn( bool b );
53 static bool IsExtendedTypeDeclaration();
54 static void SetExtendedTypeDeclaration( bool b );
56 static bool IsProcedureAutoCompleteOn();
57 static void SetProcedureAutoCompleteOn( bool b );
59 static bool IsAutoCloseQuotesOn();
60 static void SetAutoCloseQuotesOn( bool b );
62 static bool IsAutoCloseParenthesisOn();
63 static void SetAutoCloseParenthesisOn( bool b );
65 static bool IsAutoCorrectOn();
66 static void SetAutoCorrectOn( bool b );
69 class UNLESS_MERGELIBS(BASIC_DLLPUBLIC) CodeCompleteDataCache final
72 * cache to store data for
73 * code completion
74 * */
75 private:
76 CodeCompleteVarScopes aVarScopes;
77 CodeCompleteVarTypes aGlobalVars;
79 public:
80 CodeCompleteDataCache(){}
82 friend BASIC_DLLPUBLIC std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache);
84 void InsertGlobalVar( const OUString& sVarName, const OUString& sVarType );
85 void InsertLocalVar( const OUString& sProcName, const OUString& sVarName, const OUString& sVarType );
86 OUString GetVarType( std::u16string_view sVarName ) const;
87 OUString GetCorrectCaseVarName( std::u16string_view sVarName, std::u16string_view sActProcName ) const;
88 void Clear();
91 #endif // INCLUDED_BASIC_CODECOMPLETECACHE_HXX
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */