+#include "wx/hashset.h"
+#include "wx/scopedptr.h"
+
+namespace
+{
+
+// Helper function to get modification time of either a wxFileSystem URI or
+// just a normal file name, depending on the build.
+#if wxUSE_DATETIME
+
+wxDateTime GetXRCFileModTime(const wxString& filename)
+{
+#if wxUSE_FILESYSTEM
+ wxFileSystem fsys;
+ wxScopedPtr<wxFSFile> file(fsys.OpenFile(filename));
+
+ return file ? file->GetModificationTime() : wxDateTime();
+#else // wxUSE_FILESYSTEM
+ return wxDateTime(wxFileModificationTime(filename));
+#endif // wxUSE_FILESYSTEM
+}
+
+#endif // wxUSE_DATETIME
+
+} // anonymous namespace
+
+// Assign the given value to the specified entry or add a new value with this
+// name.
+static void XRCID_Assign(const wxString& str_id, int value);
+
+class wxXmlResourceDataRecord
+{
+public:
+ // Ctor takes ownership of the document pointer.
+ wxXmlResourceDataRecord(const wxString& File_,
+ wxXmlDocument *Doc_
+ )
+ : File(File_), Doc(Doc_)
+ {
+#if wxUSE_DATETIME
+ Time = GetXRCFileModTime(File);
+#endif
+ }
+
+ ~wxXmlResourceDataRecord() {delete Doc;}
+
+ wxString File;
+ wxXmlDocument *Doc;
+#if wxUSE_DATETIME
+ wxDateTime Time;
+#endif
+
+ wxDECLARE_NO_COPY_CLASS(wxXmlResourceDataRecord);
+};
+
+class wxXmlResourceDataRecords : public wxVector<wxXmlResourceDataRecord*>
+{
+ // this is a class so that it can be forward-declared
+};
+
+WX_DECLARE_HASH_SET_PTR(int, wxIntegerHash, wxIntegerEqual, wxHashSetInt);
+
+class wxIdRange // Holds data for a particular rangename
+{
+protected:
+ wxIdRange(const wxXmlNode* node,
+ const wxString& rname,
+ const wxString& startno,
+ const wxString& rsize);
+
+ // Note the existence of an item within the range
+ void NoteItem(const wxXmlNode* node, const wxString& item);
+
+ // The manager is telling us that it's finished adding items
+ void Finalise(const wxXmlNode* node);
+
+ wxString GetName() const { return m_name; }
+ bool IsFinalised() const { return m_finalised; }
+
+ const wxString m_name;
+ int m_start;
+ int m_end;
+ unsigned int m_size;
+ bool m_item_end_found;
+ bool m_finalised;
+ wxHashSetInt m_indices;
+
+ friend class wxIdRangeManager;
+};
+
+class wxIdRangeManager
+{
+public:
+ ~wxIdRangeManager();
+ // Gets the global resources object or creates one if none exists.
+ static wxIdRangeManager *Get();
+
+ // Sets the global resources object and returns a pointer to the previous
+ // one (may be NULL).
+ static wxIdRangeManager *Set(wxIdRangeManager *res);
+
+ // Create a new IDrange from this node
+ void AddRange(const wxXmlNode* node);
+ // Tell the IdRange that this item exists, and should be pre-allocated an ID
+ void NotifyRangeOfItem(const wxXmlNode* node, const wxString& item) const;
+ // Tells all IDranges that they're now complete, and can create their IDs
+ void FinaliseRanges(const wxXmlNode* node) const;
+ // Searches for a known IdRange matching 'name', returning its index or -1
+ int Find(const wxString& rangename) const;
+
+protected:
+ wxIdRange* FindRangeForItem(const wxXmlNode* node,
+ const wxString& item,
+ wxString& value) const;
+ wxVector<wxIdRange*> m_IdRanges;
+
+private:
+ static wxIdRangeManager *ms_instance;
+};