db_reader.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "api_database.h"
33 
34 namespace clan
35 {
38 
39 class DBValue;
40 class DateTime;
41 class DataBuffer;
42 class DBConnection;
43 class DBReaderProvider;
44 class DBReader_Impl;
45 
47 class CL_API_DATABASE DBReader
48 {
51 public:
53  DBReader();
54 
58  DBReader(const std::shared_ptr<DBReader_Impl> &impl);
59 
60  ~DBReader();
62 
65 public:
67  int get_column_count() const;
68 
70  std::string get_column_name(int index) const;
71 
73  int get_name_index(const std::string &name) const;
74 
76  DBValue get_column_value(int index) const;
77 
79  DBValue get_column_value(const std::string &name) const;
80 
82  std::string get_column_string(int index) const;
83 
85  bool get_column_bool(int index) const;
86 
88  char get_column_char(int index) const;
89 
91  unsigned char get_column_uchar(int index) const;
92 
94  int get_column_int(int index) const;
95 
97  unsigned int get_column_uint(int index) const;
98 
100  double get_column_double(int index) const;
101 
103  DateTime get_column_datetime(int index) const;
104 
106  DataBuffer get_column_binary(int index) const;
107 
109  std::string get_column_string(const std::string &column_name) const;
110 
112  bool get_column_bool(const std::string &column_name) const;
113 
115  char get_column_char(const std::string &column_name) const;
116 
118  unsigned char get_column_uchar(const std::string &column_name) const;
119 
121  int get_column_int(const std::string &column_name) const;
122 
124  unsigned int get_column_uint(const std::string &column_name) const;
125 
127  double get_column_double(const std::string &column_name) const;
128 
130  DateTime get_column_datetime(const std::string &column_name) const;
131 
133  DataBuffer get_column_binary(const std::string &column_name) const;
134 
136  DBReaderProvider *get_provider();
138 
141 public:
144  bool retrieve_row();
145 
147  void close();
149 
152 private:
153  std::shared_ptr<DBReader_Impl> impl;
154 
156 };
157 
158 }
159 
Database reader.
Definition: db_reader.h:47
Date/Time class.
Definition: datetime.h:44
Database reader provider.
Definition: db_reader_provider.h:43
Definition: db_value.h:36
General purpose data buffer.
Definition: databuffer.h:43