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-2006 Kern Sibbald
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 version 2 as amended with additional clauses defined in the
16 file LICENSE in the main source directory.
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 the file LICENSE for additional details.
28 #include "wx/wxprec.h"
36 class wxbDataTokenizer;
37 class wxbPromptParser;
51 /* Parse a table in tableParser */
52 static wxbTableParser* CreateAndWaitForParser(wxString cmd);
54 /* Run a command, and waits until result is fully received,
55 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
56 * containing the data. */
57 static wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
59 /* Run a command, and waits until prompt result is fully received,
60 * if keepresults is true, returns a valid pointer to a wxbPromptParser
61 * containing the data. */
62 static wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
64 /* Sleeps during milliseconds (wrapper for wxUsleep (2.4) or wxMilliSleep (2.6)) */
65 static void MilliSleep(unsigned long milliseconds);
67 static wxString ConvertToPrintable(wxString& str);
74 * abstract class that can receive director information.
79 /* Creates a new wxbDataParser, and register it in wxbMainFrame
80 * lineanalysis : indicate if date is to be analysed line by line (true)
81 * or packet by packet (false).
83 wxbDataParser(bool lineanalysis);
85 /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
86 virtual ~wxbDataParser();
89 * Receives director information, forwarded by wxbMainFrame, and sends it
90 * line by line to the virtual function Analyse.
92 * Returns true if status == CS_PROMPT and the message has been parsed
95 bool Print(wxString str, int status);
98 * Receives data to analyse.
100 virtual bool Analyse(wxString str, int status) = 0;
107 * abstract panel that can receive director information.
109 class wxbPanel : public wxPanel
112 wxbPanel(wxWindow* parent) : wxPanel(parent) {}
115 * Tab title in the notebook.
117 virtual wxString GetTitle() = 0;
120 * Enable or disable this panel
122 virtual void EnablePanel(bool enable = true) = 0;
126 * Receives director information, and splits it by line.
128 * datatokenizer[0] retrieves first line
130 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
133 /* Creates a new wxbDataTokenizer */
134 wxbDataTokenizer(bool linebyline);
136 /* Destroy a wxbDataTokenizer */
137 virtual ~wxbDataTokenizer();
140 * Receives data to analyse.
142 virtual bool Analyse(wxString str, int status);
144 /* Returns true if the last signal received was an end signal,
145 * indicating that no more data is available */
153 * Receives director information, and check if the last messages are questions.
155 class wxbPromptParser: public wxbDataParser
158 /* Creates a new wxbDataTokenizer */
161 /* Destroy a wxbDataTokenizer */
162 virtual ~wxbPromptParser();
165 * Receives data to analyse.
167 virtual bool Analyse(wxString str, int status);
169 /* Returns true if the last signal received was an prompt signal,
170 * or an end signal */
173 /* Returns true if the last message received is a prompt message */
176 /* Returns multiple choice question's introduction */
177 wxString getIntroString();
179 /* Returns question string */
180 wxString getQuestionString();
182 /* Returns a wxArrayString containing the indexed choices we have
183 * to answer the question, or NULL if this question is not a multiple
185 wxArrayString* getChoices();
187 /* Returns true if the expected answer to the choice list is a number,
188 * false if it is a string (for example yes/mod/no). */
189 bool isNumericalChoice();
196 wxArrayString* choices;
197 wxString questionStr;