3 * wxbDataParser, class that receives and analyses data
4 * wxbPanel, main frame's notebook panels
6 * Nicolas Boichat, April 2004
10 Copyright (C) 2004 Kern Sibbald and John Walker
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #include "wx/wxprec.h"
38 class wxbDataTokenizer;
39 class wxbPromptParser;
53 /* Parse a table in tableParser */
54 static wxbTableParser* CreateAndWaitForParser(wxString cmd);
56 /* Run a command, and waits until result is fully received,
57 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
58 * containing the data. */
59 static wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
61 /* Run a command, and waits until prompt result is fully received,
62 * if keepresults is true, returns a valid pointer to a wxbPromptParser
63 * containing the data. */
64 static wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
71 * abstract class that can receive director information.
76 /* Creates a new wxbDataParser, and register it in wxbMainFrame
77 * lineanalysis : indicate if date is to be analysed line by line (true)
78 * or packet by packet (false).
80 wxbDataParser(bool lineanalysis);
82 /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
83 virtual ~wxbDataParser();
86 * Receives director information, forwarded by wxbMainFrame, and sends it
87 * line by line to the virtual function Analyse.
89 * Returns true if status == CS_PROMPT and the message has been parsed
92 bool Print(wxString str, int status);
95 * Receives data to analyse.
97 virtual bool Analyse(wxString str, int status) = 0;
104 * abstract panel that can receive director information.
106 class wxbPanel : public wxPanel
109 wxbPanel(wxWindow* parent) : wxPanel(parent) {}
112 * Tab title in the notebook.
114 virtual wxString GetTitle() = 0;
117 * Enable or disable this panel
119 virtual void EnablePanel(bool enable = true) = 0;
123 * Receives director information, and splits it by line.
125 * datatokenizer[0] retrieves first line
127 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
130 /* Creates a new wxbDataTokenizer */
131 wxbDataTokenizer(bool linebyline);
133 /* Destroy a wxbDataTokenizer */
134 virtual ~wxbDataTokenizer();
137 * Receives data to analyse.
139 virtual bool Analyse(wxString str, int status);
141 /* Returns true if the last signal received was an end signal,
142 * indicating that no more data is available */
150 * Receives director information, and check if the last messages are questions.
152 class wxbPromptParser: public wxbDataParser
155 /* Creates a new wxbDataTokenizer */
158 /* Destroy a wxbDataTokenizer */
159 virtual ~wxbPromptParser();
162 * Receives data to analyse.
164 virtual bool Analyse(wxString str, int status);
166 /* Returns true if the last signal received was an prompt signal,
167 * or an end signal */
170 /* Returns true if the last message received is a prompt message */
173 /* Returns multiple choice question's introduction */
174 wxString getIntroString();
176 /* Returns question string */
177 wxString getQuestionString();
179 /* Return a wxArrayString containing the indexed choices we have
180 * to answer the question, or NULL if this question is not a multiple
182 wxArrayString* getChoices();
190 wxArrayString* choices;
191 wxString questionStr;