From ac5dc01e7d798abd3425a640ed2e7966a448f0bb Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 10 May 2004 16:43:14 +0000 Subject: [PATCH] wxbTableParser : wxHashMap replaced by wxArray git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1363 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 3 +++ bacula/src/wx-console/TODO | 10 +------- bacula/src/wx-console/wxbrestorepanel.cpp | 12 ++++----- bacula/src/wx-console/wxbtableparser.cpp | 30 +++++++++++++++-------- bacula/src/wx-console/wxbtableparser.h | 21 ++++++++++------ 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index c8cb1f67f6..290441b710 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,3 +1,6 @@ +10-05-2004 : + - wxbTableParser : wxHashMap replaced by wxArray + 09-05-2004 : - wxbMainFrame : reconnecting/disconnecting implemented - wxbMainFrame : Added menus to allow the user to change his config diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 915f80696d..64e1ce56ee 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -5,8 +5,6 @@ console_thread : Allow the user to choose his director when there's multiple Win32 : Crash when quitting while trying to connect -Mac OS X : Problem if config file in Mac file format (new line = ASCII 13). - Mac OS X : "You must first get a unique identifier for your application, a so called creator, a four letter constant. All you need to know about this step is at http://developer.apple.com/dev/cftype/" (wxWiki) @@ -22,8 +20,6 @@ wxbConfigFileEditor : create a more precise editor, with something like wxbRestorePanel : When cancelling, check for commands results -general : Do not quit when configuration file not found. - wxbRestorePanel : Add a way to cancel restore when building tree (needs director modifications) @@ -53,16 +49,12 @@ wxbRestorePanel : Is there any way to add a width adjustment handle between the tree view window and the file view window so that the width of the tree view can be changed? -general : Implement dis/reconnecting - wxbRestorePanel : Use ".default job=RestoreFiles" to get defaults parameters when changing a restore parameter fails. -wxbDataParser : Add a boolean in the constructor to avoid storing data is +wxbDataParser : Add a boolean in the constructor to avoid storing data which will not be used. -wxbTableParser : Replace wxHashMap by wxArray - wxbRestorePanel : Check if commands ran successfully (cd, mark, mods...). GTK : Improve look diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 5dad78c911..77cb8e68fa 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -580,7 +580,7 @@ void wxbRestorePanel::CmdStart() { int tot = 0; long l; - for (i = 0; i < tableparser->size(); i++) { + for (i = 0; i < tableparser->GetCount(); i++) { str = (*tableparser)[i][2]; str.Replace(",", ""); if (str.ToLong(&l)) { @@ -610,7 +610,7 @@ void wxbRestorePanel::CmdStart() { if (((*dt)[lastindex].Find("Building directory tree for JobId ") == 0) && ((i = (*dt)[lastindex].Find(" ...")) > 0)) { str = (*dt)[lastindex].Mid(34, i-34); - for (i = 0; i < tableparser->size(); i++) { + for (i = 0; i < tableparser->GetCount(); i++) { if (str == (*tableparser)[i][0]) { str = (*tableparser)[i][2]; str.Replace(",", ""); @@ -765,12 +765,12 @@ void wxbRestorePanel::CmdStart() { wxDateTime jobtime; - if (jobname == (*tableparser)[tableparser->size()-1][1]) { - wxStringTokenizer jtkz((*tableparser)[tableparser->size()-1][2], " ", wxTOKEN_STRTOK); + if (jobname == (*tableparser)[tableparser->GetCount()-1][1]) { + wxStringTokenizer jtkz((*tableparser)[tableparser->GetCount()-1][2], " ", wxTOKEN_STRTOK); if ((jobtime.ParseDate(jtkz.GetNextToken()) != NULL) && // Date (jobtime.ParseTime(jtkz.GetNextToken()) != NULL)) { // Time if (jobtime.IsLaterThan(currenttime)) { - jobid = (*tableparser)[tableparser->size()-1][0]; + jobid = (*tableparser)[tableparser->GetCount()-1][0]; cmd << jobid << "\n"; delete tableparser; cancel->Enable(true); @@ -1063,7 +1063,7 @@ void wxbRestorePanel::CmdListJobs() { WaitForPrompt("6\n"); wxbTableParser* tableparser = CreateAndWaitForParser(configPanel->GetRowString("Client") + "\n"); - for (int i = tableparser->size()-1; i > -1; i--) { + for (int i = tableparser->GetCount()-1; i > -1; i--) { wxString str = (*tableparser)[i][3]; wxDateTime datetime; const char* chr; diff --git a/bacula/src/wx-console/wxbtableparser.cpp b/bacula/src/wx-console/wxbtableparser.cpp index d1413e4a58..d5944e128b 100644 --- a/bacula/src/wx-console/wxbtableparser.cpp +++ b/bacula/src/wx-console/wxbtableparser.cpp @@ -38,12 +38,24 @@ #include "wxbmainframe.h" +#include + +WX_DEFINE_OBJARRAY(wxbTable); + +wxbArrayString::wxbArrayString(int n) : wxArrayString(), wxObject() { + Alloc(n); +} + +wxbArrayString::~wxbArrayString() { + +} + /* * wxbTableParser constructor */ -wxbTableParser::wxbTableParser() : wxbTable(5), wxbDataParser(true) { +wxbTableParser::wxbTableParser() : wxbTable(), wxbDataParser(true) { separatorNum = 0; - tableHeader = wxbTableRow(5); + tableHeader = wxbArrayString(); } /* @@ -56,8 +68,8 @@ wxbTableParser::~wxbTableParser() { /* * Returns table header as an array of wxStrings. */ -wxbTableRow* wxbTableParser::GetHeader() { - return &tableHeader; +const wxbArrayString& wxbTableParser::GetHeader() { + return tableHeader; } /* @@ -81,18 +93,16 @@ bool wxbTableParser::Analyse(wxString str, int status) { wxStringTokenizer tkz(str, "|", wxTOKEN_STRTOK); if (separatorNum == 1) { - int i = 0; while ( tkz.HasMoreTokens() ) { - tableHeader[i++] = tkz.GetNextToken().Trim(true).Trim(false); + tableHeader.Add(tkz.GetNextToken().Trim(true).Trim(false)); } } else if (separatorNum == 2) { - wxbTableRow tablerow(tableHeader.size()); - int i = 0; + wxbArrayString tablerow(tableHeader.GetCount()); while ( tkz.HasMoreTokens() ) { - tablerow[i++] = tkz.GetNextToken().Trim(true).Trim(false); + tablerow.Add(tkz.GetNextToken().Trim(true).Trim(false)); } - (*this)[size()] = tablerow; + Add(tablerow); } } } diff --git a/bacula/src/wx-console/wxbtableparser.h b/bacula/src/wx-console/wxbtableparser.h index 7310c8b5be..e7dc80b773 100644 --- a/bacula/src/wx-console/wxbtableparser.h +++ b/bacula/src/wx-console/wxbtableparser.h @@ -47,12 +47,19 @@ #include "wxbutils.h" -#include +#include -/* int-indexed array of wxString, used for one line */ -WX_DECLARE_HASH_MAP( int, wxString, wxIntegerHash, wxIntegerEqual, wxbTableRow ); -/* int-indexed array of wxbTableRow, contains the whole table */ -WX_DECLARE_HASH_MAP( int, wxbTableRow, wxIntegerHash, wxIntegerEqual, wxbTable ); +/* + * Allow the use of Object Array (auto-deletion, object returned as themselves + * and not as pointers) + */ +class wxbArrayString: public wxArrayString, public wxObject { + public: + wxbArrayString(int n = 1); + virtual ~wxbArrayString(); +}; + +WX_DECLARE_OBJARRAY( wxbArrayString, wxbTable ); /* * Class used to parse tables received from director. Data can be accessed with @@ -79,9 +86,9 @@ class wxbTableParser: public wxbTable, public wxbDataParser /* * Returns table header as an array of wxStrings. */ - wxbTableRow* GetHeader(); + const wxbArrayString& GetHeader(); private: - wxbTableRow tableHeader; + wxbArrayString tableHeader; /* * 0 - Table has not begun -- 2.39.5