]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbtableparser.h
- wxbHistoryTextCtrl : Created a new text control that keep an history
[bacula/bacula] / bacula / src / wx-console / wxbtableparser.h
1 /*
2  *
3  *   Class used to parse tables received from director in this format :
4  *
5  *  +---------+---------+-------------------+
6  *  | Header1 | Header2 | ...               |
7  *  +---------+---------+-------------------+
8  *  |  Data11 | Data12  | ...               |
9  *  |  ....   |  ...    | ...               |
10  *  +---------+---------+-------------------+
11  *
12  *    Nicolas Boichat, April 2004
13  *
14  */
15 /*
16    Copyright (C) 2004 Kern Sibbald and John Walker
17
18    This program is free software; you can redistribute it and/or
19    modify it under the terms of the GNU General Public License
20    as published by the Free Software Foundation; either version 2
21    of the License, or (at your option) any later version.
22
23    This program is distributed in the hope that it will be useful,
24    but WITHOUT ANY WARRANTY; without even the implied warranty of
25    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26    GNU General Public License for more details.
27
28    You should have received a copy of the GNU General Public License
29    along with this program; if not, write to the Free Software
30    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  */
32
33 #ifndef WXBTABLEPARSER_H
34 #define WXBTABLEPARSER_H
35
36 #include "wx/wxprec.h"
37
38 #ifdef __BORLANDC__
39    #pragma hdrstop
40 #endif
41
42 // for all others, include the necessary headers (this file is usually all you
43 // need because it includes almost all "standard" wxWindows headers)
44 #ifndef WX_PRECOMP
45    #include "wx/wx.h"
46 #endif
47
48 #include "wxbutils.h"
49
50 #include <wx/dynarray.h>
51
52 /* 
53  * Allow the use of Object Array (auto-deletion, object returned as themselves 
54  * and not as pointers)
55  */
56 class wxbArrayString: public wxArrayString, public wxObject {
57    public:
58       wxbArrayString(int n = 1);
59       virtual ~wxbArrayString();
60 };
61
62 WX_DECLARE_OBJARRAY( wxbArrayString, wxbTable );
63
64 /*
65  * Class used to parse tables received from director. Data can be accessed with
66  * the operator [].
67  *
68  * Example : wxString elem = parser[3][2]; fetches column 2 of element 3.
69  */
70 class wxbTableParser: public wxbTable, public wxbDataParser
71 {
72    public:
73       wxbTableParser();
74       virtual ~wxbTableParser();
75
76       /*
77        *   Receives data to analyse.
78        */
79       virtual bool Analyse(wxString str, int status);
80
81       /*
82        *   Return true table parsing has finished.
83        */
84       bool hasFinished();
85
86       /*
87        *   Returns table header as an array of wxStrings.
88        */
89       const wxbArrayString& GetHeader();
90    private:
91       wxbArrayString tableHeader;
92
93       /*
94        * 0 - Table has not begun
95        * 1 - first +--+ line obtained, header will follow
96        * 2 - second +--+ line obtained, data will follow
97        * 3 - last +--+ line obtained, table parsing has finished
98        */
99       int separatorNum;
100 };
101
102 #endif // WXBTABLEPARSER_H
103