Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / tools / simplerm.hxx
blobd82764f70f182d35235fb58f4c3f2c34e74222ac
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 // a simple resource manager : no stacks, no sharing of the impl class, only loading of strings and blobs
21 // but thread-safety !! :)
23 #ifndef INCLUDED_TOOLS_SIMPLERM_HXX
24 #define INCLUDED_TOOLS_SIMPLERM_HXX
26 #include <osl/mutex.hxx>
27 #include <tools/resid.hxx>
28 #include <i18nlangtag/languagetag.hxx>
29 #include <tools/toolsdllapi.h>
30 #include <memory>
32 class InternalResMgr;
34 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC SimpleResMgr final
36 osl::Mutex m_aAccessSafety;
37 std::unique_ptr<InternalResMgr>
38 m_pResImpl;
40 public:
41 /** creates a new SimpleResManager
42 @param pPrefixName
43 denotes the prefix of the resource file name,
44 in ThreadTextEncoding
45 @param rLocale
46 denotes the locale of the resource file to
47 load. If empty (SYSTEM), a default locale will be used.
49 SimpleResMgr( const sal_Char* pPrefixName,
50 const LanguageTag& rLocale);
52 ~SimpleResMgr();
54 static SimpleResMgr* Create( const sal_Char* pPrefixName,
55 const LanguageTag& rLocale );// only in VCL
57 bool IsValid() const { return m_pResImpl != nullptr; }
59 /** reads the string with the given resource id
60 @param nId
61 the resource id of the string to read
62 @return
63 the string with the given resource id, or an empty string if the id does not denote
64 an existent string
65 @seealso IsAvailable
67 OUString ReadString( sal_uInt32 nId );
69 /** checks whether a certain resource is available
70 @param _resourceType
71 the type of the resource to check. Currently, only RSC_STRING (strings) and RSC_RESOURCE (blobs)
72 are supported, for every other type, <FALSE/> will be returned.
73 @param _resourceId
74 the id of the resource to lookup.
75 @return
76 <TRUE/> if and only if a resource of the given type, with the given id, is available.
78 bool IsAvailable( RESOURCE_TYPE _resourceType, sal_uInt32 _resourceId );
81 #endif
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */