3 * wxbDataParser, class that receives and analyses data
4 * wxbPanel, main frame's notebook panels
6 * Nicolas Boichat, April-July 2004
11 Copyright (C) 2004 Kern Sibbald and John Walker
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License
15 as published by the Free Software Foundation; either version 2
16 of the License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include "wx/wxprec.h"
39 class wxbDataTokenizer;
40 class wxbPromptParser;
54 /* Parse a table in tableParser */
55 static wxbTableParser* CreateAndWaitForParser(wxString cmd);
57 /* Run a command, and waits until result is fully received,
58 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
59 * containing the data. */
60 static wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
62 /* Run a command, and waits until prompt result is fully received,
63 * if keepresults is true, returns a valid pointer to a wxbPromptParser
64 * containing the data. */
65 static wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
72 * abstract class that can receive director information.
77 /* Creates a new wxbDataParser, and register it in wxbMainFrame
78 * lineanalysis : indicate if date is to be analysed line by line (true)
79 * or packet by packet (false).
81 wxbDataParser(bool lineanalysis);
83 /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
84 virtual ~wxbDataParser();
87 * Receives director information, forwarded by wxbMainFrame, and sends it
88 * line by line to the virtual function Analyse.
90 * Returns true if status == CS_PROMPT and the message has been parsed
93 bool Print(wxString str, int status);
96 * Receives data to analyse.
98 virtual bool Analyse(wxString str, int status) = 0;
105 * abstract panel that can receive director information.
107 class wxbPanel : public wxPanel
110 wxbPanel(wxWindow* parent) : wxPanel(parent) {}
113 * Tab title in the notebook.
115 virtual wxString GetTitle() = 0;
118 * Enable or disable this panel
120 virtual void EnablePanel(bool enable = true) = 0;
124 * Receives director information, and splits it by line.
126 * datatokenizer[0] retrieves first line
128 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
131 /* Creates a new wxbDataTokenizer */
132 wxbDataTokenizer(bool linebyline);
134 /* Destroy a wxbDataTokenizer */
135 virtual ~wxbDataTokenizer();
138 * Receives data to analyse.
140 virtual bool Analyse(wxString str, int status);
142 /* Returns true if the last signal received was an end signal,
143 * indicating that no more data is available */
151 * Receives director information, and check if the last messages are questions.
153 class wxbPromptParser: public wxbDataParser
156 /* Creates a new wxbDataTokenizer */
159 /* Destroy a wxbDataTokenizer */
160 virtual ~wxbPromptParser();
163 * Receives data to analyse.
165 virtual bool Analyse(wxString str, int status);
167 /* Returns true if the last signal received was an prompt signal,
168 * or an end signal */
171 /* Returns true if the last message received is a prompt message */
174 /* Returns multiple choice question's introduction */
175 wxString getIntroString();
177 /* Returns question string */
178 wxString getQuestionString();
180 /* Returns a wxArrayString containing the indexed choices we have
181 * to answer the question, or NULL if this question is not a multiple
183 wxArrayString* getChoices();
185 /* Returns true if the expected answer to the choice list is a number,
186 * false if it is a string (for example yes/mod/no). */
187 bool isNumericalChoice();
194 wxArrayString* choices;
195 wxString questionStr;