/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Database/DatabaseSvc/DatabaseSvc-00-00-24/DatabaseSvc/DatabaseRecord.h

Go to the documentation of this file.
00001 #ifndef DatabaseRecord_h
00002 #define DatabaseRecord_h
00003 
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007 #include <cstdlib>
00008 
00009 class DatabaseRecord : public std::map<std::string, char*>
00010 {
00011  public:
00012   DatabaseRecord(){}
00013 
00014   ~DatabaseRecord()
00015    {
00016         DeleteObject();
00017    }
00018 
00019   void clear(){
00020         DeleteObject();
00021   };
00022   
00023   void DeleteObject()
00024    {
00025     DatabaseRecord::iterator it;
00026     for(it=this->begin(); it != this->end(); it++)
00027      {
00028        if((*it).second!=NULL)
00029        {
00030          delete[] (*it).second;
00031          (*it).second = NULL;
00032        }
00033      }
00034     erase(this->begin(),this->end());
00035    }
00036    
00037    int GetInt(std::string key)
00038          {
00039                  DatabaseRecord::iterator it = find(key);
00040                  if(it==end())
00041                          return 0;
00042                  return atoi((*it).second);
00043          }
00044                                                                                                                                       
00045 
00046    double GetDouble(std::string key)
00047      {
00048        DatabaseRecord::iterator it = find(key);
00049        if(it==end()) 
00050             return 0;
00051        return atof((*it).second);
00052      }
00053 
00054    long GetLong(std::string key)
00055    {
00056        DatabaseRecord::iterator it = find(key);
00057        if(it==end())
00058             return 0;
00059        return atol((*it).second);
00060    }
00061 
00062    std::string GetString(std::string key)
00063    {
00064    //  std::string str1;
00065      DatabaseRecord::iterator it = find(key);
00066      if(it==end())
00067            return 0;
00068      std::string str1((*it).second); 
00069      return str1;
00070 
00071    }
00072 };
00073 
00074 class DatabaseRecordVector : public std::vector <DatabaseRecord*>
00075 {
00076  public:
00077   DatabaseRecordVector(){};
00078   ~DatabaseRecordVector()
00079   {
00080     clear();
00081   }
00082 
00083   void clear(){
00084    DatabaseRecordVector::iterator  it;
00085     for(it=this->begin(); it != this->end(); it++)
00086      {
00087         (*it)->DeleteObject();
00088      }
00089     erase(this->begin(),this->end());
00090   }
00091 };
00092 
00093 #endif

Generated on Tue Nov 29 22:57:59 2016 for BOSS_7.0.2 by  doxygen 1.4.7