Changeset 15652

Show
Ignore:
Timestamp:
22.05.2008 16:07:46 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Moved the exists() function into dbclass because it can be shared between gdbmclass and sqlitedbclass.

Location:
gsdl/trunk/lib
Files:
6 modified

Legend:

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

    r15598 r15652  
    2929 
    3030dbclass::~dbclass() {} 
     31 
     32 
     33// May be overwritten by subclasses; returns true if exists 
     34bool dbclass::exists (const text_t& key) 
     35{ 
     36  text_t data; 
     37  return getkeydata (key, data); 
     38} 
    3139 
    3240 
  • gsdl/trunk/lib/dbclass.h

    r15650 r15652  
    5454  virtual ~dbclass(); 
    5555 
    56   // Must be implemented by subclasses; returns true if opened 
     56  // MUST be implemented by subclasses; returns true if opened 
    5757  virtual bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock) = 0; 
    5858 
    59   // Must be implemented by subclasses 
     59  // MUST be implemented by subclasses 
    6060  virtual void closedatabase () = 0; 
    6161 
    62   // Must be implemented by subclasses 
     62  // MUST be implemented by subclasses 
    6363  virtual void deletekey (const text_t &key) = 0; 
    6464 
    65   // Must be implemented by subclasses; returns true if exists 
    66   virtual bool exists (const text_t& key) = 0; 
     65  // May be overwritten by subclasses; returns true if exists 
     66  virtual bool exists (const text_t& key); 
    6767 
    6868  // Must be implemented by subclasses; returns true on success 
    6969  virtual bool getinfo (const text_t& key, infodbclass &info) = 0; 
    7070 
    71   // Must be implemented by subclasses; returns true on success 
     71  // MUST be implemented by subclasses; returns true on success 
    7272  virtual bool getkeydata (const text_t& key, text_t &data) = 0; 
    7373 
    74   // Must be implemented by subclasses; returns array of keys 
     74  // MUST be implemented by subclasses; returns array of keys 
    7575  virtual text_tarray getkeys () = 0; 
    7676 
     
    7878  virtual bool setinfo (const text_t &key, const infodbclass &info) = 0; 
    7979 
    80   // Must be implemented by subclasses; returns true on success 
     80  // MUST be implemented by subclasses; returns true on success 
    8181  virtual bool setkeydata (const text_t &key, const text_t &data) = 0; 
    8282 
  • gsdl/trunk/lib/gdbmclass.cpp

    r15651 r15652  
    112112  // free up the key memory 
    113113  delete []key_data.dptr; 
    114 } 
    115  
    116  
    117 // returns true if exists 
    118 bool gdbmclass::exists (const text_t& key) 
    119 { 
    120   text_t data; 
    121   return getkeydata (key, data); 
    122114} 
    123115 
  • gsdl/trunk/lib/gdbmclass.h

    r15649 r15652  
    6262  void deletekey (const text_t &key); 
    6363 
    64   // returns true if exists 
    65   bool exists (const text_t& key); 
    66  
    6764  // returns true on success 
    6865  bool getinfo (const text_t& key, infodbclass &info); 
  • gsdl/trunk/lib/sqlitedbclass.cpp

    r15648 r15652  
    8686  text_t sql_cmd = "DELETE FROM data WHERE key='" + key + "'"; 
    8787  sqlexec(sql_cmd); 
    88 } 
    89  
    90  
    91 // returns true if exists 
    92 bool sqlitedbclass::exists (const text_t& key) 
    93 { 
    94   text_t sql_cmd = "SELECT value FROM data WHERE key='" + key + "'"; 
    95   vector<text_tmap> sql_results; 
    96   if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
    97   { 
    98     return false; 
    99   } 
    100  
    101   return true; 
    10288} 
    10389 
  • gsdl/trunk/lib/sqlitedbclass.h

    r15648 r15652  
    4545  void deletekey (const text_t &key); 
    4646 
    47   // returns true if exists 
    48   bool exists (const text_t& key); 
    49  
    5047  // returns true on success 
    5148  bool getinfo (const text_t& key, infodbclass &info);