NCBI C++ ToolKit
dbapi_impl_result.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef DBAPI_DRIVER_IMPL___DBAPI_IMPL_RESULT__HPP
2 #define DBAPI_DRIVER_IMPL___DBAPI_IMPL_RESULT__HPP
3 
4 /* $Id: dbapi_impl_result.hpp 71962 2016-04-08 13:52:30Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Sergey Sikorskiy
30  *
31  * File Description:
32  *
33  */
34 
37 
38 
40 
41 namespace impl {
42 
43 /////////////////////////////////////////////////////////////////////////////
44 ///
45 /// CResult::
46 ///
47 
49 {
50  friend class ncbi::CDB_Result; // Because of Release().
51 
52 public:
53  CResult(void);
54  virtual ~CResult(void);
55 
56 public:
57  /// Get type of the result
58  virtual EDB_ResType ResultType(void) const = 0;
59 
60  virtual const CDBParams& GetDefineParams(void) const;
61 
62  /// Fetch next row
63  virtual bool Fetch(void) = 0;
64 
65  /// Return current item number we can retrieve (0,1,...)
66  /// Return "-1" if no more items left (or available) to read.
67  virtual int CurrentItemNo(void) const = 0;
68 
69  /// Return number of columns in the recordset.
70  virtual int GetColumnNum(void) const = 0;
71 
72  /// Get a result item (you can use either GetItem or ReadItem).
73  /// If "item_buf" is not NULL, then use "*item_buf" (its type should be
74  /// compatible with the type of retrieved item!) to retrieve the item to;
75  /// otherwise allocate new "CDB_Object".
76  virtual CDB_Object* GetItem(CDB_Object* item_buf = 0,
78 
79  /// Read a result item body (for BLOB columns, mostly).
80  /// Return number of successfully read bytes.
81  /// Set "*is_null" to TRUE if the item is <NULL>.
82  /// Throw an exception on any error.
83  virtual size_t ReadItem(void* buffer, size_t buffer_size,
84  bool* is_null = 0) = 0;
85 
86  /// Get a descriptor for a BLOB column (for SendData).
87  /// Return NULL if this result doesn't (or can't) have a BLOB descriptor.
88  /// NOTE: you need to call ReadItem (maybe even with buffer_size == 0)
89  /// before calling this method!
90  virtual I_BlobDescriptor* GetBlobDescriptor(void) = 0;
91 
93  { return GetBlobDescriptor(); }
94 
95  /// Skip result item
96  virtual bool SkipItem(void) = 0;
97 
98  void AttachTo(CDB_Result* interface)
99  {
100  m_Interface = interface;
101  }
102 
103  const CDB_Params& GetDefineParamsImpl(void) const
104  {
105  return m_DefineParams;
106  }
108  {
109  return m_DefineParams;
110  }
111 
112 protected:
115 
116 private:
117  void Release(void)
118  {
119 // delete this;
120  DetachInterface();
121  }
122 
123  void DetachInterface(void)
124  {
125  m_Interface.DetachInterface();
126  }
127 
129 
130 };
131 
132 
133 } // namespace impl
134 
136 
137 #endif /* DBAPI_DRIVER_IMPL___DBAPI_IMPL_RESULT__HPP */
CDBParams.
Definition: interfaces.hpp:154
I_BlobDescriptor::
Definition: interfaces.hpp:369
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, I_Result::EGetItem policy=I_Result::eAppendLOB)=0
Get a result item (you can use either GetItem or ReadItem).
virtual I_BlobDescriptor * GetBlobDescriptor(void)=0
Get a descriptor for a BLOB column (for SendData).
virtual int CurrentItemNo(void) const =0
Return current item number we can retrieve (0,1,...) Return "-1" if no more items left (or available)...
const CDB_Params & GetDefineParamsImpl(void) const
CInterfaceHook< CDB_Result > m_Interface
CCachedRowInfo m_CachedRowInfo
virtual bool SkipItem(void)=0
Skip result item.
virtual int GetColumnNum(void) const =0
Return number of columns in the recordset.
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)=0
Read a result item body (for BLOB columns, mostly).
void AttachTo(CDB_Result *interface)
CDB_Params m_DefineParams
I_BlobDescriptor * GetImageOrTextDescriptor(void)
virtual EDB_ResType ResultType(void) const =0
Get type of the result.
virtual bool Fetch(void)=0
Fetch next row.
CDB_Params & GetDefineParamsImpl(void)
void DetachInterface(void)
EDB_ResType
EDB_ResType::
Definition: interfaces.hpp:386
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_DBAPIDRIVER_EXPORT
Definition: ncbi_export.h:392
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static int buffer_size
Definition: pcretest.c:1050
Modified on Mon Apr 22 04:04:56 2024 by modify_doxy.py rev. 669887