Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
resourcemgr.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2015 by Dimitri van Heesch.
4
*
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation under the terms of the GNU General Public License is hereby
7
* granted. No representations are made about the suitability of this software
8
* for any purpose. It is provided "as is" without express or implied warranty.
9
* See the GNU General Public License for more details.
10
*
11
* Documents produced by Doxygen are derivative works derived from the
12
* input used in their production; they are not affected by this license.
13
*
14
*/
15
#ifndef RESOURCEMGR_H
16
#define RESOURCEMGR_H
17
18
#include <memory>
19
#include <initializer_list>
20
21
#include "
qcstring.h
"
22
#include "
construct.h
"
23
24
/** @brief Compiled resource */
25
struct
Resource
26
{
27
enum
Type
{
Verbatim
,
SVG
};
28
const
char
*
category
;
29
const
char
*
name
;
30
const
unsigned
char
*
data
;
31
int
size
;
32
Type
type
;
33
};
34
35
/** @brief Singleton for managing resources compiled into an executable */
36
class
ResourceMgr
37
{
38
public
:
39
/** Returns the one and only instance of this class */
40
static
ResourceMgr
&
instance
();
41
42
/** Registers an array of resources */
43
void
registerResources
(std::initializer_list<Resource> resources);
44
45
/** Writes all resource belonging to a given category to a given target directory */
46
bool
writeCategory
(
const
QCString
&categoryName,
const
QCString
&targetDir)
const
;
47
48
/** Copies a registered resource to a given target directory */
49
bool
copyResource
(
const
QCString
&name,
const
QCString
&targetDir)
const
;
50
51
/** Copies a registered resource to a given target directory under a given target name */
52
bool
copyResourceAs
(
const
QCString
&name,
const
QCString
&targetDir,
const
QCString
&targetName,
bool
append=
false
)
const
;
53
54
/** Gets the resource data as a C string */
55
QCString
getAsString
(
const
QCString
&name)
const
;
56
57
private
:
58
/** Returns a pointer to the resource object with the given name. */
59
const
Resource
*
get
(
const
QCString
&name)
const
;
60
61
ResourceMgr
();
62
~ResourceMgr
();
63
NON_COPYABLE
(
ResourceMgr
)
64
65
class
Private
;
66
std::unique_ptr<Private>
p
;
67
};
68
69
#endif
QCString
This is an alternative implementation of QCString.
Definition
qcstring.h:101
ResourceMgr::Private
Definition
resourcemgr.cpp:28
ResourceMgr::instance
static ResourceMgr & instance()
Returns the one and only instance of this class.
Definition
resourcemgr.cpp:33
ResourceMgr::get
const Resource * get(const QCString &name) const
Returns a pointer to the resource object with the given name.
Definition
resourcemgr.cpp:127
ResourceMgr::copyResource
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory.
Definition
resourcemgr.cpp:122
ResourceMgr::writeCategory
bool writeCategory(const QCString &categoryName, const QCString &targetDir) const
Writes all resource belonging to a given category to a given target directory.
Definition
resourcemgr.cpp:55
ResourceMgr::getAsString
QCString getAsString(const QCString &name) const
Gets the resource data as a C string.
Definition
resourcemgr.cpp:134
ResourceMgr::copyResourceAs
bool copyResourceAs(const QCString &name, const QCString &targetDir, const QCString &targetName, bool append=false) const
Copies a registered resource to a given target directory under a given target name.
Definition
resourcemgr.cpp:79
ResourceMgr::ResourceMgr
ResourceMgr()
Definition
resourcemgr.cpp:39
ResourceMgr::p
std::unique_ptr< Private > p
Definition
resourcemgr.h:66
ResourceMgr::registerResources
void registerResources(std::initializer_list< Resource > resources)
Registers an array of resources.
Definition
resourcemgr.cpp:47
ResourceMgr::~ResourceMgr
~ResourceMgr()
Definition
resourcemgr.cpp:43
construct.h
NON_COPYABLE
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition
construct.h:37
qcstring.h
Resource
Compiled resource.
Definition
resourcemgr.h:26
Resource::name
const char * name
Definition
resourcemgr.h:29
Resource::size
int size
Definition
resourcemgr.h:31
Resource::category
const char * category
Definition
resourcemgr.h:28
Resource::Type
Type
Definition
resourcemgr.h:27
Resource::SVG
@ SVG
Definition
resourcemgr.h:27
Resource::Verbatim
@ Verbatim
Definition
resourcemgr.h:27
Resource::data
const unsigned char * data
Definition
resourcemgr.h:30
Resource::type
Type type
Definition
resourcemgr.h:32
src
resourcemgr.h
Generated by
1.17.0