]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbtableparser.h
kes wx-console crashes because of differences between Bacula and wxWidgets
[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) 2000-2006 Kern Sibbald
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    version 2 as amended with additional clauses defined in the
22    file LICENSE in the main source directory.
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    the file LICENSE for additional details.
28
29  */
30
31 #ifndef WXBTABLEPARSER_H
32 #define WXBTABLEPARSER_H
33
34 #include "wx/wxprec.h"
35
36 #ifdef __BORLANDC__
37    #pragma hdrstop
38 #endif
39
40 // for all others, include the necessary headers (this file is usually all you
41 // need because it includes almost all "standard" wxWindows headers)
42 #ifndef WX_PRECOMP
43    #include "wx/wx.h"
44 #endif
45
46 #include "wxbutils.h"
47
48 #include <wx/dynarray.h>
49
50 /*
51  * Allow the use of Object Array (auto-deletion, object returned as themselves
52  * and not as pointers)
53  */
54 class wxbArrayString: public wxArrayString, public wxObject {
55    public:
56       wxbArrayString(int n = 1);
57       virtual ~wxbArrayString();
58 };
59
60 WX_DECLARE_OBJARRAY( wxbArrayString, wxbTable );
61
62 /*
63  * Class used to parse tables received from director. Data can be accessed with
64  * the operator [].
65  *
66  * Example : wxString elem = parser[3][2]; fetches column 2 of element 3.
67  */
68 class wxbTableParser: public wxbTable, public wxbDataParser
69 {
70    public:
71       wxbTableParser(bool header = true);
72       virtual ~wxbTableParser();
73
74       /*
75        *   Receives data to analyse.
76        */
77       virtual bool Analyse(wxString str, int status);
78
79       /*
80        *   Return true table parsing has finished.
81        */
82       bool hasFinished();
83
84       /*
85        *   Returns table header as an array of wxStrings.
86        */
87       const wxbArrayString& GetHeader();
88    private:
89       wxbArrayString tableHeader;
90
91       /*
92        * 0 - Table has not begun
93        * 1 - first +--+ line obtained, header will follow
94        * 2 - second +--+ line obtained, data will follow
95        * 3 - last +--+ line obtained, table parsing has finished
96        */
97       int separatorNum;
98 };
99
100 #endif // WXBTABLEPARSER_H