Changeset 15631

Show
Ignore:
Timestamp:
22.05.2008 13:23:52 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Adding an implementation of getkeys() for the sqliteclass.

Location:
gsdl/trunk/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/lib/sqliteclass.cpp

    r15623 r15631  
    200200 
    201201 
    202 text_t sqliteclass::getfirstkey() 
    203 { 
    204   if (sqlitefile == NULL) return g_EmptyText; 
    205  
    206   // !! TO IMPLEMENT 
    207   return g_EmptyText; 
    208 } 
    209  
    210  
    211 text_t sqliteclass::getnextkey(const text_t &key) 
    212 { 
    213   if (sqlitefile == NULL || key.empty()) return g_EmptyText; 
    214  
    215   // !! TO IMPLEMENT 
    216   return g_EmptyText; 
     202text_tarray sqliteclass::getkeys () 
     203{ 
     204  text_tarray keys; 
     205 
     206  // Get all the entries in the "key" column of the table 
     207  text_t sql_cmd = "SELECT key FROM data"; 
     208  vector<text_tmap> sql_results; 
     209  if (sqlitefile == NULL || !sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
     210  { 
     211    return keys; 
     212  } 
     213 
     214  // Iterate through the keys and add them to the array to be returned 
     215  vector<text_tmap>::iterator sql_results_iterator = sql_results.begin(); 
     216  while (sql_results_iterator != sql_results.end()) 
     217  { 
     218    text_tmap sql_result = (*sql_results_iterator); 
     219    keys.push_back(sql_result["key"]); 
     220    sql_results_iterator++; 
     221  } 
     222 
     223  return keys; 
    217224} 
    218225 
  • gsdl/trunk/lib/sqliteclass.h

    r15623 r15631  
    5454  void deletekey (const text_t &key); 
    5555 
    56   // getfirstkey and getnextkey are used for traversing the database 
    57   // no insertions or deletions should be carried out while traversing 
    58   // the database. when there are no keys left to visit in the database 
    59   // an empty string is returned. 
    60   text_t getfirstkey (); 
    61   text_t getnextkey (const text_t &key); 
     56  text_tarray getkeys (); 
    6257 
    6358protected: