3 * Class used to parse tables received from director in this format :
5 * +---------+---------+-------------------+
6 * | Header1 | Header2 | ... |
7 * +---------+---------+-------------------+
8 * | Data11 | Data12 | ... |
10 * +---------+---------+-------------------+
12 * Nicolas Boichat, April 2004
16 Copyright (C) 2004 Kern Sibbald and John Walker
18 This program is free software; you can redistribute it and/or
19 modify it under the terms of the GNU General Public License
20 as published by the Free Software Foundation; either version 2
21 of the License, or (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include "wxbtableparser.h" // class's header file
37 #include <wx/tokenzr.h>
39 #include "wxbmainframe.h"
42 * wxbTableParser constructor
44 wxbTableParser::wxbTableParser() : wxbTable(5), wxbDataParser() {
46 tableHeader = wxbTableRow(5);
50 * wxbTableParser destructor
52 wxbTableParser::~wxbTableParser() {
57 * Returns table header as an array of wxStrings.
59 wxbTableRow* wxbTableParser::GetHeader() {
64 * Receives director information, forwarded by the wxbPanel which
67 void wxbTableParser::Print(wxString str, int status) {
68 if ((status == CS_END) && (separatorNum > 0)) {
72 if (separatorNum == 3) return;
74 if (str.Length() > 4) {
75 if ((str.GetChar(0) == '+') && (str.GetChar(str.Length()-2) == '+') && (str.GetChar(str.Length()-1) == '\n')) {
80 if ((str.GetChar(0) == '|') && (str.GetChar(str.Length()-2) == '|') && (str.GetChar(str.Length()-1) == '\n')) {
82 wxStringTokenizer tkz(str, "|", wxTOKEN_STRTOK);
84 if (separatorNum == 1) {
86 while ( tkz.HasMoreTokens() ) {
87 tableHeader[i++] = tkz.GetNextToken().Trim(true).Trim(false);
90 else if (separatorNum == 2) {
91 wxbTableRow tablerow(tableHeader.size());
93 while ( tkz.HasMoreTokens() ) {
94 tablerow[i++] = tkz.GetNextToken().Trim(true).Trim(false);
96 (*this)[size()] = tablerow;
103 * Return true table parsing has finished.
105 bool wxbTableParser::hasFinished() {
106 return (separatorNum == 3);