00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <malloc.h>
00017
00018
00019 #include <lTrace.h>
00020 #include <lDefs.h>
00021
00022
00023 #include <cQuery.h>
00024
00025 const class Query ALL("0=0");
00026 const class Query NONE("0<>0");
00027 const class Query EQUERY;
00028
00029 Query::Query(
00030 const char *const a_where,
00031 const char *const a_order_by
00032 )
00033 {
00034 StrCpy(_where = NULL, a_where);
00035 StrCpy(_order_by = NULL, a_order_by);
00036 };
00037
00038 Query::Query(
00039 const QueRefProto &X
00040 )
00041 {
00042 _where = X._Where(); //_Where() returns new string instance !!!
00043 _order_by = X._OrderBy(); //_OrderBy() returns new string instance !!!
00044 };
00045
00046 Query::Query(
00047 const Query &X
00048 )
00049 {
00050 _where = X._Where(); //_Where() returns new string instance !!!
00051 _order_by = X._OrderBy(); //_OrderBy() returns new string instance !!!
00052 };
00053
00054 Query::~Query()
00055 {
00056 StrFree(_where);
00057 StrFree(_order_by);
00058 };
00059
00060 bool Query::Where(const char * const a_where)
00061 {
00062 StrCpy(_where, a_where);
00063 return true;
00064 };
00065
00066 bool Query::OrderBy(const char * const a_order_by)
00067 {
00068 StrCpy(_order_by, a_order_by);
00069 return true;
00070 };
00071
00072 Query &Query::Not(){
00073 char *pom = NULL;
00074 if (_where) {
00075 StrCat(pom,3,"NOT(",_where,")");
00076 free(_where);
00077 _where = pom;
00078 };
00079 return *this;
00080 };
00081
00082 Query &Query::Or(const QueRefProto &Q)
00083 {
00084 char *_aux = Q._Where();
00085 StrOr(_where,_aux);
00086 StrFree(_aux);
00087 return *this;
00088 };
00089
00090 Query &Query::And(const QueRefProto &Q)
00091 {
00092 char *_aux = Q._Where();
00093 StrAnd(_where,_aux);
00094 StrFree(_aux);
00095 return *this;
00096 };
00097
00098 Query &Query::operator =(const QueRefProto &X)
00099 {
00100 if (&X != this) {
00101 StrFree(_where);
00102 _where = X._Where();
00103 StrFree(_order_by);
00104 _order_by = X._OrderBy();
00105 };
00106 return *this;
00107 };
00108
00109 Query &Query::operator =(const Query &X)
00110 {
00111 if (&X != this) {
00112 StrFree(_where);
00113 _where = X._Where();
00114 StrFree(_order_by);
00115 _order_by = X._OrderBy();
00116 };
00117 return *this;
00118 };
00119
00120 char *Query::_Where() const
00121 {
00122 char *_retval = StrCpy(_retval = NULL, _where);
00123 return _retval;
00124 };
00125
00126 char *Query::_OrderBy() const
00127 {
00128 char *_retval = StrCpy(_retval = NULL, _order_by);
00129 return _retval;
00130 };