1 /*
2 * This file is part of wxSmith plugin for Code::Blocks Studio
3 * Copyright (C) 2006-2007  Bartlomiej Swiecki
4 *
5 * wxSmith is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * wxSmith is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * $Revision: 7109 $
19 * $Id: wxspropertystream.h 7109 2011-04-15 11:53:16Z mortenmacfly $
20 * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/plugins/contrib/wxSmith/properties/wxspropertystream.h $
21 */
22 
23 #ifndef WXSPROPERTYSTREAM_H
24 #define WXSPROPERTYSTREAM_H
25 
26 #include <wx/string.h>
27 
28 /** \brief Interface for property stream
29  *
30  * Using property stream one can define any type of data reader/writer.
31  * Basic data types are processed using functions with names simillar to data
32  * types. More complex types can be processed using SubCategory() and
33  * PopCategory() functions which groups data.
34  *
35  * Each reading function returns True or False. True is returned if value read
36  * correctly, false if read error. Error will usually mean - no more data with
37  * this name found.
38  * It's permitted to use same names for different values.
39  * Calling read functions with same name will find next data with given name
40  * located in stream after previous read. This could be usefull to store arrays
41  * of data.
42  *
43  * Currently the functionality is focused on reading/writing. But it may be
44  * extended to additional data checking. Because of that fact, arguments
45  * passed to PutXXX functions (functions storing data) are using references
46  * instead of values.
47  *
48  * Most Get / Put functions are defined by dedfault. Default behaviour is to
49  * convert from / to string value. It's obvious that it can not be done for
50  * string itself. So the minimum to make property stream usable is to write
51  * own GetString / PutString functions and fuuncitons processing sub categories:
52  * SubCategory() and PopCategory().
53  */
54 class wxsPropertyStream
55 {
56     public:
57 
58         /** \brief Ctor */
wxsPropertyStream()59         wxsPropertyStream() {}
60 
61         /** \brief Dctor */
~wxsPropertyStream()62         virtual ~wxsPropertyStream() {}
63 
64         /** \brief Reading wxChar value from steram */
65         virtual bool GetChar(const wxString &Name, wxChar& Value, wxChar Default = _T('\0'));
66 
67         /** \brief Writing wxChar value to stream */
68         virtual bool PutChar(const wxString &Name, wxChar& Value, wxChar Default = _T('\0'));
69 
70         /** \brief Getting double value */
71         virtual bool GetDouble(const wxString& Name, double& value, double Default = 0.0);
72 
73         /** \brief Writting double value */
74         virtual bool PutDouble(const wxString& Name, double& value, double Default = 0.0);
75 
76         /** \brief Getting long value */
77         virtual bool GetLong(const wxString &Name, long& Value, long Default = 0);
78 
79         /** \brief Writing long value */
80         virtual bool PutLong(const wxString &Name, long& Value, long Default = 0);
81 
82         /** \brief Getting unsigned long value */
83         virtual bool GetULong(const wxString &Name, unsigned long& Value, unsigned long Default = 0);
84 
85         /** \brief Writing unsigned long value */
86         virtual bool PutULong(const wxString &Name, unsigned long& Value, unsigned long Default = 0);
87 
88         /** \brief Getting bool value */
89         virtual bool GetBool(const wxString &Name, bool& Value, bool Default = false);
90 
91         /** \brief Writing bool value */
92         virtual bool PutBool(const wxString &Name, bool& Value, bool Default = false);
93 
94         /** \brief Getting wxString value */
95         virtual bool GetString(const wxString &Name, wxString& Value, wxString Default = wxEmptyString)=0;
96 
97         /** \brief Writting wxString value */
98         virtual bool PutString(const wxString &Name, wxString& Value, wxString Default = wxEmptyString)=0;
99 
100         /** \brief Function creating new data sub-group */
101         virtual void SubCategory(const wxString &Name)=0;
102 
103         /** \brief Function restoring previous data group */
104         virtual void PopCategory()=0;
105 };
106 
107 #endif
108