-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRowtype.h
87 lines (73 loc) · 3.02 KB
/
Rowtype.h
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
//////////////////////////////////////////////////////////////////////////////
//
// Ora++ -- a C++ interface to Oracle based on the Oracle Call Interface
// Copyright (C) 2000-1 James Edwin Cain <[email protected]>
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or any
// later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef ORAPP_ROWTYPE_H
#define ORAPP_ROWTYPE_H
#include <iostream>
#include <vector>
#include <map>
class OCIStmt;
class OCIError;
namespace Oracle
{
class Nullable;
class Select_Stmt;
class Rowtype
{
public:
// constructors/destructor
Rowtype() throw(Error); // create empty Rowtype object
Rowtype(const Select_Stmt&) throw(Error); // initialize with select list types
virtual ~Rowtype() throw();
// implementors
void add(Nullable*, const std::string&) throw();
void set_null() throw();
inline Nullable& operator[](const int i) throw(Error)
{ if (col_vec && i >= 0 && i < col_vec->size()) return *(*col_vec)[i];
else throw_subscript_error("Rowtype::operator[](const int)", i); }
Nullable& operator[](const std::string& s) throw(Error)
{ if (col_name_m->count(s)) return *(*col_vec)[(*col_name_m)[s]];
else throw_subscript_error("Rowtype::operator[](const std::string&)", s); }
// accessors
int ncols() const throw();
std::string colname(const int) const throw(Error);
inline const Nullable& operator[](const int i) const throw(Error)
{ if (col_vec && i >= 0 && i < col_vec->size()) return *(*col_vec)[i];
else throw_subscript_error("Rowtype::operator[](const int)", i); }
const Nullable& operator[](const std::string& s) const throw(Error)
{ if (col_name_m->count(s)) return *(*col_vec)[(*col_name_m)[s]];
else throw_subscript_error("Rowtype::operator[](const std::string&)", s); }
protected:
// protected implementors
void init_data(const Select_Stmt&) throw(Error);
void throw_subscript_error(const std::string&, const int) const throw(Error);
void throw_subscript_error(const std::string&, const std::string&) const throw(Error);
// data members
OCIStmt* stmt_h;
OCIError* err_h;
std::vector<Nullable*>* col_vec;
std::vector<std::string>* col_name;
std::map<std::string, int>* col_name_m;
friend class Stmt;
friend class Select_Stmt;
};
std::ostream& operator<<(std::ostream&, const Oracle::Rowtype&) throw();
}
#endif