]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: objstrm.h | |
3 | // Purpose: wxObjectStream classes | |
4 | // Author: Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: 16/07/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Guilhem Lavaux | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | #ifndef _WX_WXOBJSTRM_H__ | |
12 | #define _WX_WXOBJSTRM_H__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface | |
16 | #endif | |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/object.h" | |
20 | #include "wx/string.h" | |
21 | #include "wx/stream.h" | |
22 | ||
23 | class wxObjectStreamInfo : public wxObject { | |
24 | public: | |
25 | wxString object_name; | |
26 | int n_children, children_removed; | |
27 | wxList children; | |
28 | wxObjectStreamInfo *parent; | |
29 | wxObject *object; | |
30 | bool duplicate, recall; | |
31 | }; | |
32 | ||
33 | class wxObjectOutputStream : public wxFilterOutputStream { | |
34 | public: | |
35 | wxObjectOutputStream(wxOutputStream& s); | |
36 | ||
37 | void AddChild(wxObject *obj); | |
38 | bool SaveObject(wxObject& obj); | |
39 | ||
40 | bool FirstStage() const { return m_stage == 0; } | |
41 | ||
42 | wxString GetObjectName(wxObject *obj); | |
43 | ||
44 | protected: | |
45 | void WriteObjectDef(wxObjectStreamInfo& info); | |
46 | void ProcessObjectDef(wxObjectStreamInfo *info); | |
47 | void ProcessObjectData(wxObjectStreamInfo *info); | |
48 | ||
49 | protected: | |
50 | int m_stage; | |
51 | bool m_saving; | |
52 | wxObjectStreamInfo *m_current_info; | |
53 | wxList m_saved_objs; | |
54 | }; | |
55 | ||
56 | class wxObjectInputStream : public wxFilterInputStream { | |
57 | public: | |
58 | wxObjectInputStream(wxInputStream& s); | |
59 | ||
60 | bool SecondCall() const { return m_secondcall; } | |
61 | void Recall(bool on = TRUE) { m_current_info->recall = on; } | |
62 | ||
63 | wxObject *GetChild(int no) const; | |
64 | wxObject *GetChild(); | |
65 | int NumberOfChildren() const { return m_current_info->n_children; } | |
66 | void RemoveChildren(int nb); | |
67 | wxObject *GetParent() const; | |
68 | wxObject *LoadObject(); | |
69 | ||
70 | wxObject *SolveName(const wxString& objName) const; | |
71 | ||
72 | protected: | |
73 | bool ReadObjectDef(wxObjectStreamInfo *info); | |
74 | wxObjectStreamInfo *ProcessObjectDef(wxObjectStreamInfo *info); | |
75 | void ProcessObjectData(wxObjectStreamInfo *info); | |
76 | ||
77 | protected: | |
78 | bool m_secondcall; | |
79 | wxObjectStreamInfo *m_current_info; | |
80 | wxList m_solver; | |
81 | }; | |
82 | ||
83 | #endif |