summaryrefslogtreecommitdiff
path: root/ADBC/adbc/SQLite/Record.h
blob: 6da19ecb62e30793c1ddfbac0c90b2f9cb5c5087 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// -*- C++ -*-

//=============================================================================
/**
 * @file        Record.h
 *
 * $Id$
 *
 * @author      James H. Hill
 */
//=============================================================================

#ifndef _CUTS_DB_SQLITE_RECORD_H_
#define _CUTS_DB_SQLITE_RECORD_H_

#include "SQLite_export.h"
#include "adbc/Record.h"

namespace ADBC
{
namespace SQLite
{
// Forward decl.
class Query;

/**
 * @class Record
 *
 * Implemenation of the Record for SQLite.
 */
class ADBC_SQLITE_Export Record : public ADBC::Record
{
public:
  // Friend decl.
  friend class Query;

  /// Destructor
  virtual ~Record (void);

  /**
   * Get the number of rows in the record. Right now, this always
   * returns 0 since there is no way to determine the number of
   * rows in a record using SQLite.
   */
  virtual size_t count (void) const;

  /**
   * Get the number of columns in the record.
   *
   * @return        Number of columns.
   */
  virtual size_t columns (void) const;

  /**
   * Get the name of the column.
   *
   * @param[in]     index         Index of the column.
   * @param[in]     name          Name of the column.
   */
  const char * column_name (size_t index);

  /// Move to the next row in the record.
  virtual void advance (void);

  /// Test if reached the last row in the record.
  virtual bool done (void) const;

  virtual void get_data (size_t column, char * buffer, size_t bufsize);

  virtual void get_data (size_t column, char & value);

  virtual void get_data (size_t column, unsigned char & value);

  virtual void get_data (size_t column, short & value);

  virtual void get_data (size_t column, unsigned short & value);

  virtual void get_data (size_t column, long & value);

  virtual void get_data (size_t column, unsigned long & value);

  virtual void get_data (size_t column, float & value);

  virtual void get_data (size_t column, double & value);

  virtual void get_data (size_t column, ACE_Date_Time & datetime);

  virtual void get_data (size_t column, ACE_CString & value);

  /// Reset the record.
  virtual void reset (void);

private:
  /**
   * Initializing constructor. The ::ADBC::SQLite::Query class is the
   * only object that has access to this method.
   *
   * @param[in]       query         Parent of the record
   * @param[in]       state         Initial state
   */
  Record (const Query & query);

  /// Parent of the record.
  const Query & query_;

  /// The record's state.
  int state_;
};
}
}

#if defined (__ADBC_INLINE__)
#include "Record.inl"
#endif

#endif  // !defined _CUTS_DB_SQLITE_RECORD_H_