xref: /AOO41X/main/tools/inc/tools/config.hxx (revision 8b851043d896eaadc6634f0a22437412985b1d4a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONFIG_HXX
24 #define _CONFIG_HXX
25 
26 #include "tools/toolsdllapi.h"
27 #include <tools/string.hxx>
28 
29 struct ImplConfigData;
30 struct ImplGroupData;
31 
32 // ----------
33 // - Config -
34 // ----------
35 
36 class TOOLS_DLLPUBLIC Config
37 {
38 private:
39     XubString           maFileName;
40     ByteString          maGroupName;
41     ImplConfigData*     mpData;
42     ImplGroupData*      mpActGroup;
43     sal_uIntPtr             mnDataUpdateId;
44     sal_uInt16              mnLockCount;
45     sal_Bool                mbPersistence;
46     sal_Bool                mbDummy1;
47 
48 #ifdef _CONFIG_CXX
49     TOOLS_DLLPRIVATE sal_Bool               ImplUpdateConfig() const;
50     TOOLS_DLLPRIVATE ImplGroupData*     ImplGetGroup() const;
51 #endif
52 
53 public:
54                         Config();
55                         Config( const XubString& rFileName );
56                         ~Config();
57 
GetPathName() const58     const XubString&    GetPathName() const { return maFileName; }
59     static XubString    GetDefDirectory();
60     static XubString    GetConfigName( const XubString& rPath, const XubString& rBaseName );
61 
62     void                SetGroup( const ByteString& rGroup );
GetGroup() const63     const ByteString&   GetGroup() const { return maGroupName; }
64     void                DeleteGroup( const ByteString& rGroup );
65     ByteString          GetGroupName( sal_uInt16 nGroup ) const;
66     sal_uInt16              GetGroupCount() const;
67     sal_Bool                HasGroup( const ByteString& rGroup ) const;
68 
69     ByteString          ReadKey( const ByteString& rKey ) const;
70     UniString           ReadKey( const ByteString& rKey, rtl_TextEncoding eEncoding ) const;
71     ByteString          ReadKey( const ByteString& rKey, const ByteString& rDefault ) const;
72     void                WriteKey( const ByteString& rKey, const ByteString& rValue );
73     void                WriteKey( const ByteString& rKey, const UniString& rValue, rtl_TextEncoding eEncoding );
74     void                DeleteKey( const ByteString& rKey );
75     ByteString          GetKeyName( sal_uInt16 nKey ) const;
76     ByteString          ReadKey( sal_uInt16 nKey ) const;
77     sal_uInt16              GetKeyCount() const;
78 
79     void                EnterLock();
80     void                LeaveLock();
IsLocked() const81     sal_Bool                IsLocked() const { return (mnLockCount != 0); }
82     sal_Bool                Update();
83     void                Flush();
84 
EnablePersistence(sal_Bool bPersistence=sal_True)85     void                EnablePersistence( sal_Bool bPersistence = sal_True )
86                             { mbPersistence = bPersistence; }
IsPersistenceEnabled() const87     sal_Bool                IsPersistenceEnabled() const { return mbPersistence; }
88 
89     void                SetLineEnd( LineEnd eLineEnd );
90     LineEnd             GetLineEnd() const;
91 
92 private:
93     TOOLS_DLLPRIVATE                Config( const Config& rConfig );
94     TOOLS_DLLPRIVATE Config&            operator = ( const Config& rConfig );
95 };
96 
97 #endif // _SV_CONFIG_HXX
98