#include "wx/xml/xml.h"
-enum
-{
- wxXML_BINARY,
- wxXML_ARCHIVE
-};
-
-
class WXDLLEXPORT wxXmlResourceDataRecord
{
{
public:
wxXmlResource();
- wxXmlResource(const wxString& filemask, int type);
+ wxXmlResource(const wxString& filemask);
~wxXmlResource();
// Loads resources from XML files that match given filemask.
- // This method understands VFS (see filesys.h). Type is one of
- // wxXML_TEXT, wxXML_BINARY, wxXML_ARCHIVE and specifies type of
- // data to be expected:
- // wxXML_BINARY - binary version of .xml file, as produced
- // by wxXmlDocument::SaveBinary
- // wxXML_ARCHIVE - ZIP archive that contains arbitrary number
- // of files with .xmb extension
- // (this kind of ZIP archive is produced by
- // XML resources compiler that ships with wxWin)
- bool Load(const wxString& filemask, int type = wxXML_ARCHIVE);
+ // This method understands VFS (see filesys.h).
+ bool Load(const wxString& filemask);
// Initialize handlers for all supported controls/windows. This will
// make the executable quite big because it forces linking against
{
if (gs_libxmlLoaded)
{
- wxLogDebug("Releasing libxml.so.2");
wxDllLoader::UnloadLibrary(gs_libxmlDLL.Handle);
}
gs_libxmlLoaded = FALSE;
if (gs_libxmlLoadFailed) return FALSE;
gs_libxmlLoadFailed = TRUE;
- wxLogDebug("Loading libxml.so.2...");
{
wxLogNull lg;
#ifdef __UNIX__
gs_libxmlLoadFailed = FALSE;
- wxLogDebug("...succeed");
return TRUE;
}
m_Handlers.DeleteContents(TRUE);
}
-wxXmlResource::wxXmlResource(const wxString& filemask, int type)
+wxXmlResource::wxXmlResource(const wxString& filemask)
{
m_Handlers.DeleteContents(TRUE);
- Load(filemask, type);
+ Load(filemask);
}
wxXmlResource::~wxXmlResource()
}
-bool wxXmlResource::Load(const wxString& filemask, int type)
+bool wxXmlResource::Load(const wxString& filemask)
{
wxString fnd;
wxXmlResourceDataRecord *drec;
+ bool iswild = wxIsWild(filemask);
#if wxUSE_FILESYSTEM
wxFileSystem fsys;
#else
# define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE)
# define wxXmlFindNext wxFindNextFile()
- wxASSERT_MSG(type != wxXML_ARCHIVE, wxT("ZIP archive XML resources supported only with wxUSE_FILESYSTEM set to 1!"));
#endif
- fnd = wxXmlFindFirst;
+ if (iswild)
+ fnd = wxXmlFindFirst;
+ else
+ fnd = filemask;
while (!!fnd)
{
#if wxUSE_FILESYSTEM
- if (type == wxXML_ARCHIVE)
+ if (filemask.Lower().Matches("*.zip") ||
+ filemask.Lower().Matches("*.rsc"))
{
wxFileSystem fs2;
wxString fnd2;
drec->File = fnd;
m_Data.Add(drec);
}
- fnd = wxXmlFindNext;
+
+ if (iswild)
+ fnd = wxXmlFindNext;
+ else
+ fnd = wxEmptyString;
}
# undef wxXmlFindFirst
# undef wxXmlFindNext
m_Data[i].Doc = new wxXmlDocument;
}
if (!stream || !m_Data[i].Doc->Load(*stream))
+ {
wxLogError(_("Cannot load resources from file '%s'."), m_Data[i].File.c_str());
-
- if (m_Data[i].Doc->GetRoot()->GetName() != _T("resource"))
+ delete m_Data[i].Doc;
+ m_Data[i].Doc = NULL;
+ }
+ else if (m_Data[i].Doc->GetRoot()->GetName() != _T("resource"))
+ {
wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str());
-
- ProcessPlatformProperty(m_Data[i].Doc->GetRoot());
+ delete m_Data[i].Doc;
+ m_Data[i].Doc = NULL;
+ }
+ else
+ ProcessPlatformProperty(m_Data[i].Doc->GetRoot());
# if wxUSE_FILESYSTEM
delete file;
wxString dummy;
for (size_t f = 0; f < m_Data.GetCount(); f++)
{
+ if (m_Data[f].Doc == NULL || m_Data[f].Doc->GetRoot() == NULL) continue;
for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren();
node; node = node->GetNext())
if ( node->GetType() == wxXML_ELEMENT_NODE &&