build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / include / tools / rc.hxx
blobebf946a07e9a4689080194bf489e0400955735e2
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 .
19 #ifndef INCLUDED_TOOLS_RC_HXX
20 #define INCLUDED_TOOLS_RC_HXX
22 #include <tools/toolsdllapi.h>
23 #include <tools/resmgr.hxx>
25 class TOOLS_DLLPUBLIC Resource
27 protected:
28 ResMgr* m_pResMgr;
30 // check availability of Resource
31 bool IsAvailableRes( const ResId& rId ) const
32 { return m_pResMgr->IsAvailable( rId, this ); }
34 // Load a Resource
35 void GetRes( const ResId& rResId );
37 // check Resource state
38 #ifdef DBG_UTIL
39 void TestRes();
40 #endif
42 // Get a pointer to the Resource's data
43 void* GetClassRes()
44 { return m_pResMgr->GetClass(); }
46 // increase the memory pointer gotten by GetClassRes()
47 void IncrementRes( sal_uInt32 nBytes )
48 { m_pResMgr->Increment( nBytes ); }
50 // return the memory size of a Resource data block
51 static sal_uInt32 GetObjSizeRes( RSHEADER_TYPE * pHT )
52 { return ResMgr::GetObjSize( pHT ); }
54 // read a 32bit value from resource data and increment pointer
55 sal_Int32 ReadLongRes()
56 { return m_pResMgr->ReadLong(); }
57 // read a 16bit value from resource data and increment pointer
58 sal_Int16 ReadShortRes()
59 { return m_pResMgr->ReadShort(); }
60 // read a string from resource data and increment pointer
61 OUString ReadStringRes()
62 { return m_pResMgr->ReadString(); }
63 // read a byte string from resource data and increment pointer
64 OString ReadByteStringRes()
65 { return m_pResMgr->ReadByteString(); }
67 // free the resource from m_pResMgr's stack (pass this ptr for validation)
68 void FreeResource()
69 { m_pResMgr->PopContext( this ); }
71 // constructors
72 Resource() : m_pResMgr( nullptr ) {}
73 Resource( const ResId& rResId );
75 public:
76 #ifdef DBG_UTIL
77 ~Resource() { TestRes(); }
78 #else
79 ~Resource() {}
80 #endif
83 #endif
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */