ToolMap
Loading...
Searching...
No Matches
tmserialize.h
1/***************************************************************************
2 tmserialize.h
3 for serializating object in a simple way
4 -------------------
5 copyright : (C) 2007 CREALP Lucien Schreiber
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17// comment doxygen
18
19#ifndef _TM_SERIALIZE_H_
20#define _TM_SERIALIZE_H_
21
22// For compilers that support precompilation, includes "wx/wx.h".
23#include <wx/wxprec.h>
24
25// Include wxWidgets' headers
26#ifndef WX_PRECOMP
27#include <wx/wx.h>
28#endif
29
30#include <wx/tokenzr.h> // for string tokenizer
31
32const int TMSERIALIZE_VERSION = 1; // increment each time something change
33const wxString tmSERIAL_MAINSEP = _T("|");
34const wxString tmSERIAL_AUXSEP = _T("ยง");
35
37 private:
38 bool m_outdirection;
39 wxString m_stream;
40 wxStringTokenizer m_divStream;
41
42 bool CanStore() {
43 return m_outdirection;
44 }
45
46 bool CanRead();
47
48 void AddSeparator() {
49 m_stream.Append(tmSERIAL_MAINSEP);
50 }
51 // void AddAuxSeparator() {m_stream.Append(tmSERIAL_AUXSEP);}
52
53 void WriteInt(int value);
54
55 int ReadInt(const wxString& part);
56
57 bool ReadStream(wxString& part);
58
59 protected:
60 public:
62
63 tmSerialize(wxString stream);
64
65 virtual ~tmSerialize() {
66 ;
67 }
68
69 virtual tmSerialize& operator<<(bool value);
70
71 // virtual tmSerialize &operator << (wxString value);
72 virtual tmSerialize& operator<<(const wxString& value);
73
74 virtual tmSerialize& operator<<(const wxChar* pvalue);
75
76 virtual tmSerialize& operator<<(wxColour value);
77
78 virtual tmSerialize& operator<<(int value);
79
80 virtual tmSerialize& operator<<(long value);
81
82 virtual tmSerialize& operator>>(bool& value);
83
84 virtual tmSerialize& operator>>(wxString& value);
85
86 virtual tmSerialize& operator>>(wxColour& value);
87
88 virtual tmSerialize& operator>>(int& value);
89
90 virtual tmSerialize& operator>>(long& value);
91
92 wxString GetString() {
93 return m_stream;
94 }
95
96 bool IsStoring();
97
98 bool IsOk() {
99 return TRUE;
100 }
101
102 // for compatibility with wxSerialize
103 void EnterObject() {
104 ;
105 }
106
107 void LeaveObject() {
108 ;
109 }
110};
111
112#endif
Definition tmserialize.h:36