Changeset 15643

Show
Ignore:
Timestamp:
22.05.2008 15:26:18 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Added new getkeydata() function so a sqlitedbclass can be used for the history.db file.

Location:
gsdl/trunk/lib
Files:
2 modified

Legend:

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

    r15642 r15643  
    106106bool sqlitedbclass::getinfo (const text_t& key, infodbclass &info) 
    107107{ 
     108  text_t data; 
     109  if (!getkeydata(key, data)) return false; 
     110 
     111  // Use getinfoline() to parse the data value into the infodbclass object 
     112  text_t::iterator data_iterator = data.begin(); 
     113  text_t ikey, ivalue; 
     114  info.clear(); 
     115  while (getinfoline(data_iterator, data.end(), ikey, ivalue)) 
     116  { 
     117    info.addinfo(ikey, ivalue); 
     118  } 
     119 
     120  return true; 
     121} 
     122 
     123 
     124// returns true on success 
     125bool sqlitedbclass::getkeydata (const text_t& key, text_t &data) 
     126{ 
    108127  text_t sql_cmd = "SELECT value FROM data WHERE key='" + key + "'"; 
    109128  vector<text_tmap> sql_results; 
     
    114133 
    115134  text_tmap sql_result = sql_results[0]; 
    116   text_t sql_result_value = sql_result["value"]; 
    117   text_t::iterator sql_result_value_iterator = sql_result_value.begin(); 
    118   text_t ikey, ivalue; 
    119   info.clear(); 
    120   while (getinfoline(sql_result_value_iterator, sql_result_value.end(), ikey, ivalue)) 
    121   { 
    122     info.addinfo(ikey, ivalue); 
    123   } 
    124  
     135  data = sql_result["value"]; 
    125136  return true; 
    126137} 
  • gsdl/trunk/lib/sqlitedbclass.h

    r15642 r15643  
    3939 
    4040  // returns true if opened 
    41   bool opendatabase (const text_t &filename, int mode, int num_retrys,  
    42              bool need_filelock); 
     41  bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock); 
    4342 
    4443  void closedatabase (); 
     
    5251  bool getinfo (const text_t& key, infodbclass &info); 
    5352 
     53  // returns true on success 
     54  bool getkeydata (const text_t& key, text_t &data); 
     55 
    5456  // returns array of keys 
    5557  text_tarray getkeys (); 
     
    6264  sqlite3* sqlitefile; 
    6365 
    64   bool getinfoline (text_t::iterator &here, text_t::iterator end,  
    65             text_t &key, text_t &value); 
     66  bool getinfoline (text_t::iterator &here, text_t::iterator end, text_t &key, text_t &value); 
    6667 
    6768  bool sqlexec (const text_t &sql_cmd);