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 <qcstring.h>
19 
20 /** @brief Compiled resource */
21 struct Resource
22 {
24  const char *category;
25  const char *name;
26  const unsigned char *data;
27  int size;
29 };
30 
31 /** @brief Singleton for managing resources compiled into an executable */
33 {
34  public:
35  /** Returns the one and only instance of this class */
36  static ResourceMgr &instance();
37 
38  /** Registers an array of resources */
39  void registerResources(const Resource resources[],int numResources);
40 
41  /** Copies all resource belonging to a given category to a given target directory */
42  bool copyCategory(const char *categoryName,const char *targetDir) const;
43 
44  /** Copies a registered resource to a given target directory */
45  bool copyResource(const char *name,const char *targetDir) const;
46 
47  /** Copies a registered resource to a given target directory under a given target name */
48  bool copyResourceAs(const char *name,const char *targetDir,const char *targetName) const;
49 
50  /** Gets the resource data as a C string */
51  QCString getAsString(const char *name) const;
52 
53  private:
54  /** Returns a pointer to the resource object with the given name. */
55  const Resource *get(const char *name) const;
56 
57  ResourceMgr();
58  ~ResourceMgr();
59  class Private;
60  Private *p;
61 };
62 
63 #endif
const std::string instance
Compiled resource.
Definition: resourcemgr.h:21
const unsigned char * data
Definition: resourcemgr.h:26
Singleton for managing resources compiled into an executable.
Definition: resourcemgr.h:32
int size
Definition: resourcemgr.h:27
const char * name
Definition: resourcemgr.h:25
Private * p
Definition: resourcemgr.h:59
Type type
Definition: resourcemgr.h:28
const char * category
Definition: resourcemgr.h:24