]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fs_mem.h
wxDF_UNICODETEXT shouldn't be supported at all in ANSI build
[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 #include "wx/defs.h"
13
14 #if wxUSE_FILESYSTEM
15
16 #include "wx/filesys.h"
17
18 #if wxUSE_GUI
19 #include "wx/bitmap.h"
20 #endif // wxUSE_GUI
21
22 // ----------------------------------------------------------------------------
23 // wxMemoryFSHandlerBase
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase : public wxFileSystemHandler
27 {
28 public:
29 wxMemoryFSHandlerBase();
30 virtual ~wxMemoryFSHandlerBase();
31
32 // Add file to list of files stored in memory. Stored data (bitmap, text or
33 // raw data) will be copied into private memory stream and available under
34 // name "memory:" + filename
35 static void AddFile(const wxString& filename, const wxString& textdata);
36 static void AddFile(const wxString& filename, const void *binarydata, size_t size);
37 static void AddFileWithMimeType(const wxString& filename,
38 const wxString& textdata,
39 const wxString& mimetype);
40 static void AddFileWithMimeType(const wxString& filename,
41 const void *binarydata, size_t size,
42 const wxString& mimetype);
43
44 // Remove file from memory FS and free occupied memory
45 static void RemoveFile(const wxString& filename);
46
47 virtual bool CanOpen(const wxString& location);
48 virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
49 virtual wxString FindFirst(const wxString& spec, int flags = 0);
50 virtual wxString FindNext();
51
52 protected:
53 static bool CheckHash(const wxString& filename);
54 static wxHashTable *m_Hash;
55 };
56
57 // ----------------------------------------------------------------------------
58 // wxMemoryFSHandler
59 // ----------------------------------------------------------------------------
60
61 #if wxUSE_GUI
62
63 // add GUI-only operations to the base class
64 class WXDLLIMPEXP_CORE wxMemoryFSHandler : public wxMemoryFSHandlerBase
65 {
66 public:
67 // bring the base class versions into the scope, otherwise they would be
68 // inaccessible in wxMemoryFSHandler
69 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
70 static void AddFile(const wxString& filename, const wxString& textdata)
71 {
72 wxMemoryFSHandlerBase::AddFile(filename, textdata);
73 }
74
75 static void AddFile(const wxString& filename,
76 const void *binarydata,
77 size_t size)
78 {
79 wxMemoryFSHandlerBase::AddFile(filename, binarydata, size);
80 }
81 static void AddFileWithMimeType(const wxString& filename,
82 const wxString& textdata,
83 const wxString& mimetype)
84 {
85 wxMemoryFSHandlerBase::AddFileWithMimeType(filename,
86 textdata,
87 mimetype);
88 }
89 static void AddFileWithMimeType(const wxString& filename,
90 const void *binarydata, size_t size,
91 const wxString& mimetype)
92 {
93 wxMemoryFSHandlerBase::AddFileWithMimeType(filename,
94 binarydata, size,
95 mimetype);
96 }
97
98 #if wxUSE_IMAGE
99 static void AddFile(const wxString& filename,
100 const wxImage& image,
101 wxBitmapType type);
102
103 static void AddFile(const wxString& filename,
104 const wxBitmap& bitmap,
105 wxBitmapType type);
106 #endif // wxUSE_IMAGE
107
108 };
109
110 #else // !wxUSE_GUI
111
112 // just the same thing as the base class in wxBase
113 class WXDLLIMPEXP_BASE wxMemoryFSHandler : public wxMemoryFSHandlerBase
114 {
115 };
116
117 #endif // wxUSE_GUI/!wxUSE_GUI
118
119 #endif // wxUSE_FILESYSTEM
120
121 #endif // _WX_FS_MEM_H_
122