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
|
/*************************************************************************
*
* HTCd - Copyright (C) 1998-2006 Henrik Rydberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <hdb/db.h>
using namespace std;
const mstring compat="(compatibility)";
const int zkey=0;
OP2_IMPL(lti) {out<<(atoi(L)<atoi(R));}
OP2_IMPL(lei) {out<<(atoi(L)<=atoi(R));}
OP2_IMPL(gei) {out<<(atoi(L)>=atoi(R));}
OP2_IMPL(gti) {out<<(atoi(L)>atoi(R));}
void dbmap::setup()
{
MLOCK(mutex);
if(M.empty()) {
opAddComp(M);
OP_ADDN(20,lti,lt.int,compat);
OP_ADDN(20,lei,le.int,compat);
OP_ADDN(20,gei,ge.int,compat);
OP_ADDN(20,gti,gt.int,compat);
M.add(new op_t("lt.case",20,M.get(sref("lt"))->f2,compat));
M.add(new op_t("gt.case",20,M.get(sref("gt"))->f2,compat));
M.add(new op_t("lt.nocase",20,M.get(sref("ltn"))->f2,compat));
M.add(new op_t("gt.nocase",20,M.get(sref("gtn"))->f2,compat));
}
}
const op_t* dbmap::CompOperator(const sref& s)
{
if(M.empty()) setup();
const op_t* p=M.get(s);
if(!p) THROW("dbmap: could not find operator "<<s);
return p;
}
///////////////////////////////////////////////////////////////////
void dbmap::Sort(const sref& tab,const sref& cmp) throw(merror_t)
{
check();
int DO=0;
if(cmp.nempty()&&cmp!=compname) { compname=cmp; DO=1; }
if(tab.nempty()) { int col=Index(tab); if(col!=index) { index=col; DO=1; } }
if(DO) remap_recs();
}
void dbmap::Order(const sref& tab,const sref& cmp) throw(merror_t)
{
check();
if(!wok) THROW("db: cannot order - readonly");
Sort(tab,cmp);
{
HEADLOCK(file);
file->head()->setcomp(index,compname);
remap_tabs();
}
}
|