]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fs_mem.h
workaround for BCC bug - use #defines instead of enums
[wxWidgets.git] / include / wx / fs_mem.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fs_mem.h
3 // Purpose: in-memory file system
4 // Author: Vaclav Slavik
5 // Copyright: (c) 2000 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_FS_MEM_H_
10 #define _WX_FS_MEM_H_
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
13 // Some older compilers (such as EMX) cannot handle
14 // #pragma interface/implementation correctly, iff
15 // #pragma implementation is used in _two_ translation
16 // units (as created by e.g. event.cpp compiled for
17 // libwx_base and event.cpp compiled for libwx_gui_core).
18 // So we must not use those pragmas for those compilers in
19 // such files.
20 #pragma interface "fs_mem.h"
21 #endif
22
23 #include "wx/wxprec.h"
24
25 #ifdef __BORLANDC__
26 #pragma hdrstop
27 #endif
28
29 #if wxUSE_FILESYSTEM
30
31 #include "wx/filesys.h"
32
33 #if wxUSE_GUI
34 class WXDLLIMPEXP_CORE wxBitmap;
35 class WXDLLIMPEXP_CORE wxImage;
36 #endif // wxUSE_GUI
37
38 // ----------------------------------------------------------------------------
39 // wxMemoryFSHandlerBase
40 // ----------------------------------------------------------------------------
41
42 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase : public wxFileSystemHandler
43 {
44 public:
45 wxMemoryFSHandlerBase();
46 ~wxMemoryFSHandlerBase();
47
48 // Add file to list of files stored in memory. Stored data (bitmap, text or
49 // raw data) will be copied into private memory stream and available under
50 // name "memory:" + filename
51 static void AddFile(const wxString& filename, const wxString& textdata);
52 static void AddFile(const wxString& filename, const void *binarydata, size_t size);
53
54 // Remove file from memory FS and free occupied memory
55 static void RemoveFile(const wxString& filename);
56
57 virtual bool CanOpen(const wxString& location);
58 virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
59 virtual wxString FindFirst(const wxString& spec, int flags = 0);
60 virtual wxString FindNext();
61
62 protected:
63 static bool CheckHash(const wxString& filename);
64 static wxHashTable *m_Hash;
65 };
66
67 // ----------------------------------------------------------------------------
68 // wxMemoryFSHandler
69 // ----------------------------------------------------------------------------
70
71 #if wxUSE_GUI
72
73 // add GUI-only operations to the base class
74 class WXDLLIMPEXP_CORE wxMemoryFSHandler : public wxMemoryFSHandlerBase
75 {
76 public:
77 // bring the base class versions into the scope, otherwise they would be
78 // inaccessible in wxMemoryFSHandler
79 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
80 static void AddFile(const wxString& filename, const wxString& textdata)
81 {
82 wxMemoryFSHandlerBase::AddFile(filename, textdata);
83 }
84
85 static void AddFile(const wxString& filename,
86 const void *binarydata,
87 size_t size)
88 {
89 wxMemoryFSHandlerBase::AddFile(filename, binarydata, size);
90 }
91
92 #if wxUSE_IMAGE
93 static void AddFile(const wxString& filename, wxImage& image, long type);
94
95 static void AddFile(const wxString& filename,
96 const wxBitmap& bitmap,
97 long type);
98 #endif // wxUSE_IMAGE
99
100 };
101
102 #else // !wxUSE_GUI
103
104 // just the same thing as the base class in wxBase
105 class WXDLLIMPEXP_BASE wxMemoryFSHandler : public wxMemoryFSHandlerBase
106 {
107 };
108
109 #endif // wxUSE_GUI/!wxUSE_GUI
110
111 #endif // wxUSE_FILESYSTEM
112
113 #endif // _WX_FS_MEM_H_
114