-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeanLoader.h
52 lines (39 loc) · 1.01 KB
/
BeanLoader.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
#ifndef BeanLoader_H
#define BeanLoader_H
namespace hiberlite{
class LoadBean {
public:
template<class AV>
inline void notifyInitWalk(AV& av);
template<class AV>
inline void notifyDoneWalk(AV& av);
template<class AV, class C>
inline void act(AV& av, db_atom<C> atom){
int col_indx=locateCol(av.getScope().prefix());
atom.loadValue(stmt.top().first, col_indx);
}
template<class AV, class E, class S>
inline void act(AV& av, collection_nvp<E,S> nvp );
protected:
std::stack< std::pair<SQLiteSelect,sqlid_t> > stmt;
inline int locateCol(std::string name){
SQLiteSelect& sel=stmt.top().first;
unsigned int n=sel.column_count();
for(unsigned int i=0;i<n;i++)
if(sel.get_name(i)==name)
return i;
throw database_error(name+": column not found in SELECT query results");
}
};
class BeanLoader : AVisitor<LoadBean>
{
public:
BeanLoader();
template<class C>
C* loadBean(bean_key k);
protected:
LoadBean actor;
private:
};
} //namespace hiberlite
#endif // BeanLoader_H