00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00028 #ifndef _DBCOMPARE_H_
00029 #define _DBCOMPARE_H_
00030
00031 #include <add_algo>
00032 #include <database>
00033 #include <basic_alltype.h>
00034
00035 namespace coco {
00036
00037 #define DB_COMPARE_CMP_EQ 0
00038 #define DB_COMPARE_CMP_NE 1
00039 #define DB_COMPARE_CMP_GT 2
00040 #define DB_COMPARE_CMP_GE 3
00041 #define DB_COMPARE_CMP_LT 4
00042 #define DB_COMPARE_CMP_LE 5
00043 #define DB_COMPARE_CMP_IN 6
00044
00045 #define DB_COMPARE_CMP_ABSEQ 7
00046 #define DB_COMPARE_CMP_ABSNE 8
00047 #define DB_COMPARE_CMP_ABSGT 9
00048 #define DB_COMPARE_CMP_ABSGE 10
00049 #define DB_COMPARE_CMP_ABSLT 11
00050 #define DB_COMPARE_CMP_ABSLE 12
00051 #define DB_COMPARE_CMP_ABSIN 13
00052
00053 #define dbc_is_cmp(X) ((X) <= DB_COMPARE_CMP_ABSIN)
00054
00055 #define dbc_is_sort(X) ((X) > DB_COMPARE_CMP_ABSIN)
00056
00057 #define DB_COMPARE_SORT_MIN 14
00058 #define DB_COMPARE_SORT_MAX 15
00059 #define DB_COMPARE_SORT_ABSMIN 16
00060 #define DB_COMPARE_SORT_ABSMAX 17
00061 #define DB_COMPARE_SORT_TRUE 18
00062 #define DB_COMPARE_SORT_FALSE 19
00063
00064 typedef enum { dbc_cmp_eq=DB_COMPARE_CMP_EQ,
00065 dbc_cmp_ne=DB_COMPARE_CMP_NE,
00066 dbc_cmp_gt=DB_COMPARE_CMP_GT,
00067 dbc_cmp_ge=DB_COMPARE_CMP_GE,
00068 dbc_cmp_lt=DB_COMPARE_CMP_LT,
00069 dbc_cmp_le=DB_COMPARE_CMP_LE,
00070 dbc_cmp_in=DB_COMPARE_CMP_IN,
00071 dbc_cmp_abseq=DB_COMPARE_CMP_ABSEQ,
00072 dbc_cmp_absne=DB_COMPARE_CMP_ABSNE,
00073 dbc_cmp_absgt=DB_COMPARE_CMP_ABSGT,
00074 dbc_cmp_absge=DB_COMPARE_CMP_ABSGE,
00075 dbc_cmp_abslt=DB_COMPARE_CMP_ABSLT,
00076 dbc_cmp_absle=DB_COMPARE_CMP_ABSLE,
00077 dbc_cmp_absin=DB_COMPARE_CMP_ABSIN,
00078 dbc_sort_min=DB_COMPARE_SORT_MIN,
00079 dbc_sort_max=DB_COMPARE_SORT_MAX,
00080 dbc_sort_absmin=DB_COMPARE_SORT_ABSMIN,
00081 dbc_sort_absmax=DB_COMPARE_SORT_ABSMAX,
00082 dbc_sort_true=DB_COMPARE_SORT_TRUE,
00083 dbc_sort_false=DB_COMPARE_SORT_FALSE
00084 } dbc_method;
00085
00086 void parse_dbcompare_expression(const std::string& s,
00087 std::map<int,std::triple<std::string, dbc_method, basic_alltype> >& cols,
00088 std::vector<std::vector<int> >& expr);
00089
00090 void parse_dbcompare_sortorder(const std::string& s,
00091 std::map<int,std::triple<std::string, dbc_method, basic_alltype> >& cols,
00092 std::vector<int>& order);
00093
00094 template <typename _AT>
00095 void filter_from_view(typename std::vector<std::pair<vdbl::rowid,_AT> >& riv,
00096 vdbl::view* iv, const std::map<int,std::triple<std::string,
00097 dbc_method, basic_alltype> >& cols,
00098 const std::vector<std::vector<int> >& expr);
00099
00100 template <typename _AT>
00101 void list_from_view(typename std::vector<std::pair<vdbl::rowid,_AT> >& riv,
00102 vdbl::view* iv, const std::map<int,std::triple<std::string,
00103 dbc_method, basic_alltype > >& cols, const std::vector<int>& sort,
00104 unsigned int n);
00105
00106 }
00107
00108 #include <dbcompare.hpp>
00109
00110 #endif