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