Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

RdbMySQLRow.hh

Go to the documentation of this file.
00001 #ifndef RDBMYSQLROW_HH
00002 #define RDBMYSQLROW_HH
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: RdbMySQLRow.hh,v 1.3 2005/04/15 17:56:07 salnikov Exp $
00007 //
00008 // Description:
00009 //      Class RdbMySQLRow.
00010 //
00011 // Environment:
00012 //      This software was developed for the BaBar collaboration.  If you
00013 //      use all or part of it, please give an appropriate acknowledgement.
00014 //
00015 // Author List:
00016 //      Andy Salnikov
00017 //
00018 // Copyright Information:
00019 //      Copyright (C) 2005 SLAC
00020 //
00021 //------------------------------------------------------------------------
00022 
00023 //-------------
00024 // C Headers --
00025 //-------------
00026 extern "C" {
00027 }
00028 
00029 //---------------
00030 // C++ Headers --
00031 //---------------
00032 
00033 //----------------------
00034 // Base Class Headers --
00035 //----------------------
00036 
00037 //-------------------------------
00038 // Collaborating Class Headers --
00039 //-------------------------------
00040 #include "RdbMySQL/RdbMySQLTypeTraits.hh"
00041 
00042 //------------------------------------
00043 // Collaborating Class Declarations --
00044 //------------------------------------
00045 
00046 //              ---------------------
00047 //              -- Class Interface --
00048 //              ---------------------
00049 
00050 
00051 /**
00052  *  This class represents a single row in the result (relation).
00053  *
00054  *  This software was developed for the BaBar collaboration.  If you
00055  *  use all or part of it, please give an appropriate acknowledgement.
00056  *
00057  *  Copyright (C) 2005 SLAC
00058  *
00059  *  @see RdbMySQLResult
00060  *  @see RdbMySQLHeader
00061  *
00062  *  @version $Id: RdbMySQLRow.hh,v 1.3 2005/04/15 17:56:07 salnikov Exp $ 
00063  *
00064  *  @author Andy Salnikov
00065  */
00066 
00067 class RdbMySQLRow {
00068 
00069 public:
00070 
00071   /**
00072    *  Constructor takes MYSQL_ROW pointer, and the fields list
00073    */
00074   RdbMySQLRow ( char** row, unsigned long* lengths ) : _row(row), _lengths(lengths) {}
00075 
00076   // Destructor
00077   ~RdbMySQLRow () {}
00078 
00079   /// get the specified field as a string
00080   const char* at( unsigned int i ) const { return _row ? _row[i] : 0 ; }
00081 
00082   /// get the size of the string
00083   unsigned long size( unsigned int i ) const { return _lengths ? _lengths[i] : 0 ; }
00084 
00085   /// do a type conversion
00086   template <typename T>
00087   bool at ( unsigned int i, T& val ) const {
00088     const char* s = at(i) ;
00089     if ( ! s ) return false ;
00090     return RdbMySQLTypeTraits<T>::str2val ( s, size(i), val ) ;
00091   }
00092 
00093 
00094 protected:
00095 
00096   // Helper functions
00097 
00098 private:
00099 
00100   // Friends
00101 
00102   // Data members
00103   char** _row ;
00104   unsigned long* _lengths ;
00105 
00106 };
00107 
00108 #endif // RDBMYSQLROW_HH

Generated on Mon Dec 5 18:22:13 2005 for CDB by doxygen1.3-rc3