Doxygen
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 */
26{
28 const char *category;
29 const char *name;
30 const unsigned char *data;
31 int size;
33};
34
35/** @brief Singleton for managing resources compiled into an executable */
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
64
65 class Private;
66 std::unique_ptr<Private> p;
67};
68
69#endif
This is an alternative implementation of QCString.
Definition qcstring.h:101
static ResourceMgr & instance()
Returns the one and only instance of this class.
const Resource * get(const QCString &name) const
Returns a pointer to the resource object with the given name.
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory.
bool writeCategory(const QCString &categoryName, const QCString &targetDir) const
Writes all resource belonging to a given category to a given target directory.
QCString getAsString(const QCString &name) const
Gets the resource data as a C string.
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.
std::unique_ptr< Private > p
Definition resourcemgr.h:66
void registerResources(std::initializer_list< Resource > resources)
Registers an array of resources.
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
Compiled resource.
Definition resourcemgr.h:26
const char * name
Definition resourcemgr.h:29
const char * category
Definition resourcemgr.h:28
const unsigned char * data
Definition resourcemgr.h:30
Type type
Definition resourcemgr.h:32