]> git.sur5r.net Git - bacula/bacula/commitdiff
wxbTableParser : wxHashMap replaced by wxArray
authorNicolas Boichat <nicolas@boichat.ch>
Mon, 10 May 2004 16:43:14 +0000 (16:43 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Mon, 10 May 2004 16:43:14 +0000 (16:43 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1363 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbtableparser.cpp
bacula/src/wx-console/wxbtableparser.h

index c8cb1f67f680e46ea1b4c2a741cda0063601442e..290441b71083c868f96d71c9c975bac403c088c1 100644 (file)
@@ -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
index 915f80696d4f5cdb57be0a8264d1ed5aa59adc2e..64e1ce56ee609c363d5ec371db9bb0a715b9f446 100644 (file)
@@ -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
index 5dad78c9115cec6371b91cdb60da90a4b382385e..77cb8e68fab54d72412a3b351ead7e07442d8c2f 100644 (file)
@@ -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;
index d1413e4a58646600a40cf99d6fa9a5f06af4dcae..d5944e128bc3d756d7dfddaf7deb1ea0b2b17791 100644 (file)
 
 #include "wxbmainframe.h"
 
+#include <wx/arrimpl.cpp>
+
+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);
          }
       }
    }
index 7310c8b5bec86fc4f1e4a8c75f35427fb0ab3f5d..e7dc80b77336b5c2c078ea4c4369a402e31f464c 100644 (file)
 
 #include "wxbutils.h"
 
-#include <wx/hashmap.h>
+#include <wx/dynarray.h>
 
-/* 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