]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fs_mem.h
Don't create multiple parent-less top level frames in layout sample.
[wxWidgets.git] / include / wx / fs_mem.h
CommitLineData
dcb86da0 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/fs_mem.h
dcb86da0
VS
3// Purpose: in-memory file system
4// Author: Vaclav Slavik
5// Copyright: (c) 2000 Vaclav Slavik
65571936 6// Licence: wxWindows licence
dcb86da0
VS
7/////////////////////////////////////////////////////////////////////////////
8
4e8e18e2
VZ
9#ifndef _WX_FS_MEM_H_
10#define _WX_FS_MEM_H_
dcb86da0 11
372c511b 12#include "wx/defs.h"
dcb86da0 13
24528b0c 14#if wxUSE_FILESYSTEM
dcb86da0 15
dcb86da0 16#include "wx/filesys.h"
04dbb646 17
8c9d7602
VZ
18#include "wx/hashmap.h"
19
20class wxMemoryFSFile;
21WX_DECLARE_STRING_HASH_MAP(wxMemoryFSFile *, wxMemoryFSHash);
0eb2e510 22
886dd7d2 23#if wxUSE_GUI
f92ef853 24 #include "wx/bitmap.h"
886dd7d2 25#endif // wxUSE_GUI
dcb86da0 26
a8f12b67
VZ
27// ----------------------------------------------------------------------------
28// wxMemoryFSHandlerBase
29// ----------------------------------------------------------------------------
dcb86da0 30
bddd7a8d 31class WXDLLIMPEXP_BASE wxMemoryFSHandlerBase : public wxFileSystemHandler
dcb86da0 32{
e2478fde
VZ
33public:
34 wxMemoryFSHandlerBase();
d3c7fc99 35 virtual ~wxMemoryFSHandlerBase();
dcb86da0 36
e2478fde
VZ
37 // Add file to list of files stored in memory. Stored data (bitmap, text or
38 // raw data) will be copied into private memory stream and available under
39 // name "memory:" + filename
e2478fde
VZ
40 static void AddFile(const wxString& filename, const wxString& textdata);
41 static void AddFile(const wxString& filename, const void *binarydata, size_t size);
c5d7b81e
VS
42 static void AddFileWithMimeType(const wxString& filename,
43 const wxString& textdata,
44 const wxString& mimetype);
45 static void AddFileWithMimeType(const wxString& filename,
46 const void *binarydata, size_t size,
47 const wxString& mimetype);
04dbb646 48
e2478fde
VZ
49 // Remove file from memory FS and free occupied memory
50 static void RemoveFile(const wxString& filename);
04dbb646 51
e2478fde
VZ
52 virtual bool CanOpen(const wxString& location);
53 virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
54 virtual wxString FindFirst(const wxString& spec, int flags = 0);
55 virtual wxString FindNext();
04dbb646 56
60c0a8db 57protected:
8c9d7602
VZ
58 // check that the given file is not already present in m_Hash; logs an
59 // error and returns false if it does exist
60 static bool CheckDoesntExist(const wxString& filename);
61
62 // the hash map indexed by the names of the files stored in the memory FS
63 static wxMemoryFSHash m_Hash;
fcc65883
VZ
64
65 // the file name currently being searched for, i.e. the argument of the
66 // last FindFirst() call or empty string if FindFirst() hasn't been called
67 // yet or FindNext() didn't find anything
68 wxString m_findArgument;
69
70 // iterator into m_Hash used by FindFirst/Next(), possibly m_Hash.end() or
71 // even invalid (can only be used when m_findArgument is not empty)
72 wxMemoryFSHash::const_iterator m_findIter;
dcb86da0
VS
73};
74
a8f12b67
VZ
75// ----------------------------------------------------------------------------
76// wxMemoryFSHandler
77// ----------------------------------------------------------------------------
78
79#if wxUSE_GUI
80
81// add GUI-only operations to the base class
82class WXDLLIMPEXP_CORE wxMemoryFSHandler : public wxMemoryFSHandlerBase
e2478fde
VZ
83{
84public:
a8f12b67
VZ
85 // bring the base class versions into the scope, otherwise they would be
86 // inaccessible in wxMemoryFSHandler
192a6c88
VZ
87 // (unfortunately "using" can't be used as gcc 2.95 doesn't have it...)
88 static void AddFile(const wxString& filename, const wxString& textdata)
89 {
90 wxMemoryFSHandlerBase::AddFile(filename, textdata);
91 }
92
93 static void AddFile(const wxString& filename,
94 const void *binarydata,
95 size_t size)
96 {
97 wxMemoryFSHandlerBase::AddFile(filename, binarydata, size);
98 }
c5d7b81e
VS
99 static void AddFileWithMimeType(const wxString& filename,
100 const wxString& textdata,
101 const wxString& mimetype)
102 {
103 wxMemoryFSHandlerBase::AddFileWithMimeType(filename,
104 textdata,
105 mimetype);
106 }
107 static void AddFileWithMimeType(const wxString& filename,
108 const void *binarydata, size_t size,
109 const wxString& mimetype)
110 {
111 wxMemoryFSHandlerBase::AddFileWithMimeType(filename,
112 binarydata, size,
113 mimetype);
114 }
a8f12b67 115
2de5a6ee 116#if wxUSE_IMAGE
989a2421
VZ
117 static void AddFile(const wxString& filename,
118 const wxImage& image,
d75a69e8 119 wxBitmapType type);
a8f12b67 120
192a6c88
VZ
121 static void AddFile(const wxString& filename,
122 const wxBitmap& bitmap,
d75a69e8 123 wxBitmapType type);
1904aa72
DS
124#endif // wxUSE_IMAGE
125
e2478fde 126};
dcb86da0 127
a8f12b67
VZ
128#else // !wxUSE_GUI
129
130// just the same thing as the base class in wxBase
131class WXDLLIMPEXP_BASE wxMemoryFSHandler : public wxMemoryFSHandlerBase
132{
133};
134
135#endif // wxUSE_GUI/!wxUSE_GUI
136
e2478fde 137#endif // wxUSE_FILESYSTEM
dcb86da0 138
4e8e18e2
VZ
139#endif // _WX_FS_MEM_H_
140