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);
67 /* Sleeps during milliseconds (wrapper for wxUsleep (2.4) or wxMilliSleep (2.6)) */
68 static void MilliSleep(unsigned long milliseconds);
70 static wxString ConvertToPrintable(wxString& str);
77 * abstract class that can receive director information.
82 /* Creates a new wxbDataParser, and register it in wxbMainFrame
83 * lineanalysis : indicate if date is to be analysed line by line (true)
84 * or packet by packet (false).
86 wxbDataParser(bool lineanalysis);
88 /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
89 virtual ~wxbDataParser();
92 * Receives director information, forwarded by wxbMainFrame, and sends it
93 * line by line to the virtual function Analyse.
95 * Returns true if status == CS_PROMPT and the message has been parsed
98 bool Print(wxString str, int status);
101 * Receives data to analyse.
103 virtual bool Analyse(wxString str, int status) = 0;
110 * abstract panel that can receive director information.
112 class wxbPanel : public wxPanel
115 wxbPanel(wxWindow* parent) : wxPanel(parent) {}
118 * Tab title in the notebook.
120 virtual wxString GetTitle() = 0;
123 * Enable or disable this panel
125 virtual void EnablePanel(bool enable = true) = 0;
129 * Receives director information, and splits it by line.
131 * datatokenizer[0] retrieves first line
133 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
136 /* Creates a new wxbDataTokenizer */
137 wxbDataTokenizer(bool linebyline);
139 /* Destroy a wxbDataTokenizer */
140 virtual ~wxbDataTokenizer();
143 * Receives data to analyse.
145 virtual bool Analyse(wxString str, int status);
147 /* Returns true if the last signal received was an end signal,
148 * indicating that no more data is available */
156 * Receives director information, and check if the last messages are questions.
158 class wxbPromptParser: public wxbDataParser
161 /* Creates a new wxbDataTokenizer */
164 /* Destroy a wxbDataTokenizer */
165 virtual ~wxbPromptParser();
168 * Receives data to analyse.
170 virtual bool Analyse(wxString str, int status);
172 /* Returns true if the last signal received was an prompt signal,
173 * or an end signal */
176 /* Returns true if the last message received is a prompt message */
179 /* Returns multiple choice question's introduction */
180 wxString getIntroString();
182 /* Returns question string */
183 wxString getQuestionString();
185 /* Returns a wxArrayString containing the indexed choices we have
186 * to answer the question, or NULL if this question is not a multiple
188 wxArrayString* getChoices();
190 /* Returns true if the expected answer to the choice list is a number,
191 * false if it is a string (for example yes/mod/no). */
192 bool isNumericalChoice();
199 wxArrayString* choices;
200 wxString questionStr;